0.5.43 • Published 4 years ago

tdmf v0.5.43

Weekly downloads
9
License
ISC
Repository
github
Last release
4 years ago

test-driven-modular-framework

A Test Driven Modular Application Framework

npm install tdmf

Represent any complex application workflow (flowchart) as JavaScript code.

building blocks:

Current Version: 0.5.43

tdmf = require('tdmf')

flags = tdmf.flags // in-memory key-value datastore
testEngine = tdmf.testEngine // register tests for your functions and classes
Pipeline = tdmf.Pipeline // create pipelines
build_pipeline = tdmf.build_pipeline // build pipelines

testEngine.add_test("package", "get_sum", "pt_number_only") // a package test to inspect function input
testEngine.add_test("unit", "get_sum", ["test1", [1,2,3], [6]])
testEngine.add_test("package", "times_two", "pt_number_only")
testEngine.add_test("unit", "times_two", ["test1", [1,2,3], [2,4,6]]) // a unit test

// write components (functions and classes) with global scope

get_sum = async (package) => {
  output = []
  try {
    output = [ package.reduce((a,b) => a+b, 0) ]
  } catch(err){
    console.log(err)
  }
  return output
}

times_two = async (package) => {
  output = []
  try {
    output = package.map(x => x*2)
    times_two_output = flags.fetch("times_two_output") // read data from in-memory data store
    if (times_two_output){
      times_two_output = output.reduce((a,b) => { a.push(b); return a }, times_two_output)
    } else {
      times_two_output = output
    }
    flags.update("times_two_output", times_two_output) // write data to in-memory data store
  } catch(err){
    console.log(err)
  }
  return output
}

// Compose a pipeline to pass output of one function into another

let sample_pipeline = Pipeline([
    ["get_sum", [1,2.44,3]],
    "times_two"
])

// build and run your pipeline asynchronously

build_pipeline(sample_pipeline).then((pipeline) => {
  console.log(pipeline.output, flags.fetch("times_two_output"))
})
0.5.43

4 years ago

0.5.42

4 years ago

0.5.41

4 years ago

0.5.4

4 years ago

0.5.36

4 years ago

0.5.35

4 years ago

0.5.34

4 years ago

0.5.33

4 years ago

0.5.32

4 years ago

0.5.31

4 years ago

0.5.3

4 years ago

0.5.2

4 years ago

0.5.1

4 years ago

0.5.0

4 years ago