From c5d29df6f75741fea27fffe3b88c9c3b28e3ca73 Mon Sep 17 00:00:00 2001 From: Charley Bodkin <1542740+charlex@users.noreply.github.com> Date: Tue, 24 Dec 2019 16:43:00 -0500 Subject: [PATCH] docs: Add "Constants" section to README documents `RELEASE_TYPES` and `SEMVER_SPEC_VERSION` --- README.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/README.md b/README.md index df54e7a0..7dde5f8c 100644 --- a/README.md +++ b/README.md @@ -513,6 +513,40 @@ ex. * `s.clean(' 2.1.5 ')`: `'2.1.5'` * `s.clean('~1.0.0')`: `null` +## Constants + +As a convenience, helper constants are exported to provide information about what `node-semver` supports: + +### `RELEASE_TYPES` + +- major +- premajor +- minor +- preminor +- patch +- prepatch +- prerelease + +``` +const semver = require('semver'); + +if (semver.RELEASE_TYPES.includes(arbitraryUserInput)) { + console.log('This is a valid release type!'); +} else { + console.warn('This is NOT a valid release type!'); +} +``` + +### `SEMVER_SPEC_VERSION` + +2.0.0 + +``` +const semver = require('semver'); + +console.log('We are currently using the semver specification version:', semver.SEMVER_SPEC_VERSION); +``` + ## Exported Modules