New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

getto-specification

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

getto-specification

predicate factory : caching return value of boolean-returning-function and compose them

latest
Source
npmnpm
Version
1.0.3
Version published
Maintainers
1
Created
Source

getto-specification

predicate factory : caching return value of boolean-returning-function and compose them

status: production ready

const specification = require("getto-specification");

const spec = specification.init();

const conditionA = spec.init(() => {
  return heavy_condition_checker(); // return Promise
});

const text = "text";
const conditionB = spec.init(() => {
  return (text === "text");
});

const compose = spec.all([
  conditionA,
  spec.not(conditionB),
]);

const result = await compose.matches();
console.log(result);
Table of Contents
  • Requirements
  • Usage
  • License

Requirements

  • Node.js : 10.16.0

Usage

const specification = require("getto-specification");

const spec = specification.init();

const conditionA = spec.init(() => {
  return heavy_condition_checker(); // return Promise
});

const text = "text";
const conditionB = spec.init(() => {
  return (text === "text");
});

const compose = spec.all([
  conditionA,
  spec.not(conditionB),
]);

const result = await compose.matches();
console.log(result);

methods

init

const condition = spec.init(() => {
  return BOOLEAN;
});

spec.init() is caching function result

not

const condition = spec.not(another_condition);

return invert condition

all

const condition = spec.all([
  conditionA,
  conditionB,
]);

all conditions are sync-checking

matches: async () => {
  for(let i in conditions) {
    const condition = conditions[i];
    if (!(await condition.matches())) {
      return false;
    }
  }

  return true;
}

Install

npm install --save getto-specification

License

getto-specification is licensed under the MIT license.

Copyright © since 2019 shun@getto.systems

FAQs

Package last updated on 03 Dec 2019

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