JSPM

@rahazad/payload-reducer

0.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6
  • Score
    100M100P100Q48440F
  • License MIT

Something like lodash.merge() (a recursive version of Object.assign()) that specially designed for roudex. It especially supports functions to make it possible to transform properties based on them previous states/values.

Package Exports

  • @rahazad/payload-reducer

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@rahazad/payload-reducer) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Payload-Reducer

Something like lodash.merge() (a recursive version of Object.assign()) that specially designed for roudex. It especially supports functions to make it possible to transform properties based on them previous states/values.

npm (scoped) install size npm
Dependencies Status devDependencies Status
GitHub GitHub forks GitHub stars

Installation

npm i @rahazad/payload-reducer

or using yarn:

yarn add @rahazad/payload-reducer

Usage

import payloadReducer from '@rahazad/payload-reducer'

const srcState = {
    a: 'a',
    n: 10,
    v: {c: 'c'}
}

const payloads = [
    {
        a: 'A',
        v: {c: 'C'}
    },
    {
        n: n => n * 2
    },
]

const {newState} = payloadReducer(srcState, ...payloads)

assert.deepStrictEqual(newState, {  // import assert from 'assert' // https://nodejs.org/api/assert.html
    a: 'A',
    n: 20,
    v: {c: 'C'}
})

License

MIT © Mir-Ismaili