Launch Week Day 1: Socket for Jira Is Now Available.Learn More
Socket
Book a DemoSign in
Socket

ordu

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ordu

Execute functions in a configurable order, modifying a shared data structure.

latest
Source
npmnpm
Version
4.2.0
Version published
Weekly downloads
5.1K
8.49%
Maintainers
1
Weekly downloads
 
Created
Source

ordu

npm version Build Status Coverage Status Dependency Status DeepScan grade Maintainability

Execute functions in a configurable order, modifying a shared data structure.

Task functions are executed in order of addition, and passed a shared context, and a modifiable data structure. Execution is synchronous. You can exit early by returning a non-null value from a task function.

You can tag task functions, and restrict execution to the subset of task functions with matching tags.

This module is used by the Seneca framework to provide configurable extension hooks.

Quick example

var Ordu = require('ordu')

var w = Ordu()

w.add(function first (ctxt, data) {
  if (null == data.foo) {
    return {kind: 'error', why: 'no foo'}
  }

  data.foo = data.foo.substring(0, ctxt.len)
})

w.add({tags: ['upper']}, function second (ctxt, data) {
  data.foo = data.foo.toUpperCase()
})

var ctxt = {len: 3}
var data = {foo: 'green'}

w.process(ctxt, data)
console.log(data.foo) // prints 'GRE' (first, second)

data = {foo: 'blue'}
w.process({tags: ['upper']}, ctxt, data)
console.log(data.foo) // prints 'BLUE' (second)

data = []
var res = w.process(ctxt, data)
console.log(res) // prints {kind: 'error', why: 'no foo', ... introspection ...}

Install

npm install ordu

Notes

From the Irish ordú: instruction. Pronounced or-doo.

License

Copyright (c) 2014-2020, Richard Rodger and other contributors. Licensed under MIT.

Keywords

function

FAQs

Package last updated on 26 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts