UNPKG

@spacet.me/chain

Version:

Like `_.chain` but only contains `thru` and `value` methods. Comes with TypeScript typings.

60 lines 1.63 kB
"use strict"; /** * This package implements a subset of Lodash’s `_.chain()`, * containing just the {@link https://lodash.com/docs/4.17.11#thru | thru} * and {@link https://lodash.com/docs/4.17.11#prototype-value | value} methods. * To use this package, look at the {@link chain} function. * * @packageDocumentation */ Object.defineProperty(exports, "__esModule", { value: true }); exports.chain = exports.Chain = void 0; /** * A Chain object, created through the {@link chain} function. * @public */ var Chain = /** @class */ (function () { /** * @internal */ function Chain(__wrapped__) { this.__wrapped__ = __wrapped__; } /** * Apply a function to the value of the chain. */ Chain.prototype.thru = function (interceptor) { return new Chain(interceptor(this.__wrapped__)); }; /** * Returns the value of the chain. */ Chain.prototype.value = function () { return this.__wrapped__; }; /** * Returns the value of the chain, for seamless usage with `JSON.stringify()`. */ Chain.prototype.toJSON = function () { return this.__wrapped__; }; /** * Returns the value of the chain, for seamless usage comparison operators. */ Chain.prototype.valueOf = function () { return this.__wrapped__; }; return Chain; }()); exports.Chain = Chain; /** * Creates a {@link Chain} object. * @param value - The value to wrap. * @returns A {@link Chain} object. * @public */ function chain(value) { return new Chain(value); } exports.chain = chain; //# sourceMappingURL=index.js.map