Skip to content

pito-svk/node-train

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deprecated

Can use R.composeP instead, for example:

const R = require('ramda')

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

node-train

npm version Build Status Coverage Status

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published