1.0.0 • Published 8 years ago

fixed-object v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

fixed-object

Make an object immutable! Just that! No more crap!

node npm Travis Gemnasium Coveralls

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 mugo@forfuture.co.ke