1. deep-freeze-strict
recursively Object.freeze() objects and functions, works in strict mode
deep-freeze-strict
Package: deep-freeze-strict
Created by: jsdf
Last modified: Tue, 14 Jun 2022 22:53:56 GMT
Version: 1.1.1
License: public domain
Downloads: 602,580
Repository: https://github.com/jsdf/deep-freeze

Install

npm install deep-freeze-strict
yarn add deep-freeze-strict

deep-freeze-strict

recursively Object.freeze() objects.

this fork works in strict mode, so when
freezing a function you don't get the error:

> (function(){ "use strict"; deepFreeze(function(){}); })();

TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them

example

 var deepFreeze = require('deep-freeze-strict');

deepFreeze(Buffer);
Buffer.x = 5;
console.log(Buffer.x === undefined);

Buffer.prototype.z = 3;
console.log(Buffer.prototype.z === undefined);

$ node example/deep.js
true
true

methods

 var deepFreeze = require('deep-freeze-strict')

deepFreeze(obj)

Call Object.freeze(obj) recursively on all unfrozen properties of obj that
are functions or objects.

license

public domain

Based in part on the code snippet from
the MDN wiki page on Object.freeze(),
which
is released to the public domain.

Dependencies

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code