# chunkinator

> Upload large files from the browser with ease

Latest version **2.0.5** (published 2018-05-23) · Apache-2.0 license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install chunkinator
pnpm add chunkinator
yarn add chunkinator
bun add chunkinator
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.0.5 |
| Published | 2018-05-23 |
| First published | 2018-02-11 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 23.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Atlassian Pty Ltd |
| Maintainers | amotsjonov-atlassian, dijimsta, zzarcon |

## Links

- npm: https://www.npmjs.com/package/chunkinator
- Repository: https://bitbucket.org/hzarcogarcia/chunkinator
- Homepage: https://bitbucket.org/hzarcogarcia/chunkinator#readme
- npm.io page: https://npm.io/package/chunkinator

## Dependencies (3)

- [rxjs](https://npm.io/package/rxjs.md) ^5.5.6
- [tslib](https://npm.io/package/tslib.md) ^1.8.0
- [rxjs-async-map](https://npm.io/package/rxjs-async-map.md) ^0.1.2

## Recent versions

- 2.0.5 (latest) — 2018-05-23
- 2.0.4 — 2018-05-22
- 2.0.2 — 2018-05-04
- 1.0.3 — 2018-05-03
- 1.0.1 — 2018-04-13
- 1.0.0 — 2018-04-09
- 0.0.15 — 2018-02-19
- 0.0.14 — 2018-02-19
- 0.0.13 — 2018-02-16
- 0.0.12 — 2018-02-13
- 0.0.11 — 2018-02-13
- 0.0.10 — 2018-02-12
- 0.0.6 — 2018-02-12
- 0.0.5 — 2018-02-12
- 0.0.4 — 2018-02-11

## README

# chunkinator
Upload large files from the browser with ease

# Pipeline pieces description

See `examples/integrator.ts` for good example of usage. 

```Javascript
import chunkinator from 'chunkinator';
```

`chunkinator` is a main customizable high level component that gives you a way to upload large files.
It takes a file as an input and pushes it through Observable pipe that consist of the following parts:

- `slicenator`
- `hashinator`
- `probinator`
- `uploadinator`
- `processinator`

As a second argument `chunkinator` takes configuration options with following interface:

```Typescript
interface Options {
  chunkSize: number;
  hashingConcurrency: number;
  hashingFunction?: HashingFunction;
  probingBatchSize: number;
  probingFunction: ProbingFunction;
  uploadingConcurrency: number;
  uploadingFunction: UploadingFunction;
  processingBatchSize: number;
  processingFunction?: ProcessingFunction;
}
```

As a third argument `chunkinator` takes list of handy callbacks. Currently there is only one: `onProgress`.

## slicenator

This component takes a blob, chunk size and returns Observable sequential stream of blob chunks. 

Options' `chunkSize` is what defines chunk size

## hashinator

This component takes stream of blobs and hashes each chunk. Returning stream contains blob and it's hash.

Options' `hashingConcurrency` defines how many
chunks are hashed at the same time. `hashingFunction` is optional hashing function. If `hashingFunction` is not 
provided `SHA-1` will be used instead.

## probinator

This component takes already hashed blobs and probes each of them with backend for it already being uploaded. 
Resulting stream contains blob with hash and boolean indicating if it exists on a backend already. 

Options' `probingFunction` is a function that takes batch of hashed blobs and returns list of booleans.
`probingBatchSize` controls how many hashed blobs are given to probing function at a time.

## uploadinator

This component takes probed and hashed blobs and uploads them if blob doesn't exists on a backend.

Options' `uploadingFunction` is a callback that takes a blob and uploads it to the server. 
`uploadingConcurrency` controls how many of these calls happens at the same time.

## processinator

With this component consumer has an opportunity to finalize already uploaded chunks in some way.

Options' `processingFunction` defines a function that is called with sequential batches of uploaded chunks.
`processingBatchSize` controls how many uploaded chunks are given to processing function.


## onProgress callback

This callback is called with every uploaded chunk. The only argument it is called with a portion of already 
uploaded chunks to it's total number.

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