painless-version
Version:
Intuitive version management abstraction
47 lines (31 loc) • 2.14 kB
Markdown
# painless-version
[](https://circleci.com/gh/blackflux/painless-version)
[](https://coveralls.io/github/blackflux/painless-version?branch=master)
[](https://dependabot.com)
[](https://david-dm.org/blackflux/painless-version)
[](https://www.npmjs.com/package/painless-version)
[](https://www.npmjs.com/package/painless-version)
[](https://github.com/semantic-release/semantic-release)
[](https://github.com/blackflux/js-gardener)
Intuitive version management abstraction
## Install
```
npm i --save painless-version
```
## Getting Started
<!-- eslint-disable import/no-unresolved, import/no-extraneous-dependencies, mocha/no-global-tests -->
```js
import { test } from 'painless-version';
const version = '5.3.5';
test(`1.2.3 < ${version}`);
// => true
```
## Functions
### test(expression: String)
Evaluate comparison string of form `LHS CMP RHS` where `LHS` and `RHS` are
version strings and `CMP` is one of `<`, `<=`, `>`, `>=`, `=`.
Under the hood this uses [compare-versions](https://www.npmjs.com/package/compare-versions).
### updateDeprecationHeaders(headers: {}, { deprecationDate: Date, sunsetDate: Date })
Modifies the headers object in place assuming this is a response headers object.
Updates headers [deprecation](https://tools.ietf.org/id/draft-dalal-deprecation-header-01.html) and [sunset](https://tools.ietf.org/id/draft-dalal-deprecation-header-01.html#rfc.section.5)
Existing headers are only overwritten if the date present is further in the future.