specs

0.1.0 • Public • Published

Specs

specs is a modular framework to compile specification models into javascript functions.

Install

npm install specs

Usage

var assert = require('assert');
var specs = require('specs');

var engine = specs.engine();

var spec = engine.compile({
  foo: 42,
  bar: /foo+bar/
});

assert(spec({
  foo: 42,
  bar: 'foooooooobar'
});

Directives

Directives allow you to extend the grammar of your specification engine

engine.directive('lt', function (model) {
  return function (x) { return x < model; };
});

and use them in specification models

var spec = engine.compile({ $lt: 43 });

assert(spec(42));

Modules

A module is a set of directives.

You can write your own modules or reuse existing ones.

Below are officially supported modules to come

  • specs-comp : basic scalar comparison operators
  • specs-logic : basic logic operators
  • specs-list : basic list operators (contains, any, none of, ...)

Module usage is then like so

var engine = specs.engine('comp', 'logic', 'list');

Readme

Keywords

none

Package Sidebar

Install

npm i specs

Weekly Downloads

7

Version

0.1.0

License

none

Last publish

Collaborators

  • ovmjm