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

Version Path
appmap-0.68.1 ./node_modules/semver/internal/identifiers.js
disco_app-0.15.2 test/dummy/node_modules/sass-loader/node_modules/semver/internal/identifiers.js
disco_app-0.15.2 test/dummy/node_modules/core-js-compat/node_modules/semver/internal/identifiers.js
disco_app-0.15.2 test/dummy/node_modules/@npmcli/fs/node_modules/semver/internal/identifiers.js
appmap-0.68.0 ./node_modules/semver/internal/identifiers.js
appmap-0.67.1 ./node_modules/semver/internal/identifiers.js
appmap-0.67.0 ./node_modules/semver/internal/identifiers.js
disco_app-0.18.4 test/dummy/node_modules/sass-loader/node_modules/semver/internal/identifiers.js
disco_app-0.18.4 test/dummy/node_modules/@npmcli/fs/node_modules/semver/internal/identifiers.js
disco_app-0.18.4 test/dummy/node_modules/core-js-compat/node_modules/semver/internal/identifiers.js
disco_app-0.18.1 test/dummy/node_modules/core-js-compat/node_modules/semver/internal/identifiers.js
disco_app-0.18.1 test/dummy/node_modules/@npmcli/fs/node_modules/semver/internal/identifiers.js
disco_app-0.18.1 test/dummy/node_modules/sass-loader/node_modules/semver/internal/identifiers.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/@npmcli/fs/node_modules/semver/internal/identifiers.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/sass-loader/node_modules/semver/internal/identifiers.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/core-js-compat/node_modules/semver/internal/identifiers.js
disco_app-0.14.0 test/dummy/node_modules/core-js-compat/node_modules/semver/internal/identifiers.js
disco_app-0.14.0 test/dummy/node_modules/@npmcli/fs/node_modules/semver/internal/identifiers.js
disco_app-0.14.0 test/dummy/node_modules/sass-loader/node_modules/semver/internal/identifiers.js
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/core-js-compat/node_modules/semver/internal/identifiers.js