1.2.1 • Published 1 year ago

@p-v/trickle v1.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

trickle

A simple framework to write flow based operations

Installation

npm install @p-v/trickle
let envArgs = {
  outputTemplate: 'The result is %d'
};

let trickle = new Trickle(envArgs, {});

trickle
  .new((x) => x * x, [4])  // square
  .transform((x) => x / 2) // divide by 2
  .store((x) => ({ output: x }))  // store x as output in the trickle context
  .continue((x) => console.log('Half of 16 is', x))  // peek into the pipeline and log the value of x
  .new(
    (format, value) => console.log(format, value),
    ["{{outputTemplate}}", "<<output>>"]
  ) // use the variables from environment and context 
  .done() // execute the flow

Functionality

The basic functions defined as follows:

.new

A new operation that does not consider the response of the previous operation.

The flows environment variables can be accessed by providing the arguments in the format {{environmentVariableKey}}.

The values from the trickle context can be accessed by providing the argument in the format <<contextVariableKey>>.

.transform

Tranform the flowing object to another. The returned value becomes the new object flowing through the pipeline

.continue

Peek through the flowing object. The returned value has no affect on the flowing object.

.store

Store the arguments as part of the trickle context and can be used later as part of the same flow.

The values from the trickle context can be accessed by providing the argument in the format <<contextVariableKey>>

.done

The operations are not performed until done is called. The flow will start executing only after the call to done.

1.2.1

1 year ago

1.2.0

1 year ago

1.1.0

1 year ago

1.0.6

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago