UNPKG

@sevinf/maybe

Version:

Maybe/Optional type implementation in Typescript. Main motivation for creating this library was handling `null` values in deeply nested data, coming from GraphQL APIs, but the library itself is not limited to GraphQL.

12 lines (11 loc) 296 B
export function compact(items) { var result = []; for (var _i = 0, items_1 = items; _i < items_1.length; _i++) { var item = items_1[_i]; var unpacked = item.orNull(); if (unpacked !== null) { result.push(unpacked); } } return result; }