Skip to content

GochoMugo/fixed-object

Repository files navigation

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

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published