fixed-object
v1.0.0
Published
Make an object immutable! Just that! No more crap!
Downloads
4
Readme
fixed-object
Make an object immutable! Just that! No more crap!
install:
$ npm install fixed-object
make immutable:
config.json:
{
"name": "gochomugo"
}
var fixedobj = require("fixed-object");
var config = fixedobj(require("./config.json"));
console.log(config); // => { name: 'gochomugo' }
// this will throw an error
config.name = "sheldon cooper"; // => TypeError: Cannot assign to read only property 'name' of #<Object>
console.log(config); // => { name: 'gochomugo' }
how is it useful?
I find this useful when loading configuration files. We usually never intend to mutate configuration objects. But if you accidentally do, you can imagine the shit crap your application will go through before you realize where you messed up.
license:
The MIT License (MIT)
Copyright (c) 2015-2016 GochoMugo [email protected]