Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gyumeijie/arrify
convert a value to an array
https://github.com/gyumeijie/arrify
array arrify convert npm-package utility
Last synced: 10 days ago
JSON representation
convert a value to an array
- Host: GitHub
- URL: https://github.com/gyumeijie/arrify
- Owner: Gyumeijie
- Created: 2019-05-04T10:12:20.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-05-13T10:04:58.000Z (almost 6 years ago)
- Last Synced: 2025-01-08T04:37:12.147Z (about 1 month ago)
- Topics: array, arrify, convert, npm-package, utility
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/arraify
- Size: 7.81 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# arraify [![](https://travis-ci.com/Gyumeijie/arrify.svg?branch=master)](https://travis-ci.com/Gyumeijie/arrify)
> Convert a value to an array
## Install
```
$ npm install arraify
```## Usage
```js
const arrify = require('arraify');const obj = {
0: 'zero',
1: 'one',
length: 2,
};
arrify(obj);
// ['zero', 'one']const obj = {
0: 'zero',
1: 'one',
length: 3,
};arrify.config.arraySimilarity = 2;
arrify(obj);
// [{ 0: 'zero', 1: 'one', length: 3 }]
arrify.config.arraySimilarity = 1;
arrify(obj);
// [{ 0: 'zero', 1: 'one', length: 3 }]arrify.config.arraySimilarity = 0;
arrify(obj);
// ['zero', 'one', undefined]arrify(1, 2, 3);
// [1, 2, 3]arrify('string');
// ['s', 't', 'r', 'i', 'n', 'g']arrify.config.splitString = false;
arrify('string');
// ['sting']arrify([]);
// []arrify();
// []arrify(null);
// []arrify(undefined);
// []
```## Configs
```javascript
arrify.config = {
splitString: true,
arraySimilarity: 2,
};
```
splitString:
>true | false, defaults to `true`[arraySimilarity](https://github.com/Gyumeijie/isArrayLike):
> 0 | 1 | 2, defaults to `2`## License
MIT © [Gyumeijie](https://github.com/Gyumeijie)