# center-js

> CenterJS is a framework for NPM scripts with JS or ECMAScript.

**CenterJS includes obsolete builds for core-js if you would rather install that way.**



### NPM installation

CenterJS is on NPM for your Javascript scripts and ECMAScript. Run the following code in a desired directory.

`npm i center-js`

CenterJS is up and ready.
---

Example of usage:
```js
import 'center-js'; // <- at the top of your entry point

Array.from(new Set([1, 2, 3, 2, 1]));          // => [1, 2, 3]
[1, [2, 3], [4, [5]]].flat(2);                 // => [1, 2, 3, 4, 5]
Promise.resolve(32).then(x => console.log(x)); // => 32
```

*You can load only required features*:
```js
import 'center-js/features/array/from'; // <- at the top of your entry point
import 'center-js/features/array/flat'; // <- at the top of your entry point
import 'center-js/features/set';        // <- at the top of your entry point
import 'center-js/features/promise';    // <- at the top of your entry point

Array.from(new Set([1, 2, 3, 2, 1]));          // => [1, 2, 3]
[1, [2, 3], [4, [5]]].flat(2);                 // => [1, 2, 3, 4, 5]
Promise.resolve(32).then(x => console.log(x)); // => 32
```

*Or use it without global namespace pollution*:
```js
import from from 'center-js-pure/features/array/from';
import flat from 'center-js-pure/features/array/flat';
import Set from 'center-js-pure/features/set';
import Promise from 'center-js-pure/features/promise';

from(new Set([1, 2, 3, 2, 1]));                // => [1, 2, 3]
flat([1, [2, 3], [4, [5]]], 2);                // => [1, 2, 3, 4, 5]
Promise.resolve(32).then(x => console.log(x)); // => 32
```
