FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JavaScript/archive/code/node_modules/chalk/source/util.js at main · iu5git/JavaScript · GitHub
iu5git
/
JavaScript
Public
Notifications
You must be signed in to change notification settings
Fork
21
Star
52
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
JavaScript
/
archive
/
code
/
node_modules
/
chalk
/
source
/
util.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
39 lines (33 loc) · 1.01 KB
Breadcrumbs
JavaScript
/
archive
/
code
/
node_modules
/
chalk
/
source
/
util.js
Copy path
File metadata and controls
executable file
·
39 lines (33 loc) · 1.01 KB
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
31
32
33
34
35
36
37
38
39
'use strict'
;
const
stringReplaceAll
=
(
string
,
substring
,
replacer
)
=>
{
let
index
=
string
.
indexOf
(
substring
)
;
if
(
index
===
-
1
)
{
return
string
;
}
const
substringLength
=
substring
.
length
;
let
endIndex
=
0
;
let
returnValue
=
''
;
do
{
returnValue
+=
string
.
substr
(
endIndex
,
index
-
endIndex
)
+
substring
+
replacer
;
endIndex
=
index
+
substringLength
;
index
=
string
.
indexOf
(
substring
,
endIndex
)
;
}
while
(
index
!==
-
1
)
;
returnValue
+=
string
.
substr
(
endIndex
)
;
return
returnValue
;
}
;
const
stringEncaseCRLFWithFirstIndex
=
(
string
,
prefix
,
postfix
,
index
)
=>
{
let
endIndex
=
0
;
let
returnValue
=
''
;
do
{
const
gotCR
=
string
[
index
-
1
]
===
'\r'
;
returnValue
+=
string
.
substr
(
endIndex
,
(
gotCR
?
index
-
1
:
index
)
-
endIndex
)
+
prefix
+
(
gotCR
?
'\r\n'
:
'\n'
)
+
postfix
;
endIndex
=
index
+
1
;
index
=
string
.
indexOf
(
'\n'
,
endIndex
)
;
}
while
(
index
!==
-
1
)
;
returnValue
+=
string
.
substr
(
endIndex
)
;
return
returnValue
;
}
;
module
.
exports
=
{
stringReplaceAll
,
stringEncaseCRLFWithFirstIndex
}
;
Back
|
FazBrowse Home
|
New Git URL