@statoscope/report-writer
Advanced tools
Comparing version 5.8.0 to 5.9.0
@@ -25,3 +25,3 @@ "use strict"; | ||
for (const writer of this.chunkWriters) { | ||
await chunkToScriptWriter_1.default(writer.stream, this.stream, writer.id); | ||
await (0, chunkToScriptWriter_1.default)(writer.stream, this.stream, writer.id); | ||
} | ||
@@ -28,0 +28,0 @@ writeFooter(this.stream, this.options); |
/// <reference types="node" /> | ||
import { Readable, Writable } from 'stream'; | ||
import { TReplacer } from '@discoveryjs/json-ext'; | ||
import { Options } from './'; | ||
@@ -9,5 +10,7 @@ export declare function waitFinished(stream: Readable | Writable): Promise<void>; | ||
data: unknown; | ||
replacer?: TReplacer; | ||
} | { | ||
type: 'filename'; | ||
filename: string; | ||
replacer?: TReplacer; | ||
}; | ||
@@ -17,1 +20,2 @@ export declare function transform(options: { | ||
}, from: Array<string | FromItem>, to: string): Promise<string>; | ||
export declare function makeReplacer(from?: string, to?: string, ignoreKeys?: string[]): TReplacer | undefined; |
@@ -6,3 +6,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.transform = exports.waitFinished = void 0; | ||
exports.makeReplacer = exports.transform = exports.waitFinished = void 0; | ||
const fs_1 = __importDefault(require("fs")); | ||
@@ -35,3 +35,3 @@ const path_1 = __importDefault(require("path")); | ||
else { | ||
stream = json_ext_1.stringifyStream(fromItem.data); | ||
stream = (0, json_ext_1.stringifyStream)(fromItem.data, fromItem.replacer); | ||
} | ||
@@ -46,2 +46,15 @@ htmlWriter.addChunkWriter(stream, id); | ||
exports.transform = transform; | ||
function makeReplacer(from, to = '', ignoreKeys = []) { | ||
if (!from) { | ||
return; | ||
} | ||
return (key, value) => { | ||
if (typeof value === 'string' && !ignoreKeys.includes(key)) { | ||
if (value.includes(from)) | ||
return value.split(from).join(to); | ||
} | ||
return value; | ||
}; | ||
} | ||
exports.makeReplacer = makeReplacer; | ||
//# sourceMappingURL=utils.js.map |
{ | ||
"name": "@statoscope/report-writer", | ||
"version": "5.8.0", | ||
"version": "5.9.0", | ||
"description": "Statoscope report writer", | ||
@@ -26,3 +26,3 @@ "main": "./dist/index.js", | ||
}, | ||
"gitHead": "d7b10e373e8352a955271fd8923778b68f23dfca" | ||
"gitHead": "f8e8a9cd721828a4bc53a2f808441d81e5fdbf84" | ||
} |
10245
244