# @writetome51/set-array

> Assigns an entirely new value to an array without breaking its memory reference

Latest version **2.0.2** (published 2020-09-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install @writetome51/set-array
pnpm add @writetome51/set-array
yarn add @writetome51/set-array
bun add @writetome51/set-array
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.2 |
| Published | 2020-09-08 |
| First published | 2018-10-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Steve Thompson |
| Maintainers | writetome51 |
| Keywords | array, set, assign, reassign, value, manipulation |

## Links

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

## Dependencies (1)

- [error-if-values-are-not-arrays](https://npm.io/package/error-if-values-are-not-arrays.md) >=2.0.1

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 2.0.2 (latest) — 2020-09-08
- 2.0.1 — 2020-08-11
- 2.0.0 — 2020-07-28
- 1.0.2 — 2019-02-23
- 1.0.1 — 2018-12-04
- 1.0.0 — 2018-10-30

## README

# setArray(array, newValue: any[]): void

Sets `array` to a `newValue` without breaking its memory reference.  
It's a much better alternative to doing this:
```
array = newValue; // this breaks the memory reference.
```


## Examples
```
arr = [1,2,3,4,5];
arrCopy = arr;
arr = [3,4,5,6,7]; // But does arrCopy get updated too?

console.log(arrCopy);
 --> [1,2,3,4,5] // no it doesn't.
 
// But what if you need arrCopy to stay in-sync with arr? 
// Change the value of arr using setArray() instead:
setArray(arr, [3,4,5,6,7]);

console.log(arrCopy);
--> [3,4,5,6,7]; // Success!!
```

## Installation
`npm i @writetome51/set-array`

## Loading
```js
import { setArray } from '@writetome51/set-array';
```

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