Package Exports
- deep-freeze-plus
- deep-freeze-plus/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (deep-freeze-plus) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
deep-freeze-plus
A fast and efficient implementation of the deepFreeze function for freezing JavaScript objects and arrays without recursion. Supports all primitive types, objects, arrays, Maps, Sets, and other complex data structures.
Installation
To install deep-freeze-plus using npm:
npm install deep-freeze-plus
To install deep-freeze-plus using yarn:
yarn add deep-freeze-plus
Usage
To use deep-freeze-plus in your project, simply import the deepFreeze function and pass in the object or array you want to freeze:
const { deepFreeze } = require('deep-freeze-plus');
const obj = {
a: 1,
b: {
c: 2,
d: [3, 4],
e: new Set([5, 6, 7]),
f: new Map([['foo', 'bar'], ['baz', 'qux']]),
},
};
deepFreeze(obj);
obj.a = 100; // Throws an error
obj.b.c = 200; // Throws an error
obj.b.d[0] = 300; // Throws an error
obj.b.e.add(8); // Throws an error
obj.b.f.set('hello', 'world'); // Throws an errorContributing
We welcome contributions to deep-freeze-plus! If you find a bug or have a feature request, please open an issue or submit a pull request.
Before contributing, please review the contributing guidelines.