fixed-object

1.0.0 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i fixed-object

Weekly Downloads

0

Version

1.0.0

License

MIT

Last publish

Collaborators

  • gochomugo