Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hex7c0/protect
protect your object from being overridden
https://github.com/hex7c0/protect
nodejs object
Last synced: about 1 month ago
JSON representation
protect your object from being overridden
- Host: GitHub
- URL: https://github.com/hex7c0/protect
- Owner: hex7c0
- License: gpl-3.0
- Created: 2014-11-13T20:42:28.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2023-04-15T23:59:06.000Z (over 1 year ago)
- Last Synced: 2024-11-04T18:12:44.654Z (about 2 months ago)
- Topics: nodejs, object
- Language: JavaScript
- Homepage: https://github.com/hex7c0/protect
- Size: 59.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# [protect](https://github.com/hex7c0/protect)
[![NPM version](https://img.shields.io/npm/v/protect.svg)](https://www.npmjs.com/package/protect)
[![Linux Status](https://img.shields.io/travis/hex7c0/protect.svg?label=linux-osx)](https://travis-ci.org/hex7c0/protect)
[![Windows Status](https://img.shields.io/appveyor/ci/hex7c0/protect.svg?label=windows)](https://ci.appveyor.com/project/hex7c0/protect)
[![Dependency Status](https://img.shields.io/david/hex7c0/protect.svg)](https://david-dm.org/hex7c0/protect)
[![Coveralls](https://img.shields.io/coveralls/hex7c0/protect.svg)](https://coveralls.io/r/hex7c0/protect)protect your object from being overridden
## Installation
Install through NPM
```bash
npm install protect
```
or
```bash
git clone git://github.com/hex7c0/protect.git
```## API
inside nodejs project
```js
var protect = require('protect');var newObj = protect({
foo: 'ciao'
});newObj.ciao = 'ciao';
newObj.foo = 123;
```
with this exception
```sh
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](examples)
### [License GPLv3](LICENSE)