Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@-0/spool

Package Overview
Dependencies
Maintainers
1
Versions
119
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@-0/spool - npm Package Compare versions

Comparing version 0.2.92 to 0.2.93

2

lib/core/multiplex.d.ts
import { Subscription, PubSub } from "@thi.ng/rstream";
export declare const multiplex: (out$: any) => (task_array: any) => any;
export declare const run$: PubSub<any, any>;

@@ -6,2 +7,1 @@ export declare const out$: PubSub<any, any>;

export declare const task$: Subscription<any, any>;
export declare function multiplex(task_array: any): any;

@@ -10,3 +10,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

};
import { isFunction, isPromise } from "@thi.ng/checks";
import { isFunction, isPromise, isArray } from "@thi.ng/checks";
import { pubsub } from "@thi.ng/rstream";

@@ -17,20 +17,2 @@ import { CMD_SUB$, CMD_ARGS, CMD_RESO, CMD_ERRO, CMD_SRC$, CMD_WORK } from "@-0/keys";

const log = console.log;
export const run$ = pubsub({
topic: x => !!x[CMD_SUB$],
id: "run$_stream",
equiv: (res, tpc) => res === tpc || tpc == "_TRACE_STREAM"
});
export const out$ = pubsub({
topic: x => x[CMD_SUB$],
id: "out$_stream",
equiv: (res, tpc) => res === tpc || tpc == "_TRACE_STREAM"
});
export const cmd$ = run$.subscribeTopic(true, {
next: x => out$.next(x),
error: console.warn
}, { id: "cmd$_stream" });
export const task$ = run$.subscribeTopic(false, {
next: multiplex,
error: console.warn
}, { id: "task$_stream" });
const err_str = "Spooling Interupted";

@@ -47,5 +29,13 @@ const nosub$_err = (c, i) => console.warn(`

Hope that helps!
`);
export function multiplex(task_array) {
return task_array.reduce((a, c, i) => __awaiter(this, void 0, void 0, function* () {
`);
const task_not_array_error = x => `
You may have either:
1. Tried to run a Command that has no \`${CMD_ARGS}\` key (and thus does nothing)
2. Tried to run a Sub/Task that is not in [] (Array) form
Please check this payload for issues:
${JSON.stringify(x)}
`;
export const multiplex = out$ => task_array => isArray(task_array)
? task_array.reduce((a, c, i) => __awaiter(void 0, void 0, void 0, function* () {
let acc = yield a;

@@ -56,3 +46,3 @@ if (isFunction(c)) {

recur.unshift({ [CMD_ARGS]: acc });
return multiplex(recur);
return multiplex(out$)(recur);
}

@@ -120,4 +110,3 @@ catch (e) {

}
acc === null ||
console.warn(`no \`erro\` (Error) handler set for ${sub$ || "error"} ${result}`);
acc === null || console.warn(`no \`erro\` (Error) handler set for ${sub$ || "error"} ${result}`);
return acc;

@@ -143,3 +132,23 @@ }

return Object.assign(Object.assign({}, acc), result);
}), Promise.resolve({}));
}
}), Promise.resolve({}))
: (() => {
throw new Error(task_not_array_error(task_array));
})();
export const run$ = pubsub({
topic: x => !!x[CMD_ARGS],
id: "run$_stream",
equiv: (res, tpc) => res === tpc || tpc == "_TRACE_STREAM"
});
export const out$ = pubsub({
topic: x => x[CMD_SUB$],
id: "out$_stream",
equiv: (res, tpc) => res === tpc || tpc == "_TRACE_STREAM"
});
export const cmd$ = run$.subscribeTopic(true, {
next: x => out$.next(x),
error: console.warn
}, { id: "cmd$_stream" });
export const task$ = run$.subscribeTopic(false, {
next: multiplex(out$),
error: console.warn
}, { id: "task$_stream" });

@@ -18,2 +18,13 @@ import { map } from "@thi.ng/transducers";

const err_str = "command Registration `registerCMD`";
const no_work_or_src_error = `
Error registering ${CMD_SUB$}:
Commands with no \`${CMD_WORK}\` & no \`${CMD_SRC$}\` handler
can/need not be registered:
- \`${CMD_WORK}\`: registers side-effecting handlers
- \`${CMD_SRC$}\`: registers upstream Command producers
if your Command is for data acquisition/transformation,
you can run$.next(YOUR_COMMAND) without registration.
`;
export const registerCMD = (command = null) => {

@@ -26,2 +37,5 @@ const sub$ = command[CMD_SUB$];

const work = command[CMD_WORK];
if (!work && !src$) {
throw new Error(no_work_or_src_error);
}
const knowns = [CMD_SUB$, CMD_ARGS, CMD_RESO, CMD_ERRO, CMD_SRC$, CMD_WORK];

@@ -56,4 +70,4 @@ const [unknowns] = diff_keys(knowns, command);

error: console.warn
}, map(puck => puck[CMD_ARGS]));
}, map(x => x[CMD_ARGS]));
return CMD;
};

@@ -5,3 +5,3 @@ {

"license": "MIT",
"version": "0.2.92",
"version": "0.2.93",
"description": "SPA framework built on top of http://thi.ng/umbrella ecosystem",

@@ -44,4 +44,4 @@ "main": "./lib/index.js",

"dependencies": {
"@-0/keys": "^0.2.85",
"@-0/utils": "^0.2.82"
"@-0/keys": "^0.2.86",
"@-0/utils": "^0.2.83"
},

@@ -59,4 +59,4 @@ "devDependencies": {

"@types/node": "^14.14.22",
"@typescript-eslint/eslint-plugin": "^4.14.1",
"@typescript-eslint/parser": "^4.14.1",
"@typescript-eslint/eslint-plugin": "^4.14.2",
"@typescript-eslint/parser": "^4.14.2",
"babel-jest": "^26.6.3",

@@ -63,0 +63,0 @@ "better-docs": "^2.3.2",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc