Sha256: 4890a2816353aec02b4275986521b2efc6281e16f68f6568926d2d53aec14738
Contents?: true
Size: 409 Bytes
Versions: 66
Compression:
Stored size: 409 Bytes
Contents
const numeric = /^[0-9]+$/ const compareIdentifiers = (a, b) => { const anum = numeric.test(a) const bnum = numeric.test(b) if (anum && bnum) { a = +a b = +b } return a === b ? 0 : (anum && !bnum) ? -1 : (bnum && !anum) ? 1 : a < b ? -1 : 1 } const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a) module.exports = { compareIdentifiers, rcompareIdentifiers }
Version data entries
66 entries across 50 versions & 9 rubygems