# ublob

> Helper module for working with files.

Latest version **1.0.1** (published 2023-10-16) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2023-10-16 |
| First published | 2022-08-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=8.0.0 |
| Dependencies | 0 |
| Unpacked size | 12.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Martik Avagyan |
| Maintainers | m-avagyan |
| Keywords | npm, yarn, module, javascript, react, files, blob, base64, browser, easy, easy-to-use, open-in-browser, open-in-new-tab |

## Links

- npm: https://www.npmjs.com/package/ublob
- Repository: https://github.com/m-avagyan/ublob
- Homepage: https://github.com/m-avagyan/ublob#readme
- Issues: https://github.com/m-avagyan/ublob/issues
- npm.io page: https://npm.io/package/ublob

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2023-10-16
- 1.0.0 — 2023-10-15
- 0.1.0 — 2022-08-07
- 0.0.9 — 2022-08-07
- 0.0.8 — 2022-08-07
- 0.0.7 — 2022-08-07
- 0.0.6 — 2022-08-07
- 0.0.5 — 2022-08-07
- 0.0.4 — 2022-08-07
- 0.0.3 — 2022-08-07
- 0.0.2 — 2022-08-07
- 0.0.1 — 2022-08-07

## README

# ublob

Helper module for working with files.

## Installation

```bash
npm install ublob --save
```

or

```bash
yarn add ublob
```

## Usage

- `toBase64`: convert file to base 64 string

```typescript
import { toBase64 } from "ublob";

toBase64(file)
  .catch((error) => console.log(error))
  .then((blob) =>
    // set blob data...
  );
```

- `getFileType`: getting the file type

```typescript
import { getFileType, toBase64 } from "ublob";

toBase64(file)
  .catch((error) => console.log(error))
  .then((blob) =>
    const fileType = getFileType(blob);
    // set file type to your state
  );
```

- `open`: open blob url in browser new tab

```typescript
import { open } from "ublob";

const handleOpen = (blob) =>
  open(blob, {
    title: "Ublob PDF",
    width: "100%",
    height: "100%",
  });
```

- `getAvailableFileTypes`: getting the available file types

```typescript
import { getAvailableFileTypes } from "ublob";

const availableFileTypes = getAvailableFileTypes();
// use this list where you want
```

## Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

## Author

**Martik Avagyan**

- Website: [martikavagyan.com](https://martikavagyan.com)
- Twitter: [@martikavagyan](https://twitter.com/martikavagyan)
- GitHub: [@m-avagyan](https://github.com/m-avagyan)

## License

[MIT](https://choosealicense.com/licenses/mit/)

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