Socket
Socket
Sign inDemoInstall

trough

Package Overview
Dependencies
0
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.4 to 1.0.5

25

package.json
{
"name": "trough",
"version": "1.0.4",
"version": "1.0.5",
"description": "Middleware: a channel used to convey a liquid",

@@ -12,2 +12,6 @@ "license": "MIT",

"bugs": "https://github.com/wooorm/trough/issues",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
},
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",

@@ -24,9 +28,9 @@ "contributors": [

"browserify": "^16.0.0",
"nyc": "^14.0.0",
"prettier": "^1.12.0",
"remark-cli": "^6.0.0",
"remark-preset-wooorm": "^4.0.0",
"tape": "^4.4.0",
"tinyify": "^2.4.3",
"xo": "^0.24.0"
"nyc": "^15.0.0",
"prettier": "^1.0.0",
"remark-cli": "^7.0.0",
"remark-preset-wooorm": "^6.0.0",
"tape": "^4.0.0",
"tinyify": "^2.0.0",
"xo": "^0.25.0"
},

@@ -54,4 +58,5 @@ "scripts": {

"rules": {
"guard-for-in": "off",
"unicorn/prefer-type-error": "off"
"unicorn/prefer-reflect-apply": "off",
"unicorn/prefer-type-error": "off",
"guard-for-in": "off"
},

@@ -58,0 +63,0 @@ "ignores": [

77

readme.md

@@ -10,14 +10,14 @@ # trough

`trough` is like [`ware`][ware] with less sugar, and middleware
functions can change the input of the next.
`trough` is like [`ware`][ware] with less sugar, and middleware functions can
change the input of the next.
## Installation
## Install
[npm][]:
```bash
```sh
npm install trough
```
## Usage
## Use

@@ -31,3 +31,3 @@ ```js

.use(function(fileName) {
console.log('Checking... ' + fileName)
console.log('Checking… ' + fileName)
})

@@ -57,4 +57,4 @@ .use(function(fileName) {

```txt
Checking... readme.md
Checking... node_modules
Checking… readme.md
Checking… node_modules
Error: Expected file

@@ -76,3 +76,3 @@ at ~/example.js:21:12

#### `trough.wrap(middleware, callback[, ...input])`
#### `trough.wrap(middleware, callback[, …input])`

@@ -86,4 +86,4 @@ Call `middleware` with all input.

All other input values are called the rest input values.
The values given to `callback` are the input values, merged with every
non-nully output value.
The values given to `callback` are the input values, merged with every non-nully
output value.

@@ -102,15 +102,17 @@ * If `middleware` throws an error, returns a promise that is rejected, or

#### `Trough#run([input..., ]done)`
#### `Trough#run([input…, ]done)`
Run the pipeline (all [`use()`][use]d middleware). Invokes [`done`][done]
on completion with either an error or the output of the last middleware
Run the pipeline (all [`use()`][use]d middleware).
Invokes [`done`][done] on completion with either an error or the output of the
last middleware.
> Note! as the length of input defines whether [async][] functions get a `next`
> Note!
> as the length of input defines whether [async][] functions get a `next`
> function, it’s recommended to keep `input` at one value normally.
##### `function done(err?, [output...])`
##### `function done(err?, [output…])`
The final handler passed to [`run()`][run], invoked with an error
if a [middleware function][fn] rejected, passed, or threw one, or
the output of the last middleware function.
The final handler passed to [`run()`][run], invoked with an error if a
[middleware function][fn] rejected, passed, or threw one, or the output of the
last middleware function.

@@ -121,3 +123,3 @@ #### `Trough#use(fn)`

##### `function fn([input..., ][next])`
##### `function fn([input…, ][next])`

@@ -128,8 +130,7 @@ A middleware function invoked with the output of its predecessor.

If `fn` returns or throws an error, the pipeline fails and `done` is
invoked with that error.
If `fn` returns or throws an error, the pipeline fails and `done` is invoked
with that error.
If `fn` returns a value (neither `null` nor `undefined`), the first
`input` of the next function is set to that value (all other `input`
is passed through).
If `fn` returns a value (neither `null` nor `undefined`), the first `input` of
the next function is set to that value (all other `input` is passed through).

@@ -153,3 +154,3 @@ The following example shows how returning an error stops the pipeline:

at ~/example.js:5:12
...
```

@@ -174,3 +175,3 @@

at ~/example.js:5:11
...
```

@@ -198,8 +199,8 @@

If `fn` returns a promise, and that promise rejects, the pipeline fails
and `done` is invoked with the rejected value.
If `fn` returns a promise, and that promise rejects, the pipeline fails and
`done` is invoked with the rejected value.
If `fn` returns a promise, and that promise resolves with a value
(neither `null` nor `undefined`), the first `input` of the next function
is set to that value (all other `input` is passed through).
If `fn` returns a promise, and that promise resolves with a value (neither
`null` nor `undefined`), the first `input` of the next function is set to that
value (all other `input` is passed through).

@@ -226,4 +227,3 @@ The following example shows how rejecting a promise stops the pipeline:

The following example shows how the input isn’t touched by resolving
to `null`.
The following example shows how the input isn’t touched by resolving to `null`.

@@ -252,5 +252,5 @@ ```js

If `fn` accepts one more argument than the given `input`, a `next`
function is given (after the input). `next` must be called, but doesn’t
have to be called async.
If `fn` accepts one more argument than the given `input`, a `next` function is
given (after the input). `next` must be called, but doesn’t have to be called
async.

@@ -264,4 +264,3 @@ If `next` is given a value (neither `null` nor `undefined`) as its first

The following example shows how passing a first argument stops the
pipeline:
The following example shows how passing a first argument stops the pipeline:

@@ -268,0 +267,0 @@ ```js

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc