Socket
Socket
Sign inDemoInstall

semver-dsl

Package Overview
Dependencies
1
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    semver-dsl

Tiny internal DSL which allows invocation of different functionality depending on SemVer match.


Version published
Weekly downloads
645K
increased by4.93%
Maintainers
1
Install size
70.9 kB
Created
Weekly downloads
 

Readme

Source

Build Status

SemVer DSL

A simple internal DSL which allows you to invoke different functionality depending on version match. Used in codelyzer for keeping the code compatible across different versions of the Angular compiler.

Demo

$ npm i semver-dsl --save
import {SemVerDSL} from 'semver-dsl';

const base = () => {};
const elseIf1 = () => {};
const elseIf2 = () => {};
const else = () => console.log('I will be invoked!');

SemVerDSL('3.0.0')
  .gt('3.2.1', base)
  .elseIf.gt('3.0.1', elseIf1)
  .elseIf.between('3.0.1', '3.1.8', elseIf2)
  .else(else);

In the example above will be invoked else.

API

  • SemDSL(version: string) - factory which accepts a version and returns an object.
  • gte(version: string, callback?: Function): ISemContextualDSL - returns an object with elseIf and else properties.
  • lte(version: string, callback?: Function): ISemContextualDSL - returns an object with elseIf and else properties.
  • gt(version: string, callback?: Function): ISemContextualDSL - returns an object with elseIf and else properties.
  • lt(version: string, callback?: Function): ISemContextualDSL - returns an object with elseIf and else properties.
  • eq(version: string, callback?: Function): ISemContextualDSL - returns an object with elseIf and else properties.
  • neq(version: string, callback?: Function): ISemContextualDSL - returns an object with elseIf and else properties.
  • between(v1: string, v2: string, callback?: Function): ISemContextualDSL - returns an object with elseIf properties.
  • elseIf - returns an object of type ISemVerDSL bound to the previous predicate.
  • else - invokes given callback if all of the previous conditions have failed.
export interface ISemVerDSL {
  gte(version: string, callback: Function): ISemContextualDSL;
  lte(version: string, callback: Function): ISemContextualDSL;
  gt(version: string, callback: Function): ISemContextualDSL;
  lt(version: string, callback: Function): ISemContextualDSL;
  eq(version: string, callback: Function): ISemContextualDSL;
  neq(version: string, callback: Function): ISemContextualDSL;
  between(v1: string, v2: string, callback: Function): ISemContextualDSL;
}
export interface ISemVerContextBoundDSL {
  elseIf: ISemVerDSL;
  else(callback: Function): void;
}

License

MIT

Keywords

FAQs

Last updated on 19 Feb 2017

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc