# node-train

> [![npm version](https://badge.fury.io/js/node-train.svg)](https://badge.fury.io/js/node-train)

Latest version **1.0.0** (published 2017-05-10) · ISC license · 0 weekly downloads

## Install

```sh
npm install node-train
pnpm add node-train
yarn add node-train
bun add node-train
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2017-05-10 |
| First published | 2017-05-07 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Maintainers | peterparada |
| Keywords | clojure, thread-last |

## Links

- npm: https://www.npmjs.com/package/node-train
- Repository: https://github.com/pito-svk/node-train
- Homepage: https://github.com/pito-svk/node-train#readme
- Issues: https://github.com/pito-svk/node-train/issues
- npm.io page: https://npm.io/package/node-train

## Dependencies (2)

- [ramda](https://npm.io/package/ramda.md) ^0.23.0
- [bluebird](https://npm.io/package/bluebird.md) ^3.5.0

## Recent versions

- 1.0.0 (latest) — 2017-05-10
- 0.2.5 — 2017-05-09
- 0.2.4 — 2017-05-09
- 0.2.3 — 2017-05-08
- 0.2.2 — 2017-05-08
- 0.2.1 — 2017-05-08
- 0.1.1 — 2017-05-07
- 0.1.0 — 2017-05-07
- 0.0.3 — 2017-05-07
- 0.0.2 — 2017-05-07
- 0.0.1 — 2017-05-07

## README

# node-train

[![npm version](https://badge.fury.io/js/node-train.svg)](https://badge.fury.io/js/node-train)

Inspired by Clojure's ["thread-last" macro](https://clojuredocs.org/clojure.core/-%3E%3E).

## Installation

Npm:
```sh
$ npm i node-train
```

Yarn:
```sh
$ yarn add node-train
```

## Use case

```javascript
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
```

---
_Source: https://npm.io/package/node-train · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
