1.0.3 • Published 7 years ago

@scrambled/parse-version v1.0.3

Weekly downloads
1
License
BSD-3-Clause
Repository
github
Last release
7 years ago

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.