UNPKG

@connectv/core

Version:

agent-based reactive programming library for typescript/javascript

63 lines 2.31 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); var operators_1 = require("rxjs/operators"); var emission_1 = __importDefault(require("../shared/emission")); var random_tag_1 = __importDefault(require("../util/random-tag")); var pipe_1 = require("./pipe"); var _DefaultForkTagLength = 10; /** * * Represents [fork](https://connective.dev/docs/fork) pins. * */ var Fork = /** @class */ (function (_super) { __extends(Fork, _super); function Fork(len) { if (len === void 0) { len = _DefaultForkTagLength; } return _super.call(this, [ operators_1.map(function (e) { var __fork = [].concat(e.context.__fork || []); __fork.push(Fork._create_fork_tag(len)); return emission_1.default(e.value, Object.assign({}, e.context, { __fork: __fork })); }), operators_1.share(), ]) || this; } Fork._create_fork_tag = function (len) { if (len === void 0) { len = _DefaultForkTagLength; } return random_tag_1.default(len); }; return Fork; }(pipe_1.Pipe)); exports.Fork = Fork; /** * * Creates a [fork](https://connective.dev/docs/fork) pin. * [Checkout the docs](https://connective.dev/docs/fork) for examples and further information. * * @param len the length of the fork-tag that will be added to the context of each emission. * */ function fork(len) { if (len === void 0) { len = _DefaultForkTagLength; } return new Fork(len); } exports.fork = fork; exports.default = fork; //# sourceMappingURL=fork.js.map