object-freeze-x

1.0.3 • Public • Published

Travis status Dependency status devDependency status npm version jsDelivr hits bettercodehub score Coverage Status

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.

Param Type Description
[target] * The object to freeze.

Example

import freeze from 'object-freeze-x';
 
const x = {};
console.log(freeze(x) === x); // true

Package Sidebar

Install

npm i object-freeze-x

Weekly Downloads

2

Version

1.0.3

License

MIT

Unpacked Size

53.7 kB

Total Files

11

Last publish

Collaborators

  • xotic750