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

1.0.0 • Public • Published

Auto Immutable JS

Introduction

Auto Immutable JS is a self enforcing immutable class. Its internal data are private and readonly.

It provides Consumer instances through which it can be read and updated.

Name:

@webkrafters/auto-immutable
Alternate: auto-immutable.js

Installation

npm install --save @webkrafters/auto-immutable

Quick Start

Please see Full documentation before using. Recommended.

Obtain an Immutable Instance

/* my-immutable.ts */

import AutoImmutable from '@webkrafters/auto-immutable';

const initValue = { a: { b: { c: 24 } } };

const aImmutable = new Immutable( initValue );

export default aImmutable;

Connect to an AutoImmutable Instance

/* read-my-immutable.ts */

import myImmutable from './my-immutable';

const consumer = myImmutable.connect();

const objectPath = 'a.b.c';

const data : AccessorResponse = consumer.get( objectPath );

console.log( data ); // { 'a.b.c', 24 }

Manually Discard an AutoImmutable Consumer.

consumer.disconnect();

Manually Discard an AutoImmutable Instance.

myImmutable.close();

License

MIT

Package Sidebar

Install

npm i @webkrafters/auto-immutable

Weekly Downloads

15

Version

1.0.0

License

MIT

Unpacked Size

135 kB

Total Files

26

Last publish

Collaborators

  • webkrafters