FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
assemblyscript/tests/util/diff.js at master · TypeScriptExperts/assemblyscript · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
TypeScriptExperts
/
assemblyscript
Public
forked from
AssemblyScript/assemblyscript
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
assemblyscript
/
tests
/
util
/
diff.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
30 lines (26 loc) · 837 Bytes
Breadcrumbs
assemblyscript
/
tests
/
util
/
diff.js
Copy path
File metadata and controls
30 lines (26 loc) · 837 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var
JsDiff
=
require
(
"diff"
)
;
var
colors
=
require
(
"../../cli/util/colors"
)
;
module
.
exports
=
function
diff
(
filename
,
expected
,
actual
)
{
var
diff
=
JsDiff
.
structuredPatch
(
filename
,
filename
,
expected
,
actual
,
"expected"
,
"actual"
,
{
context
:
5
}
)
;
if
(
!
diff
.
hunks
.
length
)
return
null
;
var
ret
=
[
]
;
ret
.
push
(
'--- '
+
diff
.
oldHeader
)
;
ret
.
push
(
'+++ '
+
diff
.
newHeader
)
;
for
(
var
i
=
0
;
i
<
diff
.
hunks
.
length
;
i
++
)
{
var
hunk
=
diff
.
hunks
[
i
]
;
ret
.
push
(
'@@ -'
+
hunk
.
oldStart
+
','
+
hunk
.
oldLines
+
' +'
+
hunk
.
newStart
+
','
+
hunk
.
newLines
+
' @@'
)
;
ret
.
push
.
apply
(
ret
,
hunk
.
lines
.
map
(
line
=>
line
.
charAt
(
0
)
===
"+"
?
colors
.
green
(
line
)
:
line
.
charAt
(
0
)
===
"-"
?
line
=
colors
.
red
(
line
)
:
line
)
)
;
}
return
ret
.
join
(
'\n'
)
+
'\n'
;
}
;
Back
|
FazBrowse Home
|
New Git URL