NPM.compareVersions()

Compare two NPM version strings and return either 1, 0, or -1.

This returns: • `1` if the version A is newer (greater) • `0` if both versions are the same • `-1` if the version A is older (less than)

Usage

Hover over inputs/exits for more info.

var NPM = require('machinepack-npm');


// Compare two NPM version strings and return either 1, 0, or -1.

NPM.compareVersions({

a: '1.2.5',

b: '4.9.0',

}).execSync();

Inputs

a required

'1.2.5'
b required

'4.9.0'

Exits

error

An unexpected error occurred.

success

OK.

1