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/20201220220354/https://github.com/lodash/lodash/blob/master/compact.js
Permalink
Cannot retrieve contributors at this time
30 lines (27 sloc)
598 Bytes
/**
* Creates an array with all falsey values removed. The values `false`, `null`,
* `0`, `""`, `undefined`, and `NaN` are falsey.
*
* @since 0.1.0
* @category Array
* @param {Array } array The array to compact.
* @returns {Array } Returns the new array of filtered values.
* @example
*
* compact([0, 1, false, 2, '', 3])
* // => [1, 2, 3]
*/
function compact ( array ) {
let resIndex = 0
const result = [ ]
if ( array == null ) {
return result
}
for ( const value of array ) {
if ( value ) {
result [ resIndex ++ ] = value
}
}
return result
}
export default compact
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.