Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

readonly Build Status

readonly is simple reference restriction library between custom modules in node object.

How to install

npm install readonly

How to use

var readonly = require('readonly');

var obj = {'A':'a','B':'b','C':'c'};

// Normal ACL. You can use `obj` through moduleA as you like
var moduleA = {};
moduleA.obj = obj;

// Readonly restriction of `obj` in moduleB
var moduleB = {};
moduleB.obj = readonly(obj);

// You can update `obj` from moduleA
moduleA.obj.A = "d";
// This updates can be seen from moduleB
console.log(moduleB.obj.A); // --> "d"

// But if you update `obj` through moduleB, it will throws `UnableRewriteException`
moduleA.obj.B = "e";  // --> UnableRewriteException: original cannot be rewrite

LICENSE

MIT License. Please see the LICENSE file for details.

About

Simple reference restriction library between custom modules in node object.

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages