Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including protect with all npm packages installed. Try it out:

var protect = require("protect")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

protect v0.5.0

protect your object from being overridden

protect

NPM version Linux Status Windows Status Dependency Status Coveralls

protect your object from being overridden

Installation

Install through NPM

npm install protect

or

git clone git://github.com/hex7c0/protect.git

API

inside nodejs project

var protect = require('protect');

var newObj = protect({
    foo: 'ciao'
});

newObj.ciao = 'ciao';
newObj.foo = 123;

with this exception

a.foo = 123;
      ^
TypeError: Cannot assign to read only property 'foo' of [object Object]

protect(obj, [normal])

options

  • obj - Object Your object (default "required")
  • normal - Boolean Using {} constructor (default "Object.create(null)")

Examples

Take a look at my examples

License GPLv3

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free