# newify

> Call function constructors with an array of arguments that spread

Latest version **1.1.9** (published 2014-07-22) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.9 |
| Published | 2014-07-22 |
| First published | 2014-07-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Radu Brehar |
| Maintainers | radubrehar |
| Keywords | new, constructor, arguments, create, new, object, spread, instantiate |

## Links

- npm: https://www.npmjs.com/package/newify
- Repository: https://github.com/radubrehar/newify
- Issues: https://github.com/radubrehar/newify/issues
- npm.io page: https://npm.io/package/newify

## Alternatives

- [csv-to-markdown-table](https://npm.io/package/csv-to-markdown-table.md) — 47.0K weekly downloads
- [@sapphire/ratelimits](https://npm.io/package/@sapphire/ratelimits.md) — 4.4K weekly downloads
- [js-csvparser](https://npm.io/package/js-csvparser.md) — 2.0K weekly downloads
- [@adadapted/js-sdk](https://npm.io/package/@adadapted/js-sdk.md) — 251 weekly downloads
- [@grapecity/spread-sheets-sparklines](https://npm.io/package/@grapecity/spread-sheets-sparklines.md) — 103 weekly downloads

## Recent versions

- 1.1.9 (latest) — 2014-07-22
- 1.1.8 — 2014-07-22
- 1.1.7 — 2014-07-22
- 1.1.6 — 2014-07-22
- 1.1.3 — 2014-07-21
- 1.1.2 — 2014-07-18
- 1.1.1 — 2014-07-18
- 1.1.0 — 2014-07-18
- 1.0.0 — 2014-07-18

## README

# Purpose

Calling function constructors with an array of arguments is difficult. Until [spread](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator) params are fully supported in all browsers, newify does the job.

For a given function constructor
```js
function Student(firstName, lastName, birthYear){
	this.firstName = firstName
	this.lastName = lastName
	this.birthYear = birthYear
}
```

We want to easily call the function constructor like

```js
var arr = ['john','scot', 1980]
var s = new Student(arr) //but this will obviously not work as expected.

//we need ES6 spread
var s = new Student(...arr)
```

But since we can't use spread in ES5 ...

NEWIFY to the rescue!

```js
var arr = ['john','scot', 1980]
var s = require('newify')(Student, arr)
```

# Installation

```
npm install newify
```

# Usage

As in the above example, just give `newify` a function and an array of args

```js
var arr = ['john','scot', 1980]
var s = require('newify')(Student, arr)
```

# Run tests

```
make test
```

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