COLLECTED BY
Organization:
Internet Archive
Focused crawls are collections of frequently-updated webcrawl data from narrow (as opposed to broad or wide) web crawls, often focused on a single domain or subdomain.
The Wayback Machine - https://web.archive.org/web/20201220220230/https://github.com/lodash/lodash/blob/master/castArray.js
Permalink
Cannot retrieve contributors at this time
41 lines (39 sloc)
685 Bytes
/**
* Casts `value` as an array if it's not one.
*
* @since 4.4.0
* @category Lang
* @param {* } value The value to inspect.
* @returns {Array } Returns the cast array.
* @example
*
* castArray(1)
* // => [1]
*
* castArray({ 'a': 1 })
* // => [{ 'a': 1 }]
*
* castArray('abc')
* // => ['abc']
*
* castArray(null)
* // => [null]
*
* castArray(undefined)
* // => [undefined]
*
* castArray()
* // => []
*
* const array = [1, 2, 3]
* console.log(castArray(array) === array)
* // => true
*/
function castArray ( ...args ) {
if ( !args . length ) {
return [ ]
}
const value = args [ 0 ]
return Array . isArray ( value ) ? value : [ value ]
}
export default castArray
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.