mirror of
https://github.com/democratic-csi/democratic-csi.git
synced 2026-10-21 06:30:46 +02:00
avoid cyclic issues
Signed-off-by: Travis Glenn Hansen <travisghansen@yahoo.com>
This commit is contained in:
@@ -51,6 +51,24 @@ function getLargestNumber() {
|
||||
return number;
|
||||
}
|
||||
|
||||
function stringify(value) {
|
||||
const getCircularReplacer = () => {
|
||||
const seen = new WeakSet();
|
||||
return (key, value) => {
|
||||
if (typeof value === "object" && value !== null) {
|
||||
if (seen.has(value)) {
|
||||
return;
|
||||
}
|
||||
seen.add(value);
|
||||
}
|
||||
return value;
|
||||
};
|
||||
};
|
||||
|
||||
return JSON.stringify(value, getCircularReplacer());
|
||||
}
|
||||
|
||||
module.exports.sleep = sleep;
|
||||
module.exports.lockKeysFromRequest = lockKeysFromRequest;
|
||||
module.exports.getLargestNumber = getLargestNumber;
|
||||
module.exports.stringify = stringify;
|
||||
Reference in New Issue
Block a user