Tabnine Logo For Javascript
semver
Code IndexAdd Tabnine to your IDE (free)

How to use semver

Best JavaScript code snippets using semver(Showing top 15 results out of 846)

origin: sindresorhus/np

isLowerThanOrEqualTo(otherVersion) {
    module.exports.validate(this.version);
    module.exports.validate(otherVersion);

    return semver.lte(otherVersion, this.version);
  }
origin: standard-things/esm

function getRange(json, name) {
 if (has(json, name)) {
  const object = json[name]

  if (has(object, "esm")) {
   return validRange(object.esm)
  }
 }

 return null
}
origin: tulios/kafkajs

const testIfKafkaVersion = (version, versionComparator) => {
 const scopedTest = (description, callback, testFn = test) => {
  return versionComparator(semver.coerce(process.env.KAFKA_VERSION), semver.coerce(version))
   ? testFn(description, callback)
   : test.skip(description, callback)
 }

 scopedTest.only = (description, callback) => scopedTest(description, callback, test.only)

 return scopedTest
}
origin: lando/lando

// Helper to determine whether we should use mutagen or not
const shouldMutagen = (dockerVersion = '0.0.0') => {
 // Only do this on non linux
 if (process.platform !== 'darwin') return false;
 // Otherwise return if we have sufficient docker version
 return semver.gte(dockerVersion, '2.3.30');
}
origin: tulios/kafkajs

getCurrentVersion().then(({ latest, beta }) => {
 console.log(`Current Latest: ${latest}, Beta: ${beta}`)
 const { major, minor } = parse(latest)
 const [tag, currentBeta] = prerelease(beta)
 const newStable = `${major}.${minor + 1}.0`
 const newBeta = sameStableVersion(newStable, beta) ? currentBeta + 1 : 0
 const newBetaVersion = `${newStable}-${tag}.${newBeta}`
 console.log(`New beta: ${newBetaVersion}`)
 console.log(`##vso[task.setvariable variable=PRE_RELEASE_VERSION;isOutput=true]${newBetaVersion}`)
})
origin: parse-community/parse-server

function compatible(compatibleSDK) {
 return function (clientSDK) {
  if (typeof clientSDK === 'string') {
   clientSDK = fromString(clientSDK);
  } // REST API, or custom SDK


  if (!clientSDK) {
   return true;
  }

  const clientVersion = clientSDK.version;
  const compatiblityVersion = compatibleSDK[clientSDK.sdk];
  return semver.satisfies(clientVersion, compatiblityVersion);
 };
}
origin: parse-community/parse-server

beforeAll(async () => {
    if (
     semver.satisfies(process.env.MONGODB_VERSION, '>=4.0.4') &&
     process.env.MONGODB_TOPOLOGY === 'replicaset' &&
     process.env.MONGODB_STORAGE_ENGINE === 'wiredTiger'
    ) {
     await reconfigureServer({
      databaseAdapter: undefined,
      databaseURI:
       'mongodb://localhost:27017/parseServerMongoAdapterTestDatabase?replicaSet=replicaset',
     });
    }
   });
origin: nodejs/nodejs.org

releases.find((release) => !release.lts && semver.gte(release.version, '5.0.0'))
origin: sindresorhus/np

isPrerelease() {
    return Boolean(semver.prerelease(this.version));
  }
origin: nodejs/nodejs.org

function majorStr (release) {
 return `v${semver.major(release.version)}.x`
}
origin: sindresorhus/np

getNewVersionFrom(input) {
    module.exports.validate(this.version);
    if (!module.exports.isValidInput(input)) {
      throw new Error(`Version should be either ${module.exports.SEMVER_INCREMENTS.join(', ')} or a valid semver version.`);
    }

    return module.exports.SEMVER_INCREMENTS.includes(input) ? semver.inc(this.version, input) : input;
  }
origin: sindresorhus/np

satisfies(range) {
    module.exports.validate(this.version);
    return semver.satisfies(this.version, range, {
      includePrerelease: true
    });
  }
origin: sindresorhus/np

isGreaterThanOrEqualTo(otherVersion) {
    module.exports.validate(this.version);
    module.exports.validate(otherVersion);

    return semver.gte(otherVersion, this.version);
  }
origin: parse-community/parse-server

beforeAll(async () => {
    if (
     semver.satisfies(process.env.MONGODB_VERSION, '>=4.0.4') &&
     process.env.MONGODB_TOPOLOGY === 'replicaset' &&
     process.env.MONGODB_STORAGE_ENGINE === 'wiredTiger'
    ) {
     await reconfigureServer({
      databaseAdapter: undefined,
      databaseURI:
       'mongodb://localhost:27017/parseServerMongoAdapterTestDatabase?replicaSet=replicaset',
     });
    }
   });
origin: parse-community/parse-server

function compatible(compatibleSDK) {
 return function(clientSDK) {
  if (typeof clientSDK === 'string') {
   clientSDK = fromString(clientSDK);
  }
  // REST API, or custom SDK
  if (!clientSDK) {
   return true;
  }
  const clientVersion = clientSDK.version;
  const compatiblityVersion = compatibleSDK[clientSDK.sdk];
  return semver.satisfies(clientVersion, compatiblityVersion);
 };
}
semver(npm)

JSDoc

The semantic version parser used by npm.

Most used semver functions

  • satisfies
    Return true if the version satisfies the range.
  • valid
    Return the parsed version, or null if it's not valid.
  • lt
    v1 < v2
  • gt
    v1 > v2
  • gte
    v1 >= v2
  • major,
  • validRange,
  • SemVer.version,
  • inc,
  • diff,
  • compare,
  • lte,
  • minor,
  • parse,
  • prerelease,
  • SemVer.major,
  • clean,
  • intersects,
  • minVersion

Popular in JavaScript

  • lodash
    Lodash modular utilities.
  • mkdirp
    Recursively mkdir, like `mkdir -p`
  • path
  • through2
    A tiny wrapper around Node.js streams.Transform (Streams2/3) to avoid explicit subclassing noise
  • async
    Higher-order functions and common patterns for asynchronous code
  • qs
    A querystring parser that supports nesting and arrays, with a depth limit
  • mocha
    simple, flexible, fun test framework
  • express
    Fast, unopinionated, minimalist web framework
  • js-yaml
    YAML 1.2 parser and serializer
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJavascript Code Index
Get Tabnine for your IDE now