ravendb
Version:
RavenDB client for Node.js
27 lines • 1.02 kB
JavaScript
import { Transform } from "node:stream";
import { ObjectUtil } from "../../../Utility/ObjectUtil.js";
import { TypeUtil } from "../../../Utility/TypeUtil.js";
const DEFAULT_OBJECT_KEY_CASE_TRANSFORM_OPTS = {
arrayRecursive: true,
recursive: true
};
export class ObjectKeyCaseTransformStream extends Transform {
_opts;
constructor(_opts) {
super({ objectMode: true });
this._opts = _opts;
this._opts = Object.assign({}, DEFAULT_OBJECT_KEY_CASE_TRANSFORM_OPTS, this._opts);
}
_transform(chunk, enc, callback) {
let entry = chunk;
const key = chunk["key"];
if (TypeUtil.isPrimitive(entry) || TypeUtil.isNullOrUndefined(entry)) {
return callback(null, chunk);
}
const opts = Object.assign({}, this._opts);
opts.ignorePaths = [...new Set(opts.ignorePaths || [])];
entry = ObjectUtil.transformObjectKeys(entry, opts);
callback(null, entry);
}
}
//# sourceMappingURL=ObjectKeyCaseTransformStream.js.map