@esportsplus/typescript 0.16.0 → 0.17.0
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.
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { QuickCheckPattern, Replacement } from './types.js';
|
|
2
2
|
import program from './program.js';
|
|
3
3
|
declare const addImport: (code: string, module: string, specifiers: string[]) => string;
|
|
4
|
-
declare const applyReplacements: (code: string, replacements: Replacement[]) => string;
|
|
5
4
|
declare const applyReplacementsReverse: (code: string, replacements: Replacement[]) => string;
|
|
6
5
|
declare const mightNeedTransform: (code: string, check: QuickCheckPattern) => boolean;
|
|
7
6
|
declare const uid: (prefix: string, updateUUID?: boolean) => string;
|
|
8
|
-
export { addImport,
|
|
7
|
+
export { addImport, applyReplacementsReverse, mightNeedTransform, program, uid };
|
|
9
8
|
export type * from './types.js';
|
|
10
9
|
export * from './constants.js';
|
|
@@ -61,25 +61,6 @@ const addImport = (code, module, specifiers) => {
|
|
|
61
61
|
}
|
|
62
62
|
return code.substring(0, first) + adding + code.substring(first);
|
|
63
63
|
};
|
|
64
|
-
const applyReplacements = (code, replacements) => {
|
|
65
|
-
if (replacements.length === 0) {
|
|
66
|
-
return code;
|
|
67
|
-
}
|
|
68
|
-
replacements.sort((a, b) => a.start - b.start);
|
|
69
|
-
let parts = [], pos = 0;
|
|
70
|
-
for (let i = 0, n = replacements.length; i < n; i++) {
|
|
71
|
-
let r = replacements[i];
|
|
72
|
-
if (r.start > pos) {
|
|
73
|
-
parts.push(code.substring(pos, r.start));
|
|
74
|
-
}
|
|
75
|
-
parts.push(r.newText);
|
|
76
|
-
pos = r.end;
|
|
77
|
-
}
|
|
78
|
-
if (pos < code.length) {
|
|
79
|
-
parts.push(code.substring(pos));
|
|
80
|
-
}
|
|
81
|
-
return parts.join('');
|
|
82
|
-
};
|
|
83
64
|
const applyReplacementsReverse = (code, replacements) => {
|
|
84
65
|
if (replacements.length === 0) {
|
|
85
66
|
return code;
|
|
@@ -108,5 +89,5 @@ const mightNeedTransform = (code, check) => {
|
|
|
108
89
|
const uid = (prefix, updateUUID = false) => {
|
|
109
90
|
return prefix + '_' + (updateUUID ? uuid().replace(UUID_DASH_REGEX, '') : uidSuffix) + '_' + (i++).toString(36);
|
|
110
91
|
};
|
|
111
|
-
export { addImport,
|
|
92
|
+
export { addImport, applyReplacementsReverse, mightNeedTransform, program, uid };
|
|
112
93
|
export * from './constants.js';
|
package/package.json
CHANGED
package/src/transformer/index.ts
CHANGED
|
@@ -99,34 +99,6 @@ const addImport = (code: string, module: string, specifiers: string[]): string =
|
|
|
99
99
|
return code.substring(0, first) + adding + code.substring(first);
|
|
100
100
|
};
|
|
101
101
|
|
|
102
|
-
const applyReplacements = (code: string, replacements: Replacement[]): string => {
|
|
103
|
-
if (replacements.length === 0) {
|
|
104
|
-
return code;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
replacements.sort((a, b) => a.start - b.start);
|
|
108
|
-
|
|
109
|
-
let parts: string[] = [],
|
|
110
|
-
pos = 0;
|
|
111
|
-
|
|
112
|
-
for (let i = 0, n = replacements.length; i < n; i++) {
|
|
113
|
-
let r = replacements[i];
|
|
114
|
-
|
|
115
|
-
if (r.start > pos) {
|
|
116
|
-
parts.push(code.substring(pos, r.start));
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
parts.push(r.newText);
|
|
120
|
-
pos = r.end;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
if (pos < code.length) {
|
|
124
|
-
parts.push(code.substring(pos));
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return parts.join('');
|
|
128
|
-
};
|
|
129
|
-
|
|
130
102
|
const applyReplacementsReverse = (code: string, replacements: Replacement[]): string => {
|
|
131
103
|
if (replacements.length === 0) {
|
|
132
104
|
return code;
|
|
@@ -167,7 +139,7 @@ const uid = (prefix: string, updateUUID = false): string => {
|
|
|
167
139
|
|
|
168
140
|
|
|
169
141
|
export {
|
|
170
|
-
addImport,
|
|
142
|
+
addImport, applyReplacementsReverse,
|
|
171
143
|
mightNeedTransform,
|
|
172
144
|
program,
|
|
173
145
|
uid
|