# @dnlup/cut

> A stream size validator

Latest version **1.0.0** (published 2020-02-17) · ISC license · 0 weekly downloads

## Install

```sh
npm install @dnlup/cut
pnpm add @dnlup/cut
yarn add @dnlup/cut
bun add @dnlup/cut
```

## 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 | 2020-02-17 |
| First published | 2020-02-17 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=10 |
| Dependencies | 0 |
| Unpacked size | 4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Daniele Belardi |
| Maintainers | dnlup |
| Keywords | stream, size, validator |

## Links

- npm: https://www.npmjs.com/package/@dnlup/cut
- Repository: https://github.com/dnlup/cut
- Homepage: https://github.com/dnlup/cut#readme
- Issues: https://github.com/dnlup/cut/issues
- npm.io page: https://npm.io/package/@dnlup/cut

## Alternatives

- [byte-size](https://npm.io/package/byte-size.md) — 2.1M weekly downloads
- [speed-limiter](https://npm.io/package/speed-limiter.md) — 16.0K weekly downloads
- [@powersync/node](https://npm.io/package/@powersync/node.md) — 10.9K weekly downloads
- [@ledgerhq/coin-cardano](https://npm.io/package/@ledgerhq/coin-cardano.md) — 1.0K weekly downloads
- [@jayesol/jayeson.lib.streamfinder](https://npm.io/package/@jayesol/jayeson.lib.streamfinder.md) — 1.0K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2020-02-17

## README

# cut

> A stream size validator

<!-- toc -->

- [Installation](#installation)
- [Usage](#usage)
- [API](#api)
  * [cut([options])](#cutoptions)

<!-- tocstop -->

## Installation

```bash
$ npm i @dnlup/cut
```

## Usage
```js
const cut = require('@dnlup/cut')
const { pipeline } = require('stream')

const readable = getReadableSomeHow()

pipeline([
  readable,
  cut() // Default max size is 1024 * 1024 bytes
  // ...Other streams in the pipeline here
], error => {
  if (error) {
    if (error.message === 'Maximum size reached') {
      console.error('File exceeded size limit')
    }
  }
})
```

## API

### cut([options])

> create a new validator

* **options:** `Object`. Configuration options.
   * **options.size:** `Number`. The maximum number of bytes that are allowed to flow in the stream.
   * **options.*:** See [stream.Transform options](https://nodejs.org/dist/latest-v12.x/docs/api/stream.html#stream_new_stream_transform_options).

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