Skip to content

Fdawgs/ice-barrage

Repository files navigation

ice-barrage

GitHub release npm version CI Coverage status code style: Prettier OSSF Scorecard

Node.js module to iteratively freeze objects, arrays, and functions

Overview

ice-barrage is a drop-in replacement for deep-freeze, with the following improvements:

  • Iterative traversal to avoid call stack overflow on deep objects
  • Handling of circular references
  • Skipping of accessor properties to avoid side effects
  • Support for Symbol keys
  • TypeScript type definitions included
  • Input validation

Installation

Install using npm:

npm i ice-barrage

Example usage

Please refer to the JSDoc comments in the source code or the generated type definitions for information on the available options.

"use strict";

const iceBarrage = require("ice-barrage");

const exampleObject = {
	a: 1,
	b: {
		c: 2,
		d: [3, 4, 5],
	},
};

iceBarrage(exampleObject); // iceBarrage mutates the input object
console.log(Object.isFrozen(exampleObject)); // true
console.log(Object.isFrozen(exampleObject.b)); // true
console.log(Object.isFrozen(exampleObject.b.d)); // true

Contributing

Contributions are welcome, and any help is greatly appreciated!

See the contributing guide for details on how to get started. Please adhere to this project's Code of Conduct when contributing.

License

ice-barrage is licensed under the MIT license.

About

Node.js module to iteratively freeze objects, arrays, and functions

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Sponsor this project

 

Packages

 
 
 

Contributors