inibase 1.0.0-rc.115 → 1.0.0-rc.117
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/file.js +21 -1
- package/dist/utils.server.js +2 -1
- package/package.json +1 -1
package/dist/file.js
CHANGED
|
@@ -284,8 +284,9 @@ export const replace = async (filePath, replacements, totalItems) => {
|
|
|
284
284
|
let linesCount = 0;
|
|
285
285
|
fileHandle = await open(filePath, "r");
|
|
286
286
|
fileTempHandle = await open(fileTempPath, "w");
|
|
287
|
+
const writeStream = fileTempHandle.createWriteStream();
|
|
287
288
|
const rl = createReadLineInternface(filePath, fileHandle);
|
|
288
|
-
await _pipeline(filePath, rl,
|
|
289
|
+
await _pipeline(filePath, rl, writeStream, new Transform({
|
|
289
290
|
transform(line, _, callback) {
|
|
290
291
|
linesCount++;
|
|
291
292
|
const replacement = isReplacementsObject
|
|
@@ -295,6 +296,25 @@ export const replace = async (filePath, replacements, totalItems) => {
|
|
|
295
296
|
: replacements;
|
|
296
297
|
return callback(null, `${replacement}\n`);
|
|
297
298
|
},
|
|
299
|
+
flush(callback) {
|
|
300
|
+
const remainingReplacementsKeys = Object.keys(replacements)
|
|
301
|
+
.map(Number)
|
|
302
|
+
.toSorted((a, b) => a - b)
|
|
303
|
+
.filter((lineNumber) => lineNumber > linesCount);
|
|
304
|
+
if (remainingReplacementsKeys.length)
|
|
305
|
+
this.push("\n".repeat(remainingReplacementsKeys[0] - linesCount - 1) +
|
|
306
|
+
remainingReplacementsKeys
|
|
307
|
+
.map((lineNumber, index) => index === 0 ||
|
|
308
|
+
lineNumber -
|
|
309
|
+
(remainingReplacementsKeys[index - 1] - 1) ===
|
|
310
|
+
0
|
|
311
|
+
? replacements[lineNumber]
|
|
312
|
+
: "\n".repeat(lineNumber -
|
|
313
|
+
remainingReplacementsKeys[index - 1] -
|
|
314
|
+
1) + replacements[lineNumber])
|
|
315
|
+
.join("\n"));
|
|
316
|
+
callback();
|
|
317
|
+
},
|
|
298
318
|
}));
|
|
299
319
|
return [fileTempPath, filePath];
|
|
300
320
|
}
|
package/dist/utils.server.js
CHANGED
|
@@ -210,7 +210,8 @@ export const isEqual = (originalValue, comparedValue, fieldType) => {
|
|
|
210
210
|
case "boolean":
|
|
211
211
|
return Number(originalValue) === Number(comparedValue);
|
|
212
212
|
default:
|
|
213
|
-
return originalValue
|
|
213
|
+
return ((!String(comparedValue).length && originalValue === undefined) ||
|
|
214
|
+
originalValue == comparedValue);
|
|
214
215
|
}
|
|
215
216
|
};
|
|
216
217
|
/**
|