Skip to content
❄️ Ugly but fast read only object
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
static
.gitignore
LICENSE
README.md
index.js
package-lock.json
package.json
rollup.config.js

README.md

fast-freeze

Ugly but fast read only object

This module actually don't freeze object but convert the object into nested functions. Hence accessing any propery seems ugly.

How to use

Install like any npm package

npm i fast-freeze

then just use it

var fastFreeze = require("fast-freeze");

var testConfig = {
    name: 'John',
    surname: 'Johnson',
    age: 26,
    address: {
        street: '1st Street',
        city: 'Los Angeles',
        country: 'USA'
    },
    vehicles: [
        'BMW',
        'Ferrari',
        'Lamborghini'
    ]
};

var frozenConfig = fastFreeze(testConfig);

console.log( frozenConfig("vehicles")[1] );
console.log( testConfig["vehicles"][1] );

Benchmark

Object.freeze : 62130394.37862057 requests/second fast-freeze : 514441747.5754436 requests/second normal : 498987957.90934324 requests/second

benchmark fast freeze javascript

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.