JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q40247F
  • License ISC

Lazily chain with proxies.

Package Exports

  • lazy-chain

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 (lazy-chain) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Lazy Chain

NPM

Build Status js-standard-style codecov

A library to allow easy method chaining with es6 proxies.

Installation

NPM

First run npm install lazy-chain then require the file

const LazyChain = require("lazy-chain")

Or include the direct file

<script src="./npm_modules/lazy-chain/index.js"></script>

Usage

Setup

//Create a new LazyList
const LazyChain = require('lazy-chain')
const lazy = LazyChain() //Or use new

Chaining

Chaining runs a series of methods on the fed object, and then returns the modified object


//Chain together a series of methods
lazy.push(7)
lazy.push(8)
lazy.forEach((value) => {
  console.log(value)
})

//Feed the chain an object
lazy.chain([3, 4, 5]) //Becomes [3, 4, 5, 7, 8]
lazy.chain(['hello', true]) //Becomes ['hello', true, 7, 8]

Piping

Piping runs a series of methods, running each sequencial method on the previous methods output, and then returns the output of the last method.

//Chain together some methods
lazy.map((value) => {
  return value+1
})
lazy.map((value) => {
  return value*2
})

//Feed the pipeline the first value
lazy.pipe([1, 2]) //Becomes [5, 6]
lazy.pipe([3, 4]) //Becomes [8, 10]