https://github.com/hex7c0/protect
protect your object from being overridden
https://github.com/hex7c0/protect
nodejs object
Last synced: 3 months 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 (over 10 years ago)
- Default Branch: master
- Last Pushed: 2023-04-15T23:59:06.000Z (about 2 years ago)
- Last Synced: 2025-02-27T09:11:02.709Z (4 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)
[](https://www.npmjs.com/package/protect)
[](https://travis-ci.org/hex7c0/protect)
[](https://ci.appveyor.com/project/hex7c0/protect)
[](https://david-dm.org/hex7c0/protect)
[](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)