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

ordu

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ordu - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

12

ordu.d.ts
export { Ordu, LegacyOrdu };
interface OrduIF {
add(t: TaskDef | TaskExec, te?: TaskDef): void;
add(td: TaskDef): void;
add(td: TaskDef[]): void;
add(te: TaskExec): void;
add(te: TaskExec, td: TaskDef): void;
add(te: TaskExec[]): void;
tasks(): Task[];
operator(name: string, opr: Operator): void;
operator(opr: Operator): void;
operators(): object;

@@ -74,7 +79,8 @@ exec(ctx: any, data: any, opts: any): Promise<ExecResult>;

constructor();
operator(name: string, opr: Operator): void;
operator(first: string | Operator, opr?: Operator): void;
operators(): {
[op: string]: Operator;
};
add(taskin: TaskDef | TaskExec, taskextra?: TaskDef): void;
add(first: any, second?: any): void;
private add_task;
exec(ctx: any, data: any, opts: any): Promise<ExecResult>;

@@ -81,0 +87,0 @@ tasks(): Task[];

/* Copyright (c) 2016-2020 Richard Rodger and other contributors, MIT License */
'use strict';
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const Hoek = require("@hapi/hoek");
const Topo = require("@hapi/topo");
class Task {
constructor(taskdef) {
this.id =
null == taskdef.id ? ('' + Math.random()).substring(2) : taskdef.id;
this.name = taskdef.name || 'task' + Task.count;
this.before = strarr(taskdef.before);
this.after = strarr(taskdef.after);
this.exec = taskdef.exec || ((_) => { });
this.if = taskdef.if || void 0;
this.meta = {
order: Task.count++,
when: Date.now(),
// TODO: auto generate call point stacktrace?
from: taskdef.from || {},
};
exports.LegacyOrdu = exports.Ordu = void 0;
const Hoek = __importStar(require("@hapi/hoek"));
const Topo = __importStar(require("@hapi/topo"));
const nua_1 = __importDefault(require("nua"));
let Task = /** @class */ (() => {
class Task {
constructor(taskdef) {
this.id =
null == taskdef.id ? ('' + Math.random()).substring(2) : taskdef.id;
this.name = taskdef.name || 'task' + Task.count;
this.before = strarr(taskdef.before);
this.after = strarr(taskdef.after);
this.exec = taskdef.exec || ((_) => { });
this.if = taskdef.if || void 0;
this.meta = {
order: Task.count++,
when: Date.now(),
// TODO: auto generate call point stacktrace?
from: taskdef.from || {},
};
}
}
}
Task.count = 0;
Task.count = 0;
return Task;
})();
// Use the constructor to normalize task result

@@ -43,7 +70,7 @@ class TaskResult {

stop: (tr, _, data) => {
Hoek.merge(data, tr.out);
nua_1.default(data, tr.out, { preserve: true });
return { stop: true, err: tr.err };
},
merge: (tr, _, data) => {
Hoek.merge(data, tr.out);
nua_1.default(data, tr.out, { preserve: true });
return { stop: false };

@@ -53,4 +80,5 @@ },

}
operator(name, opr) {
this.operator_map[name] = opr;
operator(first, opr) {
let name = 'string' === typeof first ? first : first.name;
this.operator_map[name] = opr || first;
}

@@ -60,26 +88,25 @@ operators() {

}
// TODO: use https://www.typescriptlang.org/docs/handbook/advanced-types.html#discriminated-unions ?
add(taskin, taskextra) {
let t;
if (Array.isArray(taskin)) {
;
taskin.forEach((t) => this.add(t));
return;
add(first, second) {
if ('function' == typeof first) {
second = second || {};
let t = new Task(second);
t.exec = first;
t.name = first.name ? first.name : t.name;
this.add_task(t);
}
else if ('function' !== typeof taskin) {
if (taskextra) {
t = new Task(taskextra);
t.exec = taskin;
t.name = taskin.name ? taskin.name : t.name;
else if (Array.isArray(first)) {
for (var i = 0; i < first.length; i++) {
let entry = first[i];
if ('function' === typeof first[i]) {
entry = { name: first[i].name, exec: first[i] };
}
this.add_task(entry);
}
else {
t = new Task(taskin);
}
}
else {
t = new Task({
name: taskin.name,
exec: taskin,
});
this.add_task(first);
}
}
add_task(td) {
let t = new Task(td);
this.topo.add(t, {

@@ -120,2 +147,3 @@ group: t.name,

taskout = task_ex;
//console.log('RRR', taskout)
}

@@ -135,2 +163,3 @@ }

catch (operate_ex) {
//console.log('TTT', taskout)
operate = {

@@ -137,0 +166,0 @@ stop: true,

@@ -7,8 +7,19 @@ /* Copyright (c) 2016-2020 Richard Rodger and other contributors, MIT License */

import Nua from 'nua'
export { Ordu, LegacyOrdu }
interface OrduIF {
add(t: TaskDef | TaskExec, te?: TaskDef): void
add(td: TaskDef): void
add(td: TaskDef[]): void
add(te: TaskExec): void
add(te: TaskExec, td: TaskDef): void
add(te: TaskExec[]): void
tasks(): Task[]
operator(name: string, opr: Operator): void
operator(opr: Operator): void
operators(): object

@@ -120,3 +131,2 @@ exec(ctx: any, data: any, opts: any): Promise<ExecResult>

private operator_map: {
//[op: string]: (r: TaskResult, ctx: any, data: object) => Operate
[op: string]: Operator

@@ -134,3 +144,3 @@ }

stop: (tr, _, data) => {
Hoek.merge(data, tr.out)
Nua(data, tr.out, { preserve: true })
return { stop: true, err: tr.err }

@@ -140,3 +150,3 @@ },

merge: (tr, _, data) => {
Hoek.merge(data, tr.out)
Nua(data, tr.out, { preserve: true })
return { stop: false }

@@ -147,4 +157,5 @@ },

operator(name: string, opr: Operator) {
this.operator_map[name] = opr
operator(first: string | Operator, opr?: Operator) {
let name: string = 'string' === typeof first ? first : first.name
this.operator_map[name] = opr || (first as Operator)
}

@@ -156,24 +167,24 @@

// TODO: use https://www.typescriptlang.org/docs/handbook/advanced-types.html#discriminated-unions ?
add(taskin: TaskDef | TaskExec, taskextra?: TaskDef) {
let t: Task
if (Array.isArray(taskin)) {
;(taskin as any[]).forEach((t) => this.add(t))
return
} else if ('function' !== typeof taskin) {
if (taskextra) {
t = new Task(taskextra)
t.exec = taskin as TaskExec
t.name = taskin.name ? taskin.name : t.name
} else {
t = new Task(taskin as TaskDef)
add(first: any, second?: any): void {
if ('function' == typeof first) {
second = second || {}
let t = new Task(second)
t.exec = first
t.name = first.name ? first.name : t.name
this.add_task(t)
} else if (Array.isArray(first)) {
for (var i = 0; i < first.length; i++) {
let entry: TaskDef = first[i]
if ('function' === typeof first[i]) {
entry = { name: (first[i] as TaskExec).name, exec: first[i] }
}
this.add_task(entry)
}
} else {
t = new Task({
name: taskin.name,
exec: taskin as TaskExec,
})
this.add_task(first)
}
}
private add_task(td: TaskDef): void {
let t = new Task(td)
this.topo.add(t, {

@@ -218,2 +229,3 @@ group: t.name,

taskout = task_ex
//console.log('RRR', taskout)
}

@@ -233,2 +245,3 @@ } else {

} catch (operate_ex) {
//console.log('TTT', taskout)
operate = {

@@ -235,0 +248,0 @@ stop: true,

{
"name": "ordu",
"version": "1.1.1",
"version": "1.2.0",
"description": "Execute functions in a configurable order, modifying a shared data structure.",

@@ -21,3 +21,3 @@ "homepage": "https://github.com/rjrodger/ordu",

"build": "tsc -d",
"test": "lab -L -v -P test -t 90 --sourcemaps --transform node_modules/lab-transform-typescript -r console -o stdout -r html -o test/coverage.html",
"test": "lab -L -v -P test -t 80 --sourcemaps --transform node_modules/lab-transform-typescript -r console -o stdout -r html -o test/coverage.html",
"coveralls": "lab -s -P test -r lcov | coveralls",

@@ -40,3 +40,4 @@ "prettier": "prettier --write *.ts",

"@hapi/hoek": "^9.0.4",
"@hapi/topo": "^5.0.0"
"@hapi/topo": "^5.0.0",
"nua": "^1.0.2"
},

@@ -46,8 +47,8 @@ "devDependencies": {

"@hapi/lab": "^22.0.4",
"@types/node": "^13.13.5",
"@types/node": "^14.0.1",
"coveralls": "^3.1.0",
"lab-transform-typescript": "^3.0.1",
"prettier": "^2.0.5",
"typescript": "^3.8.3"
"typescript": "^3.9.2"
}
}

@@ -9,3 +9,4 @@ {

"strictNullChecks": true,
"strictPropertyInitialization": true
"strictPropertyInitialization": true,
"esModuleInterop": true
},

@@ -12,0 +13,0 @@ "exclude": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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