https://github.com/rolandjitsu/rxjs-file
RxJS File utils
https://github.com/rolandjitsu/rxjs-file
arraybuffer file file-reader rxjs typescript
Last synced: about 13 hours ago
JSON representation
RxJS File utils
- Host: GitHub
- URL: https://github.com/rolandjitsu/rxjs-file
- Owner: rolandjitsu
- Created: 2018-08-30T09:35:28.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2020-09-06T04:52:09.000Z (over 5 years ago)
- Last Synced: 2026-03-30T07:59:12.469Z (2 months ago)
- Topics: arraybuffer, file, file-reader, rxjs, typescript
- Language: TypeScript
- Size: 113 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# RxJS File
> A small package with a couple of [File](https://developer.mozilla.org/en-US/docs/Web/API/File) utils for [RxJS](https://rxjs-dev.firebaseapp.com/).
[](https://www.npmjs.com/package/rxjs-file)
[](https://github.com/rolandjitsu/rxjs-file/actions?query=workflow%3ATest)
[](https://coveralls.io/github/rolandjitsu/rxjs-file?branch=master)
# Table of Contents
* [Installation](#installation)
* [Usage](#usage)
* [Contribute](#contribute)
### Installation
----------------
You can install this package from [NPM](https://www.npmjs.com):
```bash
npm add rxjs rxjs-file
```
Or with [Yarn](https://yarnpkg.com/en):
```bash
yarn add rxjs rxjs-file
```
#### CDN
For CDN, you can use [unpkg](https://unpkg.com):
[https://unpkg.com/rxjs-file/dist/bundles/rxjs-file.umd.min.js](https://unpkg.com/rxjs-file/dist/bundles/rxjs-file.umd.min.js)
The global namespace for rxjs-file is `rxjsFile`:
```js
const {toArrayBuffer} = rxjsFile;
toArrayBuffer(file)
.subscribe(buffer => {
// Do something with the buffer
});
```
### Usage
---------
#### ES6
Read a file as [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer):
```ts
import {toArrayBuffer} from 'rxjs-file';
toArrayBuffer(file)
.subscribe(buffer => {
// Do something with the buffer
});
```
Read the file as ArrayBuffer in chunks:
```ts
import {toArrayBuffer} from 'rxjs-file';
toArrayBuffer(file, {chunkSize: 1000 /* bytes */})
.subscribe(chunk => {
// Do something with each chunk
});
```
Read a file as text:
```ts
import {toString} from 'rxjs-file';
toString(file)
.subscribe(str => {
// Do something with the string
});
```
#### CommonJS
Read a file as ArrayBuffer:
```ts
const {toArrayBuffer} = require('rxjs-file');
toArrayBuffer(file)
.subscribe(buffer => {
// Do something with the buffer
});
```
### Contribute
--------------
If you wish to contribute, please use the following guidelines:
* Use [Conventional Commits](https://conventionalcommits.org)
* Use `[ci skip]` in commit messages to skip a build