Package Exports
- subzero
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 (subzero) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
#subzero

##About: Freeze a class and its prototype, or freeze an object.
##install:
npm install freeze-class##usage:
###subzero.freezeClass Freeze a class and its prototype
'use strict';
const subzero = require( 'subzero' );
class C {
static f() { return 69; }
f() { return 22; }
}
freezeClass( C );
/*
the following statements will now return true:
*/
// Object.isFrozen( C );
// Object.isFrozen( C.prototype );
/*
and the following statements will now throw TypeErrors in strict mode:
*/
// C.g = function() { return 42 };
// C.f = function() { return 42 };
// delete C.f;
// C.constant = 42;
// C.prototype.g = function() { return 42 };
// C.prototype.f = function() { return 42 };
// delete C.prototype.f;
// C.prototype.constant = 42;
###subzero.deepFreezeClass
Deep freeze a class and its prototype. This will not freeze any classes within the class. It works by recursively freezing anything of type "object".
'use strict';
const subzero = require( 'subzero' );
class C {}
class InnerClass {}
InnerClass.x = {
y: {}
};
C.a = {
b: {
c: {
d: {
InnerClass
}
}
}
};
C.prototype.x = {
y: {
z: {}
},
w: {}
};
subzero.deepFreezeClass( C );
/*
the following statements will now return true:
*/
// Object.isFrozen( C );
// Object.isFrozen( C.a );
// Object.isFrozen( C.a.b );
// Object.isFrozen( C.a.b.c );
// Object.isFrozen( C.a.b.c.d );
// Object.isFrozen( C.prototype );
// Object.isFrozen( C.prototype.x );
// Object.isFrozen( C.prototype.x.y );
// Object.isFrozen( C.prototype.x.y.z );
// Object.isFrozen( C.prototype.x.w );
// !Object.isFrozen( InnerClass );
// !Object.isFrozen( InnerClass.x );
// !Object.isFrozen( InnerClass.x.y );
βοΈπ πΏπ π½π πΎπ πΌβοΈπΏπ»π ###subzero.deepFreezeObject
Deep freeze an object. This will not freeze any classes within the object. It works by recursively freezing anything of type "object".
'use strict';
const subzero = require( 'subzero' );
const o = {};
class InnerClass {}
InnerClass.x = {
y: {}
};
o.a = {
b: {
c: {
d: {
InnerClass
}
}
}
};
o.x = {
y: {
z: {}
},
w: {}
};
subzero.deepFreezeObject( o );
/*
the following statements will now return true:
*/
// Object.isFrozen( o );
// Object.isFrozen( o.a );
// Object.isFrozen( o.a.b );
// Object.isFrozen( o.a.b.c );
// Object.isFrozen( o.a.b.c.d );
// Object.isFrozen( o.x );
// Object.isFrozen( o.x.y );
// Object.isFrozen( o.x.y.z );
// Object.isFrozen( o.x.w );
// !Object.isFrozen( InnerClass );
// !Object.isFrozen( InnerClass.x );
// !Object.isFrozen( InnerClass.x.y );
