JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q16888F
  • 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 bower

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")

Bower

Install the package with bower install lazy-chain and then include the index.js file

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

Usage

//Create a new LazyList
let lazy = LazyChain() //Or use new

//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]

Output

LazyChain.prototype.chain returns an object representing the operation

name value
obj the obj after every method
results an array of the returned values of each method

Notes

  • It is possible to chain any method
  • It is possible to use any object
  • The methods are chained onto the original object, not each others output
  • Node must be run with the flags --harmony-proxies --harmony
  • For this to be used in browser, the brower must have the Proxy api.
  • The LazyChain's run method supersedes the run method of any object fed to it

Todo

  • Enable piping of methods
  • Add to jspm
  • Add a full API.md file