How to use the lt function from semver

Find comprehensive JavaScript semver.lt code examples handpicked from public code repositorys.

13
14
15
16
17
18
19
20
21
22

// Get latest tag according to semver.
const [ tag ] = run('git', 'tag')
  .split(/\r?\n/)
  .filter(semver.coerce) // check version can be processed
  .filter(v => semver.lt(semver.coerce(v), version)) // only consider older tags, ignore current prereleases
  .sort(semver.rcompare);

// Ordering tag → HEAD is important here.
const files = run('git', 'diff', tag, 'HEAD', '--name-only', 'contracts/**/*.sol')
fork icon378
star icon20
watch icon1

841
842
843
844
845
846
847
848
849
850
if (customer.sanctions === false) return dispatchBySanctions(false)

// BACKWARDS_COMPATIBLITY 7.5
// older server can't use "trigger sanctions" request
const serverVersion = this.trader.serverVersion
if (!serverVersion || semver.lt(serverVersion, '7.5.0-beta.0')) {
  dispatchBySanctions(customer.sanctions)
}

return this.trader.triggerSanctions(customer.id)
fork icon129
star icon96
watch icon17

+ 83 other calls in file

87
88
89
90
91
92
93
94
95
96
  } catch (e) {
    return null;
  }
})
.then((latest) => {
  if (latest && semver.lt(packageJson.version, latest)) {
    console.log();
    console.error(
      chalk.yellow(
        `You are running \`create-evershop-app\` ${packageJson.version}, which is behind the latest release (${latest}).\n\n` +
fork icon110
star icon608
watch icon8

+ 3 other calls in file

49
50
51
52
53
54
55
56
57
58
return new Promise((resolve, reject) => {
    recommendedVersion(
        {
            preset: {
                name: require.resolve('conventional-changelog-conventionalcommits'),
                preMajor: semver.lt(currentVersion, '1.0.0')
            },
            tagPrefix: 'v'
        },
        (err, release) => {
fork icon110
star icon225
watch icon26

+ 3 other calls in file

52
53
54
55
56
57
58
59
60
61
 * @param {String} v1 - The first version to compare
 * @param {String} v2 - The second version to compare
 * @returns {Boolean} True if the first version is less than the second version
 */
exports.lt = function lt(v1, v2) {
        return semver.lt(format(v1, 3, 3), format(v2, 3, 3));
};

/**
 * Converts two versions into 3 segment format, then checks if the first version is less than or
fork icon29
star icon11
watch icon53

32
33
34
35
36
37
38
39
40
41
      ((branch.type === 'prerelease' &&
        tag.channels.some((channel) =>
          isSameChannel(branch.channel, channel)
        )) ||
        !semver.prerelease(tag.version)) &&
      (isUndefined(before) || semver.lt(tag.version, before))
  )
  .sort((a, b) => semver.rcompare(a.version, b.version));

if (gitTag) {
fork icon0
star icon42
watch icon3

5
6
7
8
9
10
11
12
13
14
const semver = require('semver')
const debug = require('debug')('0x')
const sll = require('single-line-log')
const launch = require('opn')
const hasUnicode = require('has-unicode')()
const zeroEks = semver.lt(process.version, '8.5.0') === true ? () => {} : require('./')
const { version } = require('./package.json')

const defaultBanner = `
  0x ${version}
fork icon119
star icon0
watch icon35

276
277
278
279
280
281
282
283
284
285
	node.isUnsupported = true;
	node.version = '1.4.3';
} else {
	node.isUnsupported = false;
}
const is14Node = semver.lt(semver.coerce(node.version), semver.coerce('2.0'));
const current_version = parse_version(node.version);

for (let i in availableVersions) {
	try {
fork icon45
star icon74
watch icon14

140
141
142
143
144
145
146
147
148
149
var url = peregrineProps.endpoints.coreMetadataPath;
if (peregrineVersion) {
  try {
    peregrineVersion = semver.coerce(peregrineVersion, { loose: true });
    if (
      semver.lt(peregrineVersion, minSemVer) ||
      (semver.gte(peregrineVersion, monthlyReleaseCutoff) && semver.lt(peregrineVersion, minMonthlyRelease))
    ) {
      url = peregrineProps.endpoints.coreMetadataLegacyPath;
    }
fork icon2
star icon4
watch icon26

7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
// References:
// <https://github.com/nodejs/node/issues/31630>
// <https://github.com/ladjs/superagent/pull/1084/commits/dc18679a7c5ccfc6046d882015e5126888973bc8>
//
// Thanks to @shadowgate15 and @niftylettuce
if (semver.gte(process.version, 'v13.0.0') && semver.lt(process.version, 'v14.0.0')) {
  // Note that the reason this doesn't work is because in v13 as compared to v14
  // there is no `callback = nop` set in end-of-stream.js above
  throw new Error('Superagent does not work in v13 properly with abort() due to Node.js core changes');
} else if (semver.gte(process.version, 'v14.0.0')) {
fork icon1
star icon4
watch icon1

+ 2 other calls in file

773
774
775
776
777
778
779
780
781
782
    `version to update the URL...`
    // `(or downgrade the \`package-lock.json\` version).`
  );
  updateVersionLock = lockVersion;
} else {
  const lt = semver.lt(lockVersion, version);
  // istanbul ignore if -- semver shouldn't have another state
  if (!lt) {
    throw new Error(
      'Unexpected error: Not greater or less than version, nor ' +
fork icon0
star icon4
watch icon0

792
793
794
795
796
797
798
799
800
801
let yarnVersion = null;
try {
  yarnVersion = execSync('yarnpkg --version').toString().trim();
  if (semver.valid(yarnVersion)) {
    hasMinYarnPnp = semver.gte(yarnVersion, minYarnPnp);
    hasMaxYarnPnp = semver.lt(yarnVersion, maxYarnPnp);
  } else {
    // Handle non-semver compliant yarn version strings, which yarn currently
    // uses for nightly builds. The regex truncates anything after the first
    // dash. See #5362.
fork icon1
star icon0
watch icon2

+ 8 other calls in file

116
117
118
119
120
121
122
123
124
125
devServer.startCallback(() => {
  if (isInteractive) {
    clearConsole();
  }

  if (env.raw.FAST_REFRESH && semver.lt(react.version, '16.10.0')) {
    console.log(
      chalk.yellow(
        `Fast Refresh requires React 16.10 or higher. You are using React ${react.version}.`
      )
fork icon1
star icon0
watch icon0

100
101
102
103
104
105
106
107
108
// github-ae and free-pro-team versions only have '*' range
if (pageVersion !== 'enterprise-server' || existingVersionRangeIsAll) continue

const rangeOfVersionToAddIsAll = page.versions[pageVersion] === '*'
// see if the version to add is a superset of the existing version
const existingVersionIsSubsetOfNewVersion = semver.lt(
  semver.coerce(page.versions[pageVersion].replace('*', 0)),
  semver.coerce(imageVersions[pageVersion].replace('*', 0))
)
fork icon0
star icon2
watch icon0

203
204
205
206
207
208
209
210
211
212
213
214
}


module.exports = function (mongodb, options) {
  // v3.3.0 is the first version of mongodb that doesn't use mongodb-core.
  // v4.x.x has different signature
  if (semver.gte(options.version, '3.3.0') && semver.lt(options.version, '4.0.0')) {
    try {
      const coreWireProtocol = requirePatch.relReq('mongodb/lib/core/wireprotocol/index.js')


      Object.keys(coreWireProtocol).forEach((name) => {
fork icon1
star icon1
watch icon6

60
61
62
63
64
65
66
67
68
69
        process.exit(1);
    }
}
checkAppName(project_name)
Helpers.checkForLatestVersion().then(latest => {
    if (latest && semver.lt(Constants.package.version, latest)) {
        const message1 = `You are running \`create-mernjs-app\` ${chalk.bold.red(Constants.package.version)}, which is behind the latest release ${chalk.bold.green(latest)}.`
        const message2 = 'We recommend always using the latest version of create-mernjs-app.'
        const message3 = 'npm install create-mernjs-app -g'
        const message4 = `https://github.com/mernjs/create-mern-app/releases`
fork icon0
star icon2
watch icon1

116
117
118
119
120
121
122
123
124
125
devServer.startCallback(() => {
  if (isInteractive) {
    clearConsole();
  }

  if (env.raw.FAST_REFRESH && semver.lt(react.version, "16.10.0")) {
    console.log(
      chalk.yellow(
        `Fast Refresh requires React 16.10 or higher. You are using React ${react.version}.`
      )
fork icon1
star icon1
watch icon1

+ 13 other calls in file

485
486
487
488
489
490
491
492
493
494
// Make sure to always output `exotic` versions to be compatible with npm
const isDepOld = function isDepOld(_ref8) {
  let current = _ref8.current,
      latest = _ref8.latest,
      wanted = _ref8.wanted;
  return latest === 'exotic' || latest !== 'exotic' && (semver.lt(current, wanted) || semver.lt(current, latest));
};
const orderByName = function orderByName(depA, depB) {
  return depA.name.localeCompare(depB.name);
};
fork icon0
star icon0
watch icon1

+ 3 other calls in file

300
301
302
303
304
305
306
307
function isLookupTypeParameter(node) {
    return tsutils_1.isLiteralTypeNode(node.parent) && tsutils_1.isIndexedAccessTypeNode(node.parent.parent);
}
/** Versions of typescript below 2.7.1 treat backticks differently */
function hasOldTscBacktickBehavior() {
    return semver_1.lt(parse_1.getNormalizedTypescriptVersion(), "2.7.1");
}
var templateObject_1;
fork icon0
star icon0
watch icon1

+ 8 other calls in file

103
104
105
106
107
108
109
110
111
112
113
114
var excludedFileExtensionPattern = /\.(es5|min)\.js$/i;
var hasOwn = Object.prototype.hasOwnProperty;


// There's no way to tell the current Meteor version, but we can infer
// whether it's Meteor 1.4.4 or earlier by checking the Node version.
var isMeteorPre144 = semver.lt(process.version, "4.8.1");


BCp.processFilesForTarget = function (inputFiles) {
  var compiler = this;

fork icon0
star icon0
watch icon1