is-deep-frozen
v5.0.7
Published
check if an object or function is deeply frozen
Downloads
24
Maintainers
Readme
is-deep-frozen?
The question that has plagued monkey-kind and human-kind for millions of years. 🙉🙊🙈
##About:
Find out if your javascript object, function, or class is deeply frozen.
#####What this module checks:
This module checks that any object, function, or class you input, or any object, function, or class that is inside your input value will be frozen.
If your Node version is greater or equal to 6, this module checks that any buffers you input, or any buffers inside your input value are sealed (buffers cannot be frozen).
Note: Primitive javascript types (e.g. string or number) are considered to be frozen in this module.
#####If you want to deeply freeze your objects, you can use the following:
##install:
npm install is-deep-frozen
##usage:
'use strict';
const isDeepFrozen = require( 'is-deep-frozen' );
const o = Object.freeze({ xxx: 69 });
const passingResult = isDeepFrozen( o );
// passingResult will be {}, indicating o is deeply frozen
const f = function() {};
f.a = Object.freeze({ b: {} });
const failingResult = isDeepFrozen( f );
// failingResult.notDeeplyFrozen will be set to true
console.log( failingResult.error );
/*
the resulting log is:
{ NotDeeplyFrozenError: property: inputValue, value: function () {}
property: inputValue[ "prototype" ], value: {}
property: inputValue[ "a" ][ "b" ], value: {}
at isDeepFrozen (/Users/test_dir/index.js:20:23)
...
}
*/