UNPKG

@actyx/sdk

Version:
53 lines 1.96 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isBoolean = exports.isNumber = exports.isString = exports.pendingEmission = exports.toEventPredicate = void 0; /* * Actyx SDK: Functions for writing distributed apps * deployed on peer-to-peer networks, without any servers. * * Copyright (C) 2021 Actyx AG */ const rxjs_1 = require("../../node_modules/rxjs"); /** * Turn a `Where` into a function that can decide whether a locally emitted event matches the clause. * * We can ignore the 'local' flag since it will never exclude our local events, * and this method is used solely to decide whether locally emitted events are relevant. * * TODO: This will be removed once we support other means of 'I got events up to X' feedback * * @alpha */ const toEventPredicate = (where) => { const tagSets = where.toV1WireFormat(); return (event) => tagSets.some((tagIntersection) => tagIntersection.tags.every((tag) => event.tags.includes(tag))); }; exports.toEventPredicate = toEventPredicate; /** Create a PendingEmission object from an Observable. @internal */ const pendingEmission = (o) => ({ subscribe: o.subscribe.bind(o), toPromise: () => (0, rxjs_1.lastValueFrom)(o), }); exports.pendingEmission = pendingEmission; /** * Refinement that checks whether typeof x === 'string' * @public */ // eslint-disable-next-line @typescript-eslint/no-explicit-any const isString = (x) => typeof x === 'string'; exports.isString = isString; /** * Refinement that checks whether typeof x === 'number' * @public */ // eslint-disable-next-line @typescript-eslint/no-explicit-any const isNumber = (x) => typeof x === 'number'; exports.isNumber = isNumber; /** * Refinement that checks whether typeof x === 'number' * @public */ // eslint-disable-next-line @typescript-eslint/no-explicit-any const isBoolean = (x) => typeof x === 'boolean'; exports.isBoolean = isBoolean; //# sourceMappingURL=functions.js.map