GT2/GT2-iOS/node_modules/lru-memoizer/lib/freeze.js

21 lines
586 B
JavaScript
Raw Normal View History

2018-02-12 17:26:06 +00:00
// From https://raw.githubusercontent.com/nikoskalogridis/deep-freeze/fb921b32064dce1645197be2bf975fe0385450b0/index.js
// which is sadly, no longer maintained
module.exports = function deepFreeze (o) {
if (o) {
Object.freeze(o);
Object.getOwnPropertyNames(o).forEach(function (prop) {
if (o.hasOwnProperty(prop)
&& o[prop] !== null
&& (typeof o[prop] === 'object' || typeof o[prop] === 'function')
&& (o[prop].constructor !== Buffer)
&& !Object.isFrozen(o[prop])) {
deepFreeze(o[prop]);
}
});
}
return o;
};