This commit is contained in:
Tutur33
2023-11-24 22:35:41 +01:00
parent 3c0b507a93
commit 7644b2a0f7
45165 changed files with 4803356 additions and 3 deletions
+26
View File
@@ -0,0 +1,26 @@
/**
* Sets a hidden (non-enumerable) property on the `target` object, copying it
* from `source`.
*
* This is useful when we want to protect certain data from being accidentally
* leaked through logs, also when the property is non-enumerable on the `source`
* object and we want to ensure that it is properly copied.
*
* @param {object} target
* @param {object} source - default: target
* @param {string} propertyName - default: 'password'
*/
function setHiddenProperty(target, source, propertyName = 'password') {
if (!source) {
source = target;
}
Object.defineProperty(target, propertyName, {
enumerable: false,
value: source[propertyName],
});
}
module.exports = {
setHiddenProperty,
};