@scrambled/parse-version

1.0.3 • Public • Published

Parse Version

Takes a version in a format produced by NPM (e.g. "1.9.4") and returns an object like:

{
  major: 1,
  minor: 9,
  patch: 4
}

Throws if version string is incorrect.

Install

npm install @scrambled/parse-version

Use

const parse = require("@scrambled/parse-version");

const { name, version } = require("../package.json");

const project = {
  name,
  version: parse(version)
};

JSON.stringify(project, null, 2) === `{
  "name": "my-awesome-project",
  "version": {
    "major": 1,
    "minor": 0,
    "patch": 9997
  }
}`
// true

Develop

Clone the repository and hack on. Check out friendly NPM scripts:

npm run develop   # Watch and run tests
npm run debug     # Run tests with node inspector

PRs are very welcome.

Readme

Keywords

none

Package Sidebar

Install

npm i @scrambled/parse-version

Weekly Downloads

1

Version

1.0.3

License

BSD-3-Clause

Last publish

Collaborators

  • dev_scrambled
  • rsalazarscrbld