nativemutate

0.0.5-rf2 • Public • Published

NativeMutate

Lightweight & Easy immutable object data library for lightweight apps.

size gzipsize

Why NativeMutate

  • Lightweight (~1kB min&gzip)
  • Uses native-way (object native access way)
  • No dependecy requires to work
  • Good browser support (IE9+, Android 4.3+)
  • Good performance (up to 10.000-set/get is better then bit poor)
  • NodeJS support
  • ES6 support via import NativeMutate from 'nativemutate'
  • No configuration
  • Back to IE6 support via polyfills

CDN

Installing

$ npm install nativemutate
# or
$ yarn add nativemutate

Using

// CommonJS / NodeJS
const { Map, Reducer, SimpleReducer, CheckIn, equal } = require('nativemutate');

// ES6
import { Map, Reducer, SimpleReducer, CheckIn, equal } from 'nativemutate';

// Browser
// HTML Tag: <script src="https://unpkg.com/nativemutate"></script> (NOTE! IE8, Android 4 requires [type="text/javascript"] attribute)
// Now you have access via `window.NativeMutate`

Usage

var yourObject = {
	myAccess: { to: { property: true } }
};

var yourData = new NativeMutate.Map(yourObject);
	yourData.immute(); // Freezing data, but can change via yourData.set

yourObject.myAccess.to.property = false; // logs `true` as it's now freezed

yourData.set(['myAccess', 'to', 'property'], false); // logs `false` as it's changed via instance

yourData.get(['myAccess', 'to', 'property']) // `false`

Methods

get

```javascript` yourData.get('myAccess') // get value via string yourData.get(['myAccess', 'to', 'property']) // get value via Array // or make your own yourData.get('myAccess.to.property'.split(".")) // looks good, we not provide this feature built-in

set

```javascriptyourData.set('myAccess', { to: { property: 'ok' } }) // set value via string yourData.set(['myAccess', 'to', 'property'], 999) // set value via Array yourData.set(['myAccess', 'to', 'property'], function (oldValue) { return oldValue + 1 }) // set value via function, changes to1000` yourData.set(function (oldObj) { return { myAccess: { to: { property: 'never' } } }; }); // set value via function // or make your own yourData.set('myAccess.to.property'.split("."), 'always') // looks good, we not provide this feature built-in


# License
Licensed under MIT-License, do everything, use it

Package Sidebar

Install

npm i nativemutate

Weekly Downloads

2

Version

0.0.5-rf2

License

MIT

Last publish

Collaborators

  • dalisoft