sigsolve

0.2.0 • Public • Published

sigsolve

find a path through a type signature pool

testling badge

build status

example

var sigsolve = require('sigsolve');
var pool = {
    f : [ 'a', 'b' ],
    g : [ 'b', 'x' ],
    h : [ 'x', 'z' ],
    i : [ 'c', 'z' ],
    j : [ 'c', 'd' ],
};

var solutions = sigsolve([ 'a', 'z' ], pool);
console.dir(solutions);

output:

[ [ 'f', 'g', 'h' ] ]

or higher-order signatures work too:

var sigsolve = require('sigsolve');
var pool = {
    f : [ [ 'a', 'b' ], 'c' ],
    g : [ 'c', 'z' ],
    h : [ 'a', 'd' ],
    i : [ 'd', 'b' ],
};
var solutions = sigsolve([ 'a', 'z' ], pool);
console.log(JSON.stringify(solutions));

output:

[[["f",["h","i"]],"g"]]

methods

var sigsolve = require('sigsolve')

var solutions = sigsolve(target, pool)

Given a type signature target and an object pool mapping function names to type signatures,

return an array of function chain arrays that when composed have the same type signature as the target.

license

MIT

/sigsolve/

    Package Sidebar

    Install

    npm i sigsolve

    Weekly Downloads

    3

    Version

    0.2.0

    License

    MIT

    Last publish

    Collaborators

    • nopersonsmodules