Skip to content

A fast and type safe recursive (deep) object/array/function freeze

License

Notifications You must be signed in to change notification settings

thght/freeze-deep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

freeze-deep


A fast and type safe recursive (deep) object/array/function freeze

Fast, type safe and tested, it always returns the type and value(s) you've feeded it, frozen if freezable.


const freezeDeep = require('freeze-deep');

const MODEL= freezeDeep({
	person: {
		name: ''
		friends: []
	}
});

MODEL.person.name= 'Max';
console.log( MODEL.person.name );
// ''

delete MODEL.person.name;
console.log( MODEL.person );
// { name: '', friends: [] }

MODEL.person.friends[0]= 'Jack';
console.log( MODEL.person.friends[0] );
// undefined

// no runtime error on undefined or null
freezeDeep();
freezeDeep( null );

When using with node.js: npm install --save freeze-deep in the project root.

To run the tests: npm test at the cli in the project root.

I am always open for feedback and suggestions on how to improve the code.


0.1.0

  • initial commit

license

MIT

About

A fast and type safe recursive (deep) object/array/function freeze

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published