thread-first

1.0.1 • Public • Published

thread-first

Like the thread first macro in clojure https://clojure.org/guides/threading_macros

install

npm install thread-first

usage

  var threadFirst = require('thread-first')

  function head (array) {
    return Array.isArray(array) && array[0]
  }
  var text = 'abcd'
  var X = threadFirst(text, [
    ['replace', 'a', 'x'],
    'toUpperCase',
    ['split', ''],
    head
  ])
  console.log(X) // 'X'

Readme

Keywords

none

Package Sidebar

Install

npm i thread-first

Weekly Downloads

1

Version

1.0.1

License

MIT

Last publish

Collaborators

  • utanapishtim