UNPKG

@wesjet/function.js

Version:
21 lines (20 loc) 471 B
/** * Copyright (c) Wesbitty, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * */ export class SingleItem { constructor(item) { this.item = item; } map(fn) { return new SingleItem(fn(this.item)); } filter(fn) { return fn(this.item) ? this : new SingleItem(undefined); } } export const singleItem = (item) => new SingleItem(item);