chlklib 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/utilities.cjs +52 -0
- package/dist/utilities.cjs.map +7 -0
- package/dist/utilities.js +33 -0
- package/dist/utilities.js.map +7 -0
- package/package.json +1 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var utilities_exports = {};
|
|
19
|
+
__export(utilities_exports, {
|
|
20
|
+
stringEncaseCRLFWithFirstIndex: () => stringEncaseCRLFWithFirstIndex,
|
|
21
|
+
stringReplaceAll: () => stringReplaceAll
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(utilities_exports);
|
|
24
|
+
function stringReplaceAll(string, substring, replacer) {
|
|
25
|
+
let index = string.indexOf(substring);
|
|
26
|
+
if (index === -1) {
|
|
27
|
+
return string;
|
|
28
|
+
}
|
|
29
|
+
const substringLength = substring.length;
|
|
30
|
+
let endIndex = 0;
|
|
31
|
+
let returnValue = "";
|
|
32
|
+
do {
|
|
33
|
+
returnValue += string.slice(endIndex, index) + substring + replacer;
|
|
34
|
+
endIndex = index + substringLength;
|
|
35
|
+
index = string.indexOf(substring, endIndex);
|
|
36
|
+
} while (index !== -1);
|
|
37
|
+
returnValue += string.slice(endIndex);
|
|
38
|
+
return returnValue;
|
|
39
|
+
}
|
|
40
|
+
function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
|
|
41
|
+
let endIndex = 0;
|
|
42
|
+
let returnValue = "";
|
|
43
|
+
do {
|
|
44
|
+
const gotCR = string[index - 1] === "\r";
|
|
45
|
+
returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
|
|
46
|
+
endIndex = index + 1;
|
|
47
|
+
index = string.indexOf("\n", endIndex);
|
|
48
|
+
} while (index !== -1);
|
|
49
|
+
returnValue += string.slice(endIndex);
|
|
50
|
+
return returnValue;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=utilities.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../source/utilities.js"],
|
|
4
|
+
"sourcesContent": ["// TODO: When targeting Node.js 16, use `String.prototype.replaceAll`.\nexport function stringReplaceAll(string, substring, replacer) {\n\tlet index = string.indexOf(substring);\n\tif (index === -1) {\n\t\treturn string;\n\t}\n\n\tconst substringLength = substring.length;\n\tlet endIndex = 0;\n\tlet returnValue = '';\n\tdo {\n\t\treturnValue += string.slice(endIndex, index) + substring + replacer;\n\t\tendIndex = index + substringLength;\n\t\tindex = string.indexOf(substring, endIndex);\n\t} while (index !== -1);\n\n\treturnValue += string.slice(endIndex);\n\treturn returnValue;\n}\n\nexport function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {\n\tlet endIndex = 0;\n\tlet returnValue = '';\n\tdo {\n\t\tconst gotCR = string[index - 1] === '\\r';\n\t\treturnValue += string.slice(endIndex, (gotCR ? index - 1 : index)) + prefix + (gotCR ? '\\r\\n' : '\\n') + postfix;\n\t\tendIndex = index + 1;\n\t\tindex = string.indexOf('\\n', endIndex);\n\t} while (index !== -1);\n\n\treturnValue += string.slice(endIndex);\n\treturn returnValue;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACO,SAAS,iBAAiB,QAAQ,WAAW,UAAU;AAC7D,MAAI,QAAQ,OAAO,QAAQ,SAAS;AACpC,MAAI,UAAU,IAAI;AACjB,WAAO;AAAA,EACR;AAEA,QAAM,kBAAkB,UAAU;AAClC,MAAI,WAAW;AACf,MAAI,cAAc;AAClB,KAAG;AACF,mBAAe,OAAO,MAAM,UAAU,KAAK,IAAI,YAAY;AAC3D,eAAW,QAAQ;AACnB,YAAQ,OAAO,QAAQ,WAAW,QAAQ;AAAA,EAC3C,SAAS,UAAU;AAEnB,iBAAe,OAAO,MAAM,QAAQ;AACpC,SAAO;AACR;AAEO,SAAS,+BAA+B,QAAQ,QAAQ,SAAS,OAAO;AAC9E,MAAI,WAAW;AACf,MAAI,cAAc;AAClB,KAAG;AACF,UAAM,QAAQ,OAAO,QAAQ,CAAC,MAAM;AACpC,mBAAe,OAAO,MAAM,UAAW,QAAQ,QAAQ,IAAI,KAAM,IAAI,UAAU,QAAQ,SAAS,QAAQ;AACxG,eAAW,QAAQ;AACnB,YAAQ,OAAO,QAAQ,MAAM,QAAQ;AAAA,EACtC,SAAS,UAAU;AAEnB,iBAAe,OAAO,MAAM,QAAQ;AACpC,SAAO;AACR;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
function stringReplaceAll(string, substring, replacer) {
|
|
2
|
+
let index = string.indexOf(substring);
|
|
3
|
+
if (index === -1) {
|
|
4
|
+
return string;
|
|
5
|
+
}
|
|
6
|
+
const substringLength = substring.length;
|
|
7
|
+
let endIndex = 0;
|
|
8
|
+
let returnValue = "";
|
|
9
|
+
do {
|
|
10
|
+
returnValue += string.slice(endIndex, index) + substring + replacer;
|
|
11
|
+
endIndex = index + substringLength;
|
|
12
|
+
index = string.indexOf(substring, endIndex);
|
|
13
|
+
} while (index !== -1);
|
|
14
|
+
returnValue += string.slice(endIndex);
|
|
15
|
+
return returnValue;
|
|
16
|
+
}
|
|
17
|
+
function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
|
|
18
|
+
let endIndex = 0;
|
|
19
|
+
let returnValue = "";
|
|
20
|
+
do {
|
|
21
|
+
const gotCR = string[index - 1] === "\r";
|
|
22
|
+
returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
|
|
23
|
+
endIndex = index + 1;
|
|
24
|
+
index = string.indexOf("\n", endIndex);
|
|
25
|
+
} while (index !== -1);
|
|
26
|
+
returnValue += string.slice(endIndex);
|
|
27
|
+
return returnValue;
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
stringEncaseCRLFWithFirstIndex,
|
|
31
|
+
stringReplaceAll
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=utilities.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../source/utilities.js"],
|
|
4
|
+
"sourcesContent": ["// TODO: When targeting Node.js 16, use `String.prototype.replaceAll`.\nexport function stringReplaceAll(string, substring, replacer) {\n\tlet index = string.indexOf(substring);\n\tif (index === -1) {\n\t\treturn string;\n\t}\n\n\tconst substringLength = substring.length;\n\tlet endIndex = 0;\n\tlet returnValue = '';\n\tdo {\n\t\treturnValue += string.slice(endIndex, index) + substring + replacer;\n\t\tendIndex = index + substringLength;\n\t\tindex = string.indexOf(substring, endIndex);\n\t} while (index !== -1);\n\n\treturnValue += string.slice(endIndex);\n\treturn returnValue;\n}\n\nexport function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {\n\tlet endIndex = 0;\n\tlet returnValue = '';\n\tdo {\n\t\tconst gotCR = string[index - 1] === '\\r';\n\t\treturnValue += string.slice(endIndex, (gotCR ? index - 1 : index)) + prefix + (gotCR ? '\\r\\n' : '\\n') + postfix;\n\t\tendIndex = index + 1;\n\t\tindex = string.indexOf('\\n', endIndex);\n\t} while (index !== -1);\n\n\treturnValue += string.slice(endIndex);\n\treturn returnValue;\n}\n"],
|
|
5
|
+
"mappings": "AACO,SAAS,iBAAiB,QAAQ,WAAW,UAAU;AAC7D,MAAI,QAAQ,OAAO,QAAQ,SAAS;AACpC,MAAI,UAAU,IAAI;AACjB,WAAO;AAAA,EACR;AAEA,QAAM,kBAAkB,UAAU;AAClC,MAAI,WAAW;AACf,MAAI,cAAc;AAClB,KAAG;AACF,mBAAe,OAAO,MAAM,UAAU,KAAK,IAAI,YAAY;AAC3D,eAAW,QAAQ;AACnB,YAAQ,OAAO,QAAQ,WAAW,QAAQ;AAAA,EAC3C,SAAS,UAAU;AAEnB,iBAAe,OAAO,MAAM,QAAQ;AACpC,SAAO;AACR;AAEO,SAAS,+BAA+B,QAAQ,QAAQ,SAAS,OAAO;AAC9E,MAAI,WAAW;AACf,MAAI,cAAc;AAClB,KAAG;AACF,UAAM,QAAQ,OAAO,QAAQ,CAAC,MAAM;AACpC,mBAAe,OAAO,MAAM,UAAW,QAAQ,QAAQ,IAAI,KAAM,IAAI,UAAU,QAAQ,SAAS,QAAQ;AACxG,eAAW,QAAQ;AACnB,YAAQ,OAAO,QAAQ,MAAM,QAAQ;AAAA,EACtC,SAAS,UAAU;AAEnB,iBAAe,OAAO,MAAM,QAAQ;AACpC,SAAO;AACR;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|