ts-swc-transform 2.11.0 → 2.11.1
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/cjs/compat.js +2 -6
- package/dist/cjs/compat.js.map +1 -1
- package/dist/esm/compat.js +2 -6
- package/dist/esm/compat.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/compat.js
CHANGED
|
@@ -31,9 +31,7 @@ _export(exports, {
|
|
|
31
31
|
* - Falls back to indexOf on Node 0.8-3.x
|
|
32
32
|
*/ var hasStartsWith = typeof String.prototype.startsWith === 'function';
|
|
33
33
|
function stringStartsWith(str, search, position) {
|
|
34
|
-
if (hasStartsWith)
|
|
35
|
-
return str.startsWith(search, position);
|
|
36
|
-
}
|
|
34
|
+
if (hasStartsWith) return str.startsWith(search, position);
|
|
37
35
|
position = position || 0;
|
|
38
36
|
return str.indexOf(search, position) === position;
|
|
39
37
|
}
|
|
@@ -43,9 +41,7 @@ function stringStartsWith(str, search, position) {
|
|
|
43
41
|
* - Falls back to lastIndexOf on Node 0.8-3.x
|
|
44
42
|
*/ var hasEndsWith = typeof String.prototype.endsWith === 'function';
|
|
45
43
|
function stringEndsWith(str, search, position) {
|
|
46
|
-
if (hasEndsWith)
|
|
47
|
-
return str.endsWith(search, position);
|
|
48
|
-
}
|
|
44
|
+
if (hasEndsWith) return str.endsWith(search, position);
|
|
49
45
|
var len = position === undefined ? str.length : position;
|
|
50
46
|
return str.lastIndexOf(search) === len - search.length;
|
|
51
47
|
}
|
package/dist/cjs/compat.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/compat.ts"],"sourcesContent":["/**\n * Compatibility Layer for Node.js 0.8+\n * Local to this package - contains only needed functions.\n */\n\n/**\n * String.prototype.startsWith wrapper for Node.js 0.8+\n * - Uses native startsWith on Node 4.0+ / ES2015+\n * - Falls back to indexOf on Node 0.8-3.x\n */\nconst hasStartsWith = typeof String.prototype.startsWith === 'function';\
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/compat.ts"],"sourcesContent":["/**\n * Compatibility Layer for Node.js 0.8+\n * Local to this package - contains only needed functions.\n */\n\n/**\n * String.prototype.startsWith wrapper for Node.js 0.8+\n * - Uses native startsWith on Node 4.0+ / ES2015+\n * - Falls back to indexOf on Node 0.8-3.x\n */\nconst hasStartsWith = typeof String.prototype.startsWith === 'function';\nexport function stringStartsWith(str: string, search: string, position?: number): boolean {\n if (hasStartsWith) return str.startsWith(search, position);\n position = position || 0;\n return str.indexOf(search, position) === position;\n}\n\n/**\n * String.prototype.endsWith wrapper for Node.js 0.8+\n * - Uses native endsWith on Node 4.0+ / ES2015+\n * - Falls back to lastIndexOf on Node 0.8-3.x\n */\nconst hasEndsWith = typeof String.prototype.endsWith === 'function';\nexport function stringEndsWith(str: string, search: string, position?: number): boolean {\n if (hasEndsWith) return str.endsWith(search, position);\n const len = position === undefined ? str.length : position;\n return str.lastIndexOf(search) === len - search.length;\n}\n\n/**\n * String.prototype.replaceAll wrapper for Node.js 0.8+\n * - Uses native replaceAll on Node 15.0+ / ES2021+\n * - Falls back to regex replace on older versions\n */\n// biome-ignore lint/suspicious/noExplicitAny: Feature detection for ES2021 replaceAll\nconst hasReplaceAll = typeof (String.prototype as any).replaceAll === 'function';\n\nexport function stringReplaceAll(str: string, search: string, replace: string): string {\n if (hasReplaceAll) {\n // biome-ignore lint/suspicious/noExplicitAny: Using native replaceAll when available\n return (str as any).replaceAll(search, replace);\n }\n // Escape special regex characters\n const escaped = search.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n return str.replace(new RegExp(escaped, 'g'), replace);\n}\n\n/**\n * Array.prototype.find wrapper for Node.js 0.8+\n * - Uses native find on Node 4.0+ / ES2015+\n * - Falls back to loop on Node 0.8-3.x\n */\nconst hasArrayFind = typeof Array.prototype.find === 'function';\n\nexport function arrayFind<T>(arr: T[], predicate: (item: T, index: number, arr: T[]) => boolean): T | undefined {\n if (hasArrayFind) {\n return arr.find(predicate);\n }\n for (let i = 0; i < arr.length; i++) {\n if (predicate(arr[i], i, arr)) return arr[i];\n }\n return undefined;\n}\n"],"names":["arrayFind","stringEndsWith","stringReplaceAll","stringStartsWith","hasStartsWith","String","prototype","startsWith","str","search","position","indexOf","hasEndsWith","endsWith","len","undefined","length","lastIndexOf","hasReplaceAll","replaceAll","replace","escaped","RegExp","hasArrayFind","Array","find","arr","predicate","i"],"mappings":";;;;;;;;;;;QAsDgBA;eAAAA;;QA/BAC;eAAAA;;QAcAC;eAAAA;;QA1BAC;eAAAA;;;AAXhB;;;CAGC,GAED;;;;CAIC,GACD,IAAMC,gBAAgB,OAAOC,OAAOC,SAAS,CAACC,UAAU,KAAK;AACtD,SAASJ,iBAAiBK,GAAW,EAAEC,MAAc,EAAEC,QAAiB;IAC7E,IAAIN,eAAe,OAAOI,IAAID,UAAU,CAACE,QAAQC;IACjDA,WAAWA,YAAY;IACvB,OAAOF,IAAIG,OAAO,CAACF,QAAQC,cAAcA;AAC3C;AAEA;;;;CAIC,GACD,IAAME,cAAc,OAAOP,OAAOC,SAAS,CAACO,QAAQ,KAAK;AAClD,SAASZ,eAAeO,GAAW,EAAEC,MAAc,EAAEC,QAAiB;IAC3E,IAAIE,aAAa,OAAOJ,IAAIK,QAAQ,CAACJ,QAAQC;IAC7C,IAAMI,MAAMJ,aAAaK,YAAYP,IAAIQ,MAAM,GAAGN;IAClD,OAAOF,IAAIS,WAAW,CAACR,YAAYK,MAAML,OAAOO,MAAM;AACxD;AAEA;;;;CAIC,GACD,sFAAsF;AACtF,IAAME,gBAAgB,OAAO,AAACb,OAAOC,SAAS,CAASa,UAAU,KAAK;AAE/D,SAASjB,iBAAiBM,GAAW,EAAEC,MAAc,EAAEW,OAAe;IAC3E,IAAIF,eAAe;QACjB,qFAAqF;QACrF,OAAO,AAACV,IAAYW,UAAU,CAACV,QAAQW;IACzC;IACA,kCAAkC;IAClC,IAAMC,UAAUZ,OAAOW,OAAO,CAAC,uBAAuB;IACtD,OAAOZ,IAAIY,OAAO,CAAC,IAAIE,OAAOD,SAAS,MAAMD;AAC/C;AAEA;;;;CAIC,GACD,IAAMG,eAAe,OAAOC,MAAMlB,SAAS,CAACmB,IAAI,KAAK;AAE9C,SAASzB,UAAa0B,GAAQ,EAAEC,SAAwD;IAC7F,IAAIJ,cAAc;QAChB,OAAOG,IAAID,IAAI,CAACE;IAClB;IACA,IAAK,IAAIC,IAAI,GAAGA,IAAIF,IAAIV,MAAM,EAAEY,IAAK;QACnC,IAAID,UAAUD,GAAG,CAACE,EAAE,EAAEA,GAAGF,MAAM,OAAOA,GAAG,CAACE,EAAE;IAC9C;IACA,OAAOb;AACT"}
|
package/dist/esm/compat.js
CHANGED
|
@@ -7,9 +7,7 @@
|
|
|
7
7
|
* - Falls back to indexOf on Node 0.8-3.x
|
|
8
8
|
*/ const hasStartsWith = typeof String.prototype.startsWith === 'function';
|
|
9
9
|
export function stringStartsWith(str, search, position) {
|
|
10
|
-
if (hasStartsWith)
|
|
11
|
-
return str.startsWith(search, position);
|
|
12
|
-
}
|
|
10
|
+
if (hasStartsWith) return str.startsWith(search, position);
|
|
13
11
|
position = position || 0;
|
|
14
12
|
return str.indexOf(search, position) === position;
|
|
15
13
|
}
|
|
@@ -19,9 +17,7 @@ export function stringStartsWith(str, search, position) {
|
|
|
19
17
|
* - Falls back to lastIndexOf on Node 0.8-3.x
|
|
20
18
|
*/ const hasEndsWith = typeof String.prototype.endsWith === 'function';
|
|
21
19
|
export function stringEndsWith(str, search, position) {
|
|
22
|
-
if (hasEndsWith)
|
|
23
|
-
return str.endsWith(search, position);
|
|
24
|
-
}
|
|
20
|
+
if (hasEndsWith) return str.endsWith(search, position);
|
|
25
21
|
const len = position === undefined ? str.length : position;
|
|
26
22
|
return str.lastIndexOf(search) === len - search.length;
|
|
27
23
|
}
|
package/dist/esm/compat.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/compat.ts"],"sourcesContent":["/**\n * Compatibility Layer for Node.js 0.8+\n * Local to this package - contains only needed functions.\n */\n\n/**\n * String.prototype.startsWith wrapper for Node.js 0.8+\n * - Uses native startsWith on Node 4.0+ / ES2015+\n * - Falls back to indexOf on Node 0.8-3.x\n */\nconst hasStartsWith = typeof String.prototype.startsWith === 'function';\
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/typescript/ts-swc-transform/src/compat.ts"],"sourcesContent":["/**\n * Compatibility Layer for Node.js 0.8+\n * Local to this package - contains only needed functions.\n */\n\n/**\n * String.prototype.startsWith wrapper for Node.js 0.8+\n * - Uses native startsWith on Node 4.0+ / ES2015+\n * - Falls back to indexOf on Node 0.8-3.x\n */\nconst hasStartsWith = typeof String.prototype.startsWith === 'function';\nexport function stringStartsWith(str: string, search: string, position?: number): boolean {\n if (hasStartsWith) return str.startsWith(search, position);\n position = position || 0;\n return str.indexOf(search, position) === position;\n}\n\n/**\n * String.prototype.endsWith wrapper for Node.js 0.8+\n * - Uses native endsWith on Node 4.0+ / ES2015+\n * - Falls back to lastIndexOf on Node 0.8-3.x\n */\nconst hasEndsWith = typeof String.prototype.endsWith === 'function';\nexport function stringEndsWith(str: string, search: string, position?: number): boolean {\n if (hasEndsWith) return str.endsWith(search, position);\n const len = position === undefined ? str.length : position;\n return str.lastIndexOf(search) === len - search.length;\n}\n\n/**\n * String.prototype.replaceAll wrapper for Node.js 0.8+\n * - Uses native replaceAll on Node 15.0+ / ES2021+\n * - Falls back to regex replace on older versions\n */\n// biome-ignore lint/suspicious/noExplicitAny: Feature detection for ES2021 replaceAll\nconst hasReplaceAll = typeof (String.prototype as any).replaceAll === 'function';\n\nexport function stringReplaceAll(str: string, search: string, replace: string): string {\n if (hasReplaceAll) {\n // biome-ignore lint/suspicious/noExplicitAny: Using native replaceAll when available\n return (str as any).replaceAll(search, replace);\n }\n // Escape special regex characters\n const escaped = search.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n return str.replace(new RegExp(escaped, 'g'), replace);\n}\n\n/**\n * Array.prototype.find wrapper for Node.js 0.8+\n * - Uses native find on Node 4.0+ / ES2015+\n * - Falls back to loop on Node 0.8-3.x\n */\nconst hasArrayFind = typeof Array.prototype.find === 'function';\n\nexport function arrayFind<T>(arr: T[], predicate: (item: T, index: number, arr: T[]) => boolean): T | undefined {\n if (hasArrayFind) {\n return arr.find(predicate);\n }\n for (let i = 0; i < arr.length; i++) {\n if (predicate(arr[i], i, arr)) return arr[i];\n }\n return undefined;\n}\n"],"names":["hasStartsWith","String","prototype","startsWith","stringStartsWith","str","search","position","indexOf","hasEndsWith","endsWith","stringEndsWith","len","undefined","length","lastIndexOf","hasReplaceAll","replaceAll","stringReplaceAll","replace","escaped","RegExp","hasArrayFind","Array","find","arrayFind","arr","predicate","i"],"mappings":"AAAA;;;CAGC,GAED;;;;CAIC,GACD,MAAMA,gBAAgB,OAAOC,OAAOC,SAAS,CAACC,UAAU,KAAK;AAC7D,OAAO,SAASC,iBAAiBC,GAAW,EAAEC,MAAc,EAAEC,QAAiB;IAC7E,IAAIP,eAAe,OAAOK,IAAIF,UAAU,CAACG,QAAQC;IACjDA,WAAWA,YAAY;IACvB,OAAOF,IAAIG,OAAO,CAACF,QAAQC,cAAcA;AAC3C;AAEA;;;;CAIC,GACD,MAAME,cAAc,OAAOR,OAAOC,SAAS,CAACQ,QAAQ,KAAK;AACzD,OAAO,SAASC,eAAeN,GAAW,EAAEC,MAAc,EAAEC,QAAiB;IAC3E,IAAIE,aAAa,OAAOJ,IAAIK,QAAQ,CAACJ,QAAQC;IAC7C,MAAMK,MAAML,aAAaM,YAAYR,IAAIS,MAAM,GAAGP;IAClD,OAAOF,IAAIU,WAAW,CAACT,YAAYM,MAAMN,OAAOQ,MAAM;AACxD;AAEA;;;;CAIC,GACD,sFAAsF;AACtF,MAAME,gBAAgB,OAAO,AAACf,OAAOC,SAAS,CAASe,UAAU,KAAK;AAEtE,OAAO,SAASC,iBAAiBb,GAAW,EAAEC,MAAc,EAAEa,OAAe;IAC3E,IAAIH,eAAe;QACjB,qFAAqF;QACrF,OAAO,AAACX,IAAYY,UAAU,CAACX,QAAQa;IACzC;IACA,kCAAkC;IAClC,MAAMC,UAAUd,OAAOa,OAAO,CAAC,uBAAuB;IACtD,OAAOd,IAAIc,OAAO,CAAC,IAAIE,OAAOD,SAAS,MAAMD;AAC/C;AAEA;;;;CAIC,GACD,MAAMG,eAAe,OAAOC,MAAMrB,SAAS,CAACsB,IAAI,KAAK;AAErD,OAAO,SAASC,UAAaC,GAAQ,EAAEC,SAAwD;IAC7F,IAAIL,cAAc;QAChB,OAAOI,IAAIF,IAAI,CAACG;IAClB;IACA,IAAK,IAAIC,IAAI,GAAGA,IAAIF,IAAIZ,MAAM,EAAEc,IAAK;QACnC,IAAID,UAAUD,GAAG,CAACE,EAAE,EAAEA,GAAGF,MAAM,OAAOA,GAAG,CAACE,EAAE;IAC9C;IACA,OAAOf;AACT"}
|