# assign-properties

> An Object.assign like utility that preserve descriptors

Latest version **0.1.1** (published 2020-02-14) · ISC license · 0 weekly downloads

## Install

```sh
npm install assign-properties
pnpm add assign-properties
yarn add assign-properties
bun add assign-properties
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2020-02-14 |
| First published | 2020-02-13 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 6.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Andrea Giammarchi |
| Maintainers | webreflection |
| Keywords | Object, assign, descriptors, properties |

## Links

- npm: https://www.npmjs.com/package/assign-properties
- npm.io page: https://npm.io/package/assign-properties

## Dependencies (2)

- [@ungap/assign](https://npm.io/package/@ungap/assign.md) ^0.1.0
- [@ungap/get-own-property-descriptors](https://npm.io/package/@ungap/get-own-property-descriptors.md) ^1.0.0

## Recent versions

- 0.1.1 (latest) — 2020-02-14
- 0.1.0 — 2020-02-13
- 0.0.0 — 2020-02-13

## README

# assignProperties

[![Build Status](https://travis-ci.com/WebReflection/assign-properties.svg?branch=master)](https://travis-ci.com/WebReflection/assign-properties) [![Coverage Status](https://coveralls.io/repos/github/WebReflection/assign-properties/badge.svg?branch=master)](https://coveralls.io/github/WebReflection/assign-properties?branch=master) ![WebReflection status](https://offline.report/status/webreflection.svg)

An [Object.assign](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) like utility that preserve descriptors, as in accessors or value, or configurable, or writable, etc.

```js
import assignProperties from 'assign-properties';
const assignProperties = require('assign-properties');
// <script src="https://unpkg.com/assign-properties">
```

## Same [Object.assign](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) API

```js
// the issue with assign is that copies are values
const before = Object.assign({}, {get random() { return Math.random() }});

// mixins are broken this way
before.random === before.random; // true

// with assignProperties, everything is fine
const after = assignProperties({}, {get random() { return Math.random() }});

// the getter is passed along instead of being lost in the process
after.random === after.random; // false
```

### Object spread suffers the same issue
```js
const base = {get random() { return Math.random() }};
const spread = {...base};
spread.random === spread.random; // true
```

So, if you want to bring accessors to the mix, this module is your stop.

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