# expo-asset-utils

> Utilities for converting files into Expo Assets

Latest version **3.0.0** (published 2021-09-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install expo-asset-utils
pnpm add expo-asset-utils
yarn add expo-asset-utils
bun add expo-asset-utils
```

## 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 | 3.0.0 |
| Published | 2021-09-30 |
| First published | 2018-01-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 11.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 44 |
| Author | Evan Bacon |
| Maintainers | fiber-god, ide, brentvatne, ccheever, evanbacon, quinlanj, esamelson, expoadmin, charliecruzan, tsapeta, dsokal, tcdavis, exponent, wschurman, bbarthec, jkhales, wkozyra, bycedric, lukmccall, jonsamp, princefleaswallow, andyboythekid, kudochien |
| Keywords | expo, asset, utils, react-native, react |

## Links

- npm: https://www.npmjs.com/package/expo-asset-utils
- Repository: https://github.com/expo/expo-asset-utils
- Homepage: https://github.com/expo/expo-asset-utils#readme
- Issues: https://github.com/expo/expo-asset-utils/issues
- npm.io page: https://npm.io/package/expo-asset-utils

## 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

- 3.0.0 (latest) — 2021-09-30
- 2.0.0 — 2021-01-19
- 1.2.0 — 2019-08-02
- 1.1.1 — 2019-04-23
- 1.1.0 — 2019-04-21
- 1.0.0 — 2019-01-17
- 0.0.5 — 2018-08-06
- 0.0.4-alpha.3 — 2018-07-29
- 0.0.4-alpha.2 — 2018-03-01
- 0.0.4-alpha.1 — 2018-03-01
- 0.0.4-alpha.0 — 2018-01-30
- 0.0.3 — 2018-01-25
- 0.0.2 — 2018-01-21
- 0.0.1 — 2018-01-21
- 0.0.0 — 2018-01-06

## README

# expo-asset-utils

> This package is no longer required for parsing assets, use [`expo-asset`](https://www.npmjs.com/package/expo-asset) and [`expo-file-system`](https://www.npmjs.com/package/expo-file-system) instead.

# [expo-asset-utils](https://snack.expo.io/@bacon/expo-asset-utils-example)

### Installation

```bash
yarn add expo-asset-utils
```

### Usage

Import the library into your JavaScript file:

```ts
import * as AssetUtils from 'expo-asset-utils';
```

## Functions

### resolveAsync

Given a reference to some asset, this will return a promise that resolves to an Expo.Asset that has been cached.

- Expo asset: `Expo.Asset.fromModule(require('./image.png'))`
- static resource: `require('./image.png')`
- remote image: `'https://upload.wikimedia.org/wikipedia/en/1/17/Batman-BenAffleck.jpg'`
- local file: `'file:///var/image.png'`
- asset library file: `'asset-library:///var/image.png'`
- React Native Image source: `{uri: 'https://upload.wikimedia.org/wikipedia/en/1/17/Batman-BenAffleck.jpg'}`

| Property      |                       Type                        | Description                                      |
| ------------- | :-----------------------------------------------: | ------------------------------------------------ |
| fileReference | `Expo.Asset`, `number`, `string`, `{uri: string}` | This will resolve into a downloaded `Expo.Asset` |

### base64forImageUriAsync

Given a image URI `string`, this will return a base64 encoded string and the image size: `{ data: string, size: { width: number, height: number } }`

| Property |   Type   | Description                          |
| -------- | :------: | ------------------------------------ |
| uri      | `string` | This URI will be converted to base64 |

### uriAsync

> Deprecated: Use `(await resolveAsync()).localUri`

### fromUriAsync

> Deprecated: Use `Asset.fromURI('...')` from `expo-asset`

### arrayFromObject

> Deprecated

### cacheAssetsAsync

> Deprecated

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