immutable-transactions
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

immutable-transactions

immutable-transactions is a JavaScript library simplifying transactions in application state where you want to enforce strict immutability while still using native JavaScript objects and arrays.

It´s a simple and lightweight alternative to Immutable.js or Seamless-Immutable.

Some features:

  • If the transaction didn't cause any changes, the previous object will be returned.
  • Make operations deep in a nested object using a list of keys, return the top object.
  • Supports negative array indexes.

Example

import { changeIn } from 'immutable-transactions'

const state = {
  ultimate: {
    answer: 41
  }
}

const nextState = changeIn(state, ['ultimate', 'answer'], previousValue => previousValue + 1)
// => {
//   ultimate: {
//     answer: 42
//   }
// }

See description of all methods in the declaration file

Readme

Keywords

none

Package Sidebar

Install

npm i immutable-transactions

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

49.8 kB

Total Files

10

Last publish

Collaborators

  • eosterberg