mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 18:25:24 +00:00
Moved freezeRecursive function to utils
This commit is contained in:
@@ -199,7 +199,7 @@ export default class PKPass extends Bundle {
|
||||
*/
|
||||
|
||||
public get props(): Readonly<Schemas.PassProps> {
|
||||
return freezeRecusive(this[propsSymbol]);
|
||||
return Utils.freezeRecursive(this[propsSymbol]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -913,31 +913,6 @@ export default class PKPass extends Bundle {
|
||||
}
|
||||
}
|
||||
|
||||
function freezeRecusive(object: Object) {
|
||||
const objectCopy = {};
|
||||
const objectEntries = Object.entries(object);
|
||||
|
||||
for (let i = 0; i < objectEntries.length; i++) {
|
||||
const [key, value] = objectEntries[i];
|
||||
|
||||
if (value && typeof value === "object") {
|
||||
if (Array.isArray(value)) {
|
||||
objectCopy[key] = value.slice();
|
||||
|
||||
for (let j = 0; j < value.length; j++) {
|
||||
objectCopy[key][j] = freezeRecusive(value[j]);
|
||||
}
|
||||
} else {
|
||||
objectCopy[key] = freezeRecusive(value);
|
||||
}
|
||||
} else {
|
||||
objectCopy[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
return Object.freeze(objectCopy);
|
||||
}
|
||||
|
||||
function validateJSONBuffer(
|
||||
buffer: Buffer,
|
||||
schema: Parameters<typeof Schemas.validate>[0],
|
||||
|
||||
Reference in New Issue
Block a user