# object-extract

> Extract object key-value pairs as variables to a specified context.

Latest version **0.1.0** (published 2015-11-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install object-extract
pnpm add object-extract
yarn add object-extract
bun add object-extract
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2015-11-30 |
| First published | 2015-11-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Marin Atanasov |
| Maintainers | tyxla |
| Keywords | object, key, value, extract, pair, var, variable, context, import |

## Links

- npm: https://www.npmjs.com/package/object-extract
- Repository: https://github.com/tyxla/object-extract
- Issues: https://github.com/tyxla/object-extract/issues
- npm.io page: https://npm.io/package/object-extract

## Recent versions

- 0.1.0 (latest) — 2015-11-30

## README

# object-extract

Extract object key-value pairs as variables to a specified context.

```
npm install object-extract
```

[![Build Status](https://travis-ci.org/tyxla/object-extract.svg)](https://travis-ci.org/tyxla/object-extract)

## About

This will assign each property of the specified object as a variable in the specified context.

When assigning, the property key is used for the variable name, and the property value is used for the variable value.

## Syntax

``` js
objectExtract(objectToExtract, context);
```

#### objectToExtract

This is the object that you wish to extract to the specified context.

#### context

This is the context you wish to extract the object to. If not specified, variables will be assigned to the global scope.

## Usage

Pass the object you want to extract, and the context object you want it to get extracted to.

``` js
var obj = {
	test: 123
};

objectExtract({
	example: 456
}, obj);

console.log(obj);
/*
{
	test: 123,
	example: 456
}
*/

```

In case you want to extract the object in the global scope, omit the `context` parameter.

``` js
objectExtract({
	example: 456
});

console.log(example);
/*
456
*/
```

## License

MIT

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