You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					40 lines
				
				543 B
			
		
		
			
		
	
	
					40 lines
				
				543 B
			| 
								 
											2 years ago
										 
									 | 
							
								# arrify [](https://travis-ci.org/sindresorhus/arrify)
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								> Convert a value to an array
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								## Install
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								```
							 | 
						||
| 
								 | 
							
								$ npm install arrify
							 | 
						||
| 
								 | 
							
								```
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								## Usage
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								```js
							 | 
						||
| 
								 | 
							
								const arrify = require('arrify');
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								arrify('🦄');
							 | 
						||
| 
								 | 
							
								//=> ['🦄']
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								arrify(['🦄']);
							 | 
						||
| 
								 | 
							
								//=> ['🦄']
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								arrify(new Set(['🦄']));
							 | 
						||
| 
								 | 
							
								//=> ['🦄']
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								arrify(null);
							 | 
						||
| 
								 | 
							
								//=> []
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								arrify(undefined);
							 | 
						||
| 
								 | 
							
								//=> []
							 | 
						||
| 
								 | 
							
								```
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								*Supplying `null` or `undefined` results in an empty array.*
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								## License
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								MIT © [Sindre Sorhus](https://sindresorhus.com)
							 |