1.0.3 • Published 5 years ago

object-freeze-x v1.0.3

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

object-freeze-x

Freezes an object. Or fake when freeze does not exist.

module.exports*

Nothing can be added to or removed from the properties set of a frozen object. Any attempt to do so will fail, either silently or by throwing a TypeError exception (most commonly, but not exclusively, when in strict mode).

For data properties of a frozen object, values cannot be changed, the writable and configurable attributes are set to false. Accessor properties (getters and setters) work the same (and still give the illusion that you are changing the value). Note that values that are objects can still be modified, unless they are also frozen. As an object, an array can be frozen; after doing so, its elements cannot be altered and no elements can be added to or removed from the array.

Returns the same object that was passed into the function. It does not create a frozen copy.

Kind: Exported member
Returns: * - The object to freeze.

ParamTypeDescription
target*The object to freeze.

Example

import freeze from 'object-freeze-x';

const x = {};
console.log(freeze(x) === x); // true