is-deep-frozen

5.0.7 • Public • Published

is-deep-frozen? npm version Build Status

dkconfused.png

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:
  1. 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.

  2. 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:
  1. subzero
  2. deep-freeze
  3. immutablejs

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)
            ...
    }
*/

Package Sidebar

Install

npm i is-deep-frozen

Weekly Downloads

9

Version

5.0.7

License

BSD 3-Clause License

Last publish

Collaborators

  • npm.m.stecky.efantis