semver-dsl

WebJar for semver-dsl

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

semver-dsl
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

semver-dsl
WebJar for semver-dsl
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/mgechev/semver-dsl

Download semver-dsl

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/semver-dsl/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>semver-dsl</artifactId>
    <version>1.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/semver-dsl/
implementation 'org.webjars.npm:semver-dsl:1.0.1'
// https://jarcasting.com/artifacts/org.webjars.npm/semver-dsl/
implementation ("org.webjars.npm:semver-dsl:1.0.1")
'org.webjars.npm:semver-dsl:jar:1.0.1'
<dependency org="org.webjars.npm" name="semver-dsl" rev="1.0.1">
  <artifact name="semver-dsl" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='semver-dsl', version='1.0.1')
)
libraryDependencies += "org.webjars.npm" % "semver-dsl" % "1.0.1"
[org.webjars.npm/semver-dsl "1.0.1"]

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.npm : semver jar [5.3.0,6)

Project Modules

There are no modules declared in this project.

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

Versions

Version
1.0.1