# array-envelop

> Wraps an array-like object to an array

Latest version **1.0.2** (published 2018-07-22) · ISC license · 0 weekly downloads

## Install

```sh
npm install array-envelop
pnpm add array-envelop
yarn add array-envelop
bun add array-envelop
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2018-07-22 |
| First published | 2018-07-22 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 3.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Kagami Sascha Rosylight |
| Maintainers | saschanaz |
| Keywords | array, iterable |

## Links

- npm: https://www.npmjs.com/package/array-envelop
- Repository: https://github.com/saschanaz/array-envelop
- Homepage: https://github.com/saschanaz/array-envelop#readme
- Issues: https://github.com/saschanaz/array-envelop/issues
- npm.io page: https://npm.io/package/array-envelop

## Dependencies (1)

- [esm](https://npm.io/package/esm.md) ^3.0.72

## Recent versions

- 1.0.2 (latest) — 2018-07-22
- 1.0.1 — 2018-07-22
- 1.0.0 — 2018-07-22

## README

# array-envelop [![npm version](https://badge.fury.io/js/array-envelop.svg)](https://badge.fury.io/js/array-envelop)

This wraps an array-like object to an array so that every array method can be utilized. Try yourself via [RunKit](https://npm.runkit.com/array-envelop).

```js
import { envelop } from "array-envelop";

const object = {
  0: "maya",
  1: "eve",
  length: 2
};

const enveloped = envelop(object);
enveloped.indexOf("eve"); // returns 1

/*
 * Anything that mutates the array will throw, including the followings:
 *
 * enveloped.length = "peanut";
 * enveloped.push("peanut");
 * enveloped.pop();
 * enveloped.shift();
 */
```

### Why not `Array.from`?

`Array.from` copies everything while `array-envelop` keeps refering to the original object.

```js
object[2] = "aya";
object.length = 3;

enveloped.join(" "); // "maya eve aya"
```

```js
const liveNodeList = document.getElementsByTagtName("div");

envelop(liveNodeList); // a live array that changes as the document structure does
```

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