NASA Planetary Mission

    @slimio/immutable
    TypeScript icon, indicating that this package has built-in type declarations

    0.1.0 • Public • Published

    Immutable

    V0.1.0 Maintenance MIT

    Immutable Objects properties.

    ⚠️ this project is experimental

    Getting Started

    This package is available in the Node Package Repository and can be easily installed with npm or yarn.

    $ npm i @slimio/immutable
    # or
    $ yarn add @slimio/immutable

    API

    seal< T extends object >(target: T): T

    Same as Object.seal() but doesn't allow to cast the original property type:

    const obj = Immutable.seal({
        foo: "bar"
    });
    obj.foo = "world"; // ok
    obj.foo = 10; // Error: Unable to cast string to number for propertyKey foo
    freezedProperty(target: object, propertyKey: symbol | string, value?: any): void

    Setup a freezed property on a given target (Same behavior as Object.freeze but for all kind of values).

    const obj = {};
    Immutable.freezedProperty(obj, "foo", "bar");
    console.log(obj.foo); // stdout bar
    delete obj.foo; // Error

    License

    MIT

    Install

    npm i @slimio/immutable

    DownloadsWeekly Downloads

    26

    Version

    0.1.0

    License

    MIT

    Unpacked Size

    6.87 kB

    Total Files

    5

    Last publish

    Collaborators

    • mcroquet
    • ahkrin
    • fraxken
    • alexandre.malaj