Git Product home page Git Product logo

immu___small_immutable_data_wrapper's Introduction

immu NPM Module NPM download count Build Status

emu

A TINY, fail-fast, lazy, "naked", simple immutable data structure library.

  • By TINY, less than 1k gzipped and minified.
  • By fail-fast, I mean you'll be notified if you try to change a proprety.
  • By lazy, I mean it doesn't evaulate the mutability of a property until it absolutely has to.
  • By naked, I mean they work like regular objects and arrays.
  • By simple, I mean that it doesn't add any extra features to your code (except immutability, of course).

Why use immutable data?

Bugs happen because developers write them. This just puts one more layer between you and your code exploding.

Install

npm install immu --save

Usage

'use strict';

let immu = require('immu');

let user = {
  name: 'Scott',
  age: 31,
  location: 'somewhere'
};

let immutableUser = immu(user);

try {
  immutableUser.name = 'Unchangeable';
}
catch (e) {
  console.error(e.message); // Cannot change value of an immutable property
}

console.log(immutableUser.name) // Scott

// Get the raw object back
console.log(immutableUser.toJS()); // {name: 'Scott', age: 31, location: 'somewhere'}

let list = immu([1, 2, 3, 4]);
let newList = list
  .map(item => item + 1)
  .filter(item => item % 2 === 0);

Run Tests

git clone https://github.com/scottcorgan/immu.git && cd immu
npm install
npm test

immu___small_immutable_data_wrapper's People

Contributors

michaeldeol avatar scottcorgan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.