1.0.0 • Published 7 years ago

node-train v1.0.0

Weekly downloads
4
License
ISC
Repository
github
Last release
7 years ago

node-train

npm version

Inspired by Clojure's "thread-last" macro.

Installation

Npm:

$ npm i node-train

Yarn:

$ yarn add node-train

Use case

const train = require('node-train')
const _ = require('lodash')

const calls =
  await train(callsResponse.items,
              addTotalSpendingPerCall,
              addShopNamePerCall,
              addCustomerPerCall,
              addBranchIdPerCall,
              addProductDescriptionPerCall,
              _.last)

return calls

// same as
const calls = callsResponse.items
const callsWithTotalSpending = await addTotalSpendingPerCall(calls)
const callsWithTotalSpendingAndShopName = await addShopNamePerCall(callsWithTotalSpending)
const callsWithTotalSpendingAndShopNameAndCustomer = await addCustomerPerCall(callsWithTotalSpendingAndShopName)
const callsWithTotalSpendingAndShopNameAndCustomerAndBranchId = await addBranchIdPerCall(callsWithTotalSpendingAndShopNameAndCustomer)
const callsWithTotalSpendingAndShopNameAndCustomerAndBranchIdAndProductDescription = await addProductDescriptionPerCall(callsWithTotalSpendingAndShopNameAndCustomerAndBranchId)
const lastCallWithTotalSpendingAndShopNameAndCustomerAndBranchIdAndProductDescription = _.last(callsWithTotalSpendingAndShopNameAndCustomerAndBranchIdAndProductDescription)

return lastCallWithTotalSpendingAndShopNameAndCustomerAndBranchIdAndProductDescription
1.0.0

7 years ago

0.2.5

7 years ago

0.2.4

7 years ago

0.2.3

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago