(items, fn, includeNull)
| 276 | |
| 277 | // a version of Array.map that doesn't require an array, i.e. works on arrays and scalars. |
| 278 | function __map(items, fn, includeNull) { |
| 279 | // whether to return nulls in array of results; default = true; |
| 280 | includeNull = includeNull == null ? true : includeNull; |
| 281 | if (items == null) return items; |
| 282 | var result; |
| 283 | if (Array.isArray(items)) { |
| 284 | result = []; |
| 285 | items.forEach(function (v, ix) { |
| 286 | var r = fn(v, ix); |
| 287 | if (r != null || includeNull) { |
| 288 | result[ix] = r; |
| 289 | } |
| 290 | }); |
| 291 | } else { |
| 292 | result = fn(items); |
| 293 | } |
| 294 | return result; |
| 295 | } |
| 296 | |
| 297 | |
| 298 | function __arrayFirst(array, predicate) { |
no outgoing calls
no test coverage detected