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.

15 lines (14 loc) 393 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); 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; } exports.compact = compact;