How to use semver method in storybook-root

Best JavaScript code snippet using storybook-root

semver.test.js

Source:semver.test.js Github

copy

Full Screen

1const Semver = require('../../lib/semver');2const chai = require('chai');3const crypto = require('crypto');4let semver = new Semver();5let expect = chai.expect;6describe('Semver unit tests', () => {7 it('Undefined semvers', () => {8 let ver1, ver2;9 let result = semver.determinePrecedence(ver1, '1.1.1');10 expect(result).to.be.false;11 result = semver.determinePrecedence('1.1.1', ver2);12 expect(result).to.be.false;13 });14 it('Null semvers', () => {15 let result = semver.determinePrecedence(null, '1.1.1');16 expect(result).to.be.false;17 result = semver.determinePrecedence('1.1.1', null);18 expect(result).to.be.false;19 });20 it('Empty semvers', () => {21 let result = semver.determinePrecedence('', '1.1.1');22 expect(result).to.be.false;23 result = semver.determinePrecedence('1.1.1', '');24 expect(result).to.be.false;25 });26 it('Non string semvers', () => {27 let result = semver.determinePrecedence(1, '1.1.1');28 expect(result).to.be.false;29 result = semver.determinePrecedence('1.1.1', 1);30 expect(result).to.be.false;31 });32 it('Missing Major', () => {33 let result = semver.determinePrecedence('.1.1', '1.1.1');34 expect(result).to.be.false;35 result = semver.determinePrecedence('1.1.1', '.1.1');36 expect(result).to.be.false;37 });38 it('Missing Minor', () => {39 let result = semver.determinePrecedence('1..1', '1.1.1');40 expect(result).to.be.false;41 result = semver.determinePrecedence('1.1.1', '1..1');42 expect(result).to.be.false;43 });44 it('Missing Patch', () => {45 let result = semver.determinePrecedence('1.1.', '1.1.1');46 expect(result).to.be.false;47 result = semver.determinePrecedence('1.1.1', '1.1.');48 expect(result).to.be.false;49 });50 it('Non integer Major, Minor, and Patch', () => {51 let result = semver.determinePrecedence('a.1.1', '1.1.1');52 expect(result).to.be.false;53 result = semver.determinePrecedence('1.a.1', '1.1.1');54 expect(result).to.be.false;55 result = semver.determinePrecedence('1.1.a', '1.1.1');56 expect(result).to.be.false;57 result = semver.determinePrecedence('1.1.1', 'a.1.1');58 expect(result).to.be.false;59 result = semver.determinePrecedence('1.1.1', '1.a.1');60 expect(result).to.be.false;61 result = semver.determinePrecedence('1.1.1', '1.1.a');62 expect(result).to.be.false;63 });64 it('Random n-length, non integer identifier', () => {65 let ver1 = crypto.randomBytes(255).toString('hex').slice(Math.floor(Math.random() * (255 - 1) + 1), 255) + '.' +66 crypto.randomBytes(255).toString('hex').slice(Math.floor(Math.random() * (255 - 1) + 1), 255) + '.' +67 crypto.randomBytes(255).toString('hex').slice(Math.floor(Math.random() * (255 - 1) + 1), 255)68 let result = semver.determinePrecedence(ver1, '1.1.1');69 expect(result).to.be.false;70 let ver2 = crypto.randomBytes(255).toString('hex').slice(Math.floor(Math.random() * (255 - 1) + 1), 255) + '.' +71 crypto.randomBytes(255).toString('hex').slice(Math.floor(Math.random() * (255 - 1) + 1), 255) + '.' +72 crypto.randomBytes(255).toString('hex').slice(Math.floor(Math.random() * (255 - 1) + 1), 255)73 result = semver.determinePrecedence('1.1.1', ver2);74 expect(result).to.be.false;75 });76 it('Leading zeros Major, Minor, and Patch', () => {77 let result = semver.determinePrecedence('02.1.1', '1.1.1');78 expect(result).to.be.false;79 result = semver.determinePrecedence('1.010.1', '1.1.1');80 expect(result).to.be.false;81 result = semver.determinePrecedence('1.1.0000003', '1.1.1');82 expect(result).to.be.false;83 result = semver.determinePrecedence('1.1.1', '02.1.1');84 expect(result).to.be.false;85 result = semver.determinePrecedence('1.1.1', '1.09.1');86 expect(result).to.be.false;87 result = semver.determinePrecedence('1.1.1', '1.1.01');88 expect(result).to.be.false;89 });90 it('Non ASCII-alphanumerics in pre-release', () => {91 let result = semver.determinePrecedence('1.1.1-!.#.$', '1.1.1');92 expect(result).to.be.false;93 result = semver.determinePrecedence('1.10.1', '1.1.1-ab.%.^');94 expect(result).to.be.false;95 result = semver.determinePrecedence('1.1.3-(>")>', '1.1.1-<("<)');96 expect(result).to.be.false;97 result = semver.determinePrecedence('1.1.1-¯\_(ツ)_/¯', '02.1.1');98 expect(result).to.be.false;99 result = semver.determinePrecedence('1.1.1', '1.09.1-_-_-_');100 expect(result).to.be.false;101 result = semver.determinePrecedence('1.1.1-!@#$%^&*()_+=[{}]<>/?', '1.1.01');102 expect(result).to.be.false;103 });104 it('Empty identifiers in pre-release', () => {105 let result = semver.determinePrecedence('1.1.1-.', '1.1.1');106 expect(result).to.be.false;107 result = semver.determinePrecedence('1.10.1', '1.1.1-alpha..beta');108 expect(result).to.be.false;109 result = semver.determinePrecedence('1.1.3', '1.1.1-rc.');110 expect(result).to.be.false;111 result = semver.determinePrecedence('1.1.1-foo-.-..', '02.1.1');112 expect(result).to.be.false;113 });114 it('Leading zeros in numeric identifiers - pre-release', () => {115 let result = semver.determinePrecedence('2.1.1-01', '1.1.1');116 expect(result).to.be.false;117 result = semver.determinePrecedence('1.10.1-rc01.02', '1.1.1');118 expect(result).to.be.false;119 result = semver.determinePrecedence('1.1.3-1.2.3.04', '1.1.1');120 expect(result).to.be.false;121 result = semver.determinePrecedence('1.1.1', '2.1.1--.010.foo');122 expect(result).to.be.false;123 result = semver.determinePrecedence('1.1.1', '1.9.1-01');124 expect(result).to.be.false;125 result = semver.determinePrecedence('1.1.1', '1.1.1-0foo');126 expect(result).to.be.true;127 });128 it('First semver Major > second semver Major', () => {129 let result = semver.determinePrecedence('2.0.0', '1.0.0');130 expect(result).to.be.true;131 result = semver.determinePrecedence('20.0.0', '15.0.0');132 expect(result).to.be.true;133 });134 it('First semver Major < second semver Major', () => {135 let result = semver.determinePrecedence('1.0.0', '2.0.0');136 expect(result).to.be.false;137 result = semver.determinePrecedence('15.0.0', '20.0.0');138 expect(result).to.be.false;139 });140 it('First semver Major.Minor > second semver Major.Minor', () => {141 let result = semver.determinePrecedence('2.1.0', '2.0.0');142 expect(result).to.be.true;143 result = semver.determinePrecedence('2.31.0', '2.22.0');144 expect(result).to.be.true;145 });146 it('First semver Major.Minor < second semver Major.Minor', () => {147 let result = semver.determinePrecedence('2.0.0', '2.1.0');148 expect(result).to.be.false;149 result = semver.determinePrecedence('2.22.0', '2.31.0');150 expect(result).to.be.false;151 });152 it('First semver Major.Minor.Patch > second semver Major.Minor.Patch', () => {153 let result = semver.determinePrecedence('2.0.1', '2.0.0');154 expect(result).to.be.true;155 result = semver.determinePrecedence('2.0.10', '2.0.9');156 expect(result).to.be.true;157 });158 it('First semver Major.Minor.Patch < second semver Major.Minor.Patch', () => {159 let result = semver.determinePrecedence('2.0.0', '2.0.1');160 expect(result).to.be.false;161 result = semver.determinePrecedence('2.0.9', '2.0.10');162 expect(result).to.be.false;163 });164 it('Semver Major, Minor, and Patch are all equal - first semver has pre-release', () => {165 let result = semver.determinePrecedence('2.0.1-alpha', '2.0.1');166 expect(result).to.be.false;167 result = semver.determinePrecedence('100.52.6-x.92-rc1', '100.52.6');168 expect(result).to.be.false;169 });170 it('Semver Major, Minor, and Patch are all equal - second semver has pre-release', () => {171 let result = semver.determinePrecedence('2.0.1', '2.0.1-alpha');172 expect(result).to.be.true;173 result = semver.determinePrecedence('100.52.6', '100.52.6-x.92-rc1');174 expect(result).to.be.true;175 });176 it('Semver Major, Minor, and Patch are all equal', () => {177 let result = semver.determinePrecedence('2.0.1', '2.0.1');178 expect(result).to.be.false;179 });180 it('Semver Major, Minor, Patch, and pre-release are all equal', () => {181 let result = semver.determinePrecedence('2.0.1-alpha.beta.foo', '2.0.1-alpha.beta.foo');182 expect(result).to.be.false;183 });184 it('Semver Major, Minor, and Patch are all equal - Numeric pre-release comparison', () => {185 let result = semver.determinePrecedence('2.0.1-100', '2.0.1-99');186 expect(result).to.be.true;187 result = semver.determinePrecedence('2.0.1-1', '2.0.1-50');188 expect(result).to.be.false;189 result = semver.determinePrecedence('2.0.1-100.2.75', '2.0.1-100.2.74');190 expect(result).to.be.true;191 result = semver.determinePrecedence('2.0.1-100.2.999', '2.0.1-100.2.5000');192 expect(result).to.be.false;193 });194 it('Semver Major, Minor, and Patch are all equal - Lexical pre-release comparison', () => {195 let result = semver.determinePrecedence('2.0.1-beta', '2.0.1-alpha');196 expect(result).to.be.true;197 result = semver.determinePrecedence('2.0.1-beta', '2.0.1-rc');198 expect(result).to.be.false;199 result = semver.determinePrecedence('2.0.1-foo-.bar-.baz-', '2.0.1-foo-.bar-.aaz-');200 expect(result).to.be.true;201 result = semver.determinePrecedence('2.0.1-a.b.c.d.e.f', '2.0.1-a.b.c.d.e.g');202 expect(result).to.be.false;203 });204 it('Semver Major, Minor, and Patch are all equal - Numbers & non-numberic pre-release comparison', () => {205 let result = semver.determinePrecedence('2.0.1-alpha.beta', '2.0.1-alpha.1');206 expect(result).to.be.true;207 result = semver.determinePrecedence('2.0.1-1', '2.0.1-rc');208 expect(result).to.be.false;209 result = semver.determinePrecedence('2.0.1-foo-.bar-.bam', '2.0.1-foo-.bar-.1337');210 expect(result).to.be.true;211 result = semver.determinePrecedence('2.0.1-a.b.c.d.e.100', '2.0.1-a.b.c.d.e.g');212 expect(result).to.be.false;213 });214 it('Semver Major, Minor, and Patch are all equal - Mixed Numbers & non-numberic pre-release comparison', () => {215 let result = semver.determinePrecedence('2.0.1-alpha.1zeta', '2.0.1-alpha.1beta');216 expect(result).to.be.true;217 result = semver.determinePrecedence('2.0.1-r1', '2.0.1-r2');218 expect(result).to.be.false;219 result = semver.determinePrecedence('2.0.1-foo2-.bar3-.bamz', '2.0.1-foo2-.bar3-.bam4');220 expect(result).to.be.true;221 result = semver.determinePrecedence('2.0.1-100abc.1-1.b100', '2.0.1-100abc.1-1.b101');222 expect(result).to.be.false;223 });224 it('Semver Major, Minor, and Patch are all equal - Semver1 has larger set', () => {225 let result = semver.determinePrecedence('2.0.1-alpha.beta.gamma', '2.0.1-alpha.beta');226 expect(result).to.be.true;227 result = semver.determinePrecedence('2.0.1-rc.5.go', '2.0.1-rc.5');228 expect(result).to.be.true;229 result = semver.determinePrecedence('2.0.1--.-.-.-', '2.0.1--.-.-');230 expect(result).to.be.true;231 });232 it('Semver Major, Minor, and Patch are all equal - Semver2 has larger set', () => {233 let result = semver.determinePrecedence('2.0.1-alpha.beta', '2.0.1-alpha.beta.-');234 expect(result).to.be.false;235 result = semver.determinePrecedence('2.0.1-rc.5.go', '2.0.1-rc.5.go.a.b.c');236 expect(result).to.be.false;237 result = semver.determinePrecedence('2.0.1--.-.-.-', '2.0.1--.-.-.-.x');238 expect(result).to.be.false;239 });...

Full Screen

Full Screen

sver.js

Source:sver.js Github

copy

Full Screen

1'use strict';2var shortSemverRegEx = /^([~\^])?(0|[1-9]\d*)(?:\.(0|[1-9]\d*))?$/;3var semverRegEx = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([\da-z-]+(?:\.[\da-z-]+)*))?(\+[\da-z-]+)?$/i;4exports.semverRegEx = semverRegEx;5exports.shortSemverRegEx = shortSemverRegEx;6var Symbol = require('es6-symbol');7var MAJOR = Symbol('major');8var MINOR = Symbol('minor');9var PATCH = Symbol('patch');10var PRE = Symbol('pre');11var BUILD = Symbol('build');12var TAG = Symbol('tag');13var numRegEx = /^\d+$/;14function Semver(version) {15 var semver = version.match(semverRegEx);16 if (!semver) {17 this[TAG] = version;18 return;19 }20 this[MAJOR] = parseInt(semver[1], 10);21 this[MINOR] = parseInt(semver[2], 10);22 this[PATCH] = parseInt(semver[3], 10);23 this[PRE] = semver[4] && semver[4].split('.');24 this[BUILD] = semver[5];25}26Object.defineProperty(Semver.prototype, 'major', {27 get: function major () {28 return this[MAJOR];29 }30});31Object.defineProperty(Semver.prototype, 'minor', {32 get: function minor () {33 return this[MINOR];34 }35});36Object.defineProperty(Semver.prototype, 'patch', {37 get: function patch () {38 return this[PATCH];39 }40});41Object.defineProperty(Semver.prototype, 'pre', {42 get: function pre () {43 return this[PRE];44 }45});46Object.defineProperty(Semver.prototype, 'build', {47 get: function build () {48 return this[BUILD];49 }50});51Object.defineProperty(Semver.prototype, 'tag', {52 get: function tag () {53 return this[TAG];54 }55});56Semver.prototype.gt = function gt(version) {57 return Semver.compare(this, version) === 1;58}59Semver.prototype.lt = function lt (version) {60 return Semver.compare(this, version) === -1;61}62Semver.prototype.eq = function eq (version) {63 if (!(version instanceof Semver))64 version = new Semver(version);65 if (this[TAG] && version[TAG])66 return this[TAG] === version[TAG];67 if (this[TAG] || version[TAG])68 return false;69 if (this[MAJOR] !== version[MAJOR])70 return false;71 if (this[MINOR] !== version[MINOR])72 return false;73 if (this[PATCH] !== version[PATCH])74 return false;75 if (this[PRE] === undefined && version[PRE] === undefined)76 return true;77 if (this[PRE] === undefined || version[PRE] === undefined)78 return false;79 if (this[PRE].length !== version[PRE].length)80 return false;81 for (var i = 0; i < this[PRE].length; i++) {82 if (this[PRE][i] !== version[PRE][i])83 return false;84 }85 return this[BUILD] === version[BUILD];86}87Semver.prototype.matches = function matches (range, unstable) {88 unstable = unstable || false;89 if (!(range instanceof SemverRange))90 range = new SemverRange(range);91 return range.has(this, unstable);92}93Semver.prototype.toString = function toString () {94 if (this[TAG])95 return this[TAG];96 return this[MAJOR] + '.' + this[MINOR] + '.' + this[PATCH] + (this[PRE] ? '-' + this[PRE].join('.') : '') + (this[BUILD] ? this[BUILD] : '');97}98Semver.isValid = function isValid (version) {99 var semver = version.match(semverRegEx);100 return semver && semver[2] !== undefined && semver[3] !== undefined;101}102Semver.compare = function compare (v1, v2) {103 if (!(v1 instanceof Semver))104 v1 = new Semver(v1);105 if (!(v2 instanceof Semver))106 v2 = new Semver(v2);107 // not semvers - tags have equal precedence108 if (v1[TAG] && v2[TAG])109 return 0;110 // semver beats tag version111 if (v1[TAG])112 return -1;113 if (v2[TAG])114 return 1;115 // compare version numbers116 if (v1[MAJOR] !== v2[MAJOR])117 return v1[MAJOR] > v2[MAJOR] ? 1 : -1;118 if (v1[MINOR] !== v2[MINOR])119 return v1[MINOR] > v2[MINOR] ? 1 : -1;120 if (v1[PATCH] !== v2[PATCH])121 return v1[PATCH] > v2[PATCH] ? 1 : -1;122 if (!v1[PRE] && !v2[PRE])123 return 0;124 if (!v1[PRE])125 return 1;126 if (!v2[PRE])127 return -1;128 // prerelease comparison129 for (var i = 0, l = Math.min(v1[PRE].length, v2[PRE].length); i < l; i++) {130 if (v1[PRE][i] !== v2[PRE][i]) {131 var isNum1 = v1[PRE][i].match(numRegEx);132 var isNum2 = v2[PRE][i].match(numRegEx);133 // numeric has lower precedence134 if (isNum1 && !isNum2)135 return -1;136 if (isNum2 && !isNum1)137 return 1;138 // compare parts139 if (isNum1 && isNum2)140 return parseInt(v1[PRE][i], 10) > parseInt(v2[PRE][i], 10) ? 1 : -1;141 else142 return v1[PRE][i] > v2[PRE][i] ? 1 : -1;143 }144 }145 if (v1[PRE].length === v2[PRE].length)146 return 0;147 // more pre-release fields win if equal148 return v1[PRE].length > v2[PRE].length ? 1 : -1;149}150exports.Semver = Semver;151var WILDCARD_RANGE = 0;152var MAJOR_RANGE = 1;153var STABLE_RANGE = 2;154var EXACT_RANGE = 3;155var TYPE = Symbol('type');156var VERSION = Symbol('version');157function SemverRange(versionRange) {158 if (versionRange === '*' || versionRange === '') {159 this[TYPE] = WILDCARD_RANGE;160 return;161 }162 var shortSemver = versionRange.match(shortSemverRegEx);163 if (shortSemver) {164 if (shortSemver[1])165 versionRange = versionRange.substr(1);166 if (shortSemver[3] === undefined) {167 // ^, ~ mean the same thing for a single major168 this[VERSION] = new Semver(versionRange + '.0.0');169 this[TYPE] = MAJOR_RANGE;170 }171 else {172 this[VERSION] = new Semver(versionRange + '.0');173 // ^ only becomes major range for major > 0174 if (shortSemver[1] === '^' && shortSemver[2] !== '0')175 this[TYPE] = MAJOR_RANGE;176 else177 this[TYPE] = STABLE_RANGE;178 }179 // empty pre array === support prerelease ranges180 this[VERSION][PRE] = this[VERSION][PRE] || [];181 }182 else if (versionRange[0] === '^') {183 this[VERSION] = new Semver(versionRange.substr(1));184 if (this[VERSION][MAJOR] === 0) {185 if (this[VERSION][MINOR] === 0)186 this[TYPE] = EXACT_RANGE;187 else188 this[TYPE] = STABLE_RANGE;189 }190 else {191 this[TYPE] = MAJOR_RANGE;192 }193 }194 else if (versionRange[0] === '~') {195 this[VERSION] = new Semver(versionRange.substr(1));196 this[TYPE] = STABLE_RANGE;197 }198 else {199 this[VERSION] = new Semver(versionRange);200 this[TYPE] = EXACT_RANGE;201 }202 if (this[VERSION][TAG] && this[TYPE] !== EXACT_RANGE)203 this[TYPE] = EXACT_RANGE;204}205Object.defineProperty(SemverRange.prototype, 'isExact', {206 get: function isExact () {207 return this[TYPE] === EXACT_RANGE;208 }209});210Object.defineProperty(SemverRange.prototype, 'isStable', {211 get: function isStable () {212 return this[TYPE] === STABLE_RANGE;213 }214});215Object.defineProperty(SemverRange.prototype, 'isMajor', {216 get: function isMajor () {217 return this[TYPE] === MAJOR_RANGE;218 }219});220Object.defineProperty(SemverRange.prototype, 'isWildcard', {221 get: function isWildcard () {222 return this[TYPE] === WILDCARD_RANGE;223 }224});225Object.defineProperty(SemverRange.prototype, 'type', {226 get: function type () {227 switch (this[TYPE]) {228 case WILDCARD_RANGE:229 return 'wildcard';230 case MAJOR_RANGE:231 return 'major';232 case STABLE_RANGE:233 return 'stable';234 case EXACT_RANGE:235 return 'exact';236 }237 }238});239Object.defineProperty(SemverRange.prototype, 'version', {240 get: function version () {241 return this[VERSION];242 }243});244SemverRange.prototype.gt = function gt (range) {245 return SemverRange.compare(this, range) === 1;246}247SemverRange.prototype.lt = function lt (range) {248 return SemverRange.compare(this, range) === -1;249}250SemverRange.prototype.eq = function eq (range) {251 return SemverRange.compare(this, range) === 0;252}253SemverRange.prototype.has = function has (version, unstable) {254 unstable = unstable || false;255 if (!(version instanceof Semver))256 version = new Semver(version);257 if (this[TYPE] === WILDCARD_RANGE)258 return true;259 if (this[TYPE] === EXACT_RANGE)260 return this[VERSION].eq(version);261 if (version[TAG])262 return false;263 if (version.lt(this[VERSION]))264 return false;265 if (version[PRE] && !unstable)266 return this[VERSION][MAJOR] === version[MAJOR] && this[VERSION][MINOR] === version[MINOR] && this[VERSION][PATCH] === version[PATCH];267 if (this[TYPE] === MAJOR_RANGE)268 return this[VERSION][MAJOR] === version[MAJOR];269 return this[VERSION][MAJOR] === version[MAJOR] && this[VERSION][MINOR] === version[MINOR];270}271SemverRange.prototype.contains = function contains (range) {272 if (!(range instanceof SemverRange))273 range = new SemverRange(range);274 if (this[TYPE] === WILDCARD_RANGE)275 return true;276 if (range[TYPE] === WILDCARD_RANGE)277 return false;278 return range[TYPE] >= this[TYPE] && this.has(range[VERSION], true);279}280SemverRange.prototype.intersect = function intersect (range) {281 if (!(range instanceof SemverRange))282 range = new SemverRange(range);283 if (this[TYPE] === WILDCARD_RANGE && range[TYPE] === WILDCARD_RANGE)284 return this;285 if (this[TYPE] === WILDCARD_RANGE)286 return range;287 if (range[TYPE] === WILDCARD_RANGE)288 return this;289 if (this[TYPE] === EXACT_RANGE)290 return range.has(this[VERSION], true) ? this : undefined;291 if (range[TYPE] === EXACT_RANGE)292 return this.has(range[VERSION], true) ? range : undefined;293 var higherRange, lowerRange, polarity;294 if (range[VERSION].gt(this[VERSION])) {295 higherRange = range;296 lowerRange = this;297 polarity = true;298 }299 else {300 higherRange = this;301 lowerRange = range;302 polarity = false;303 }304 if (!lowerRange.has(higherRange[VERSION], true))305 return;306 if (lowerRange[TYPE] === MAJOR_RANGE)307 return polarity ? range : this;308 var intersection = new SemverRange(higherRange[VERSION].toString());309 intersection[TYPE] = STABLE_RANGE;310 return intersection;311}312SemverRange.prototype.bestMatch = function bestMatch (versions, unstable) {313 unstable = unstable || false;314 var self = this;315 var maxSemver;316 versions.forEach(function(version) {317 if (!(version instanceof Semver))318 version = new Semver(version);319 if (!self.has(version, unstable))320 return;321 if (!unstable && version[PRE]) {322 if (self[TYPE] === WILDCARD_RANGE || !self[VERSION][PRE] || self[VERSION][MAJOR] !== version[MAJOR] ||323 self[VERSION][MINOR] !== version[MINOR] || self[VERSION][PATCH] !== version[PATCH])324 return;325 }326 if (!maxSemver) {327 maxSemver = version;328 }329 else if (Semver.compare(version, maxSemver) === 1) {330 maxSemver = version;331 }332 });333 return maxSemver;334}335SemverRange.prototype.toString = function toString () {336 var version = this[VERSION];337 switch (this[TYPE]) {338 case WILDCARD_RANGE:339 return '*';340 case MAJOR_RANGE:341 if (version[MAJOR] === 0 && version[MINOR] === 0 && version[PATCH] === 0)342 return '0';343 if (version[PRE] && version[PRE].length === 0 && version[PATCH] === 0)344 return '^' + version[MAJOR] + '.' + version[MINOR];345 return '^' + version.toString();346 case STABLE_RANGE:347 if (version[PRE] && version[PRE].length === 0 && version[PATCH] === 0)348 return version[MAJOR] + '.' + version[MINOR];349 return '~' + version.toString();350 case EXACT_RANGE:351 return version.toString();352 }353}354SemverRange.match = function match (range, version, unstable) {355 unstable = unstable || false;356 if (!(version instanceof Semver))357 version = new Semver(version);358 return version.matches(range, unstable);359}360SemverRange.isValid = function isValid (range) {361 var semverRange = new SemverRange(range);362 return semverRange[TYPE] !== EXACT_RANGE || semverRange[VERSION][TAG] === undefined;363}364SemverRange.compare = function compare (r1, r2) {365 if (!(r1 instanceof SemverRange))366 r1 = new SemverRange(r1);367 if (!(r2 instanceof SemverRange))368 r2 = new SemverRange(r2);369 if (r1[TYPE] === WILDCARD_RANGE && r2[TYPE] === WILDCARD_RANGE)370 return 0;371 if (r1[TYPE] === WILDCARD_RANGE)372 return 1;373 if (r2[TYPE] === WILDCARD_RANGE)374 return -1;375 var cmp = Semver.compare(r1[VERSION], r2[VERSION]);376 if (cmp !== 0) {377 return cmp;378 }379 if (r1[TYPE] === r2[TYPE])380 return 0;381 return r1[TYPE] > r2[TYPE] ? 1 : -1;382}...

Full Screen

Full Screen

semver_v6.2.x.js

Source:semver_v6.2.x.js Github

copy

Full Screen

1// flow-typed signature: 0f3a5488505547a0a71d5b49cf5c29542// flow-typed version: 01cfe946d5/semver_v6.2.x/flow_>=v0.104.x3declare module "semver" {4 declare type Release =5 | "major"6 | "premajor"7 | "minor"8 | "preminor"9 | "patch"10 | "prepatch"11 | "prerelease";12 // The supported comparators are taken from the source here:13 // https://github.com/npm/node-semver/blob/8bd070b550db2646362c9883c8d008d32f66a234/semver.js#L62314 declare type Operator =15 | "==="16 | "!=="17 | "=="18 | "="19 | "" // Not sure why you would want this, but whatever.20 | "!="21 | ">"22 | ">="23 | "<"24 | "<=";25 declare class SemVer {26 build: Array<string>;27 loose: ?boolean;28 major: number;29 minor: number;30 patch: number;31 prerelease: Array<string | number>;32 raw: string;33 version: string;34 constructor(version: string | SemVer, options?: Options): SemVer;35 compare(other: string | SemVer): -1 | 0 | 1;36 compareMain(other: string | SemVer): -1 | 0 | 1;37 comparePre(other: string | SemVer): -1 | 0 | 1;38 compareBuild(other: string | SemVer): -1 | 0 | 1;39 format(): string;40 inc(release: Release, identifier: string): this;41 }42 declare class Comparator {43 options?: Options;44 operator: Operator;45 semver: SemVer;46 value: string;47 constructor(comp: string | Comparator, options?: Options): Comparator;48 parse(comp: string): void;49 test(version: string): boolean;50 }51 declare class Range {52 loose: ?boolean;53 raw: string;54 set: Array<Array<Comparator>>;55 constructor(range: string | Range, options?: Options): Range;56 format(): string;57 parseRange(range: string): Array<Comparator>;58 test(version: string): boolean;59 toString(): string;60 }61 declare var SEMVER_SPEC_VERSION: string;62 declare var re: Array<RegExp>;63 declare var src: Array<string>;64 declare type Options = {65 options?: Options,66 includePrerelease?: boolean,67 ...68 } | boolean;69 // Functions70 declare function valid(v: string | SemVer, options?: Options): string | null;71 declare function clean(v: string | SemVer, options?: Options): string | null;72 declare function inc(73 v: string | SemVer,74 release: Release,75 options?: Options,76 identifier?: string77 ): string | null;78 declare function inc(79 v: string | SemVer,80 release: Release,81 identifier: string82 ): string | null;83 declare function major(v: string | SemVer, options?: Options): number;84 declare function minor(v: string | SemVer, options?: Options): number;85 declare function patch(v: string | SemVer, options?: Options): number;86 declare function intersects(r1: string | SemVer, r2: string | SemVer, loose?: boolean): boolean;87 declare function minVersion(r: string | Range): Range | null;88 // Comparison89 declare function gt(90 v1: string | SemVer,91 v2: string | SemVer,92 options?: Options93 ): boolean;94 declare function gte(95 v1: string | SemVer,96 v2: string | SemVer,97 options?: Options98 ): boolean;99 declare function lt(100 v1: string | SemVer,101 v2: string | SemVer,102 options?: Options103 ): boolean;104 declare function lte(105 v1: string | SemVer,106 v2: string | SemVer,107 options?: Options108 ): boolean;109 declare function eq(110 v1: string | SemVer,111 v2: string | SemVer,112 options?: Options113 ): boolean;114 declare function neq(115 v1: string | SemVer,116 v2: string | SemVer,117 options?: Options118 ): boolean;119 declare function cmp(120 v1: string | SemVer,121 comparator: Operator,122 v2: string | SemVer,123 options?: Options124 ): boolean;125 declare function compare(126 v1: string | SemVer,127 v2: string | SemVer,128 options?: Options129 ): -1 | 0 | 1;130 declare function rcompare(131 v1: string | SemVer,132 v2: string | SemVer,133 options?: Options134 ): -1 | 0 | 1;135 declare function diff(v1: string | SemVer, v2: string | SemVer): ?Release;136 declare function intersects(comparator: Comparator): boolean;137 declare function sort(138 list: Array<string | SemVer>,139 options?: Options140 ): Array<string | SemVer>;141 declare function rsort(142 list: Array<string | SemVer>,143 options?: Options144 ): Array<string | SemVer>;145 declare function compareIdentifiers(146 v1: string | SemVer,147 v2: string | SemVer148 ): -1 | 0 | 1;149 declare function rcompareIdentifiers(150 v1: string | SemVer,151 v2: string | SemVer152 ): -1 | 0 | 1;153 // Ranges154 declare function validRange(155 range: string | Range,156 options?: Options157 ): string | null;158 declare function satisfies(159 version: string | SemVer,160 range: string | Range,161 options?: Options162 ): boolean;163 declare function maxSatisfying(164 versions: Array<string | SemVer>,165 range: string | Range,166 options?: Options167 ): string | SemVer | null;168 declare function minSatisfying(169 versions: Array<string | SemVer>,170 range: string | Range,171 options?: Options172 ): string | SemVer | null;173 declare function gtr(174 version: string | SemVer,175 range: string | Range,176 options?: Options177 ): boolean;178 declare function ltr(179 version: string | SemVer,180 range: string | Range,181 options?: Options182 ): boolean;183 declare function outside(184 version: string | SemVer,185 range: string | Range,186 hilo: ">" | "<",187 options?: Options188 ): boolean;189 declare function intersects(190 range: Range191 ): boolean;192 // Coercion193 declare function coerce(194 version: string | SemVer,195 options?: Options196 ): ?SemVer197 // Not explicitly documented, or deprecated198 declare function parse(version: string, options?: Options): ?SemVer;199 declare function toComparators(200 range: string | Range,201 options?: Options202 ): Array<Array<string>>;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1{2 "dependencies": {3 }4}5const semver = require('semver');6const version = require('./package.json').version;7module.exports = {8 version: semver.coerce(version).version9}10{11 "dependencies": {12 }13}14const semver = require('semver');15const version = require('./package.json').version;16module.exports = {17 version: semver.coerce(version).version18}19{20 "dependencies": {21 }22}23const semver = require('semver');24const version = require('./package.json').version;25module.exports = {26 version: semver.coerce(version).version27}28{29 "dependencies": {30 }31}32const semver = require('semver');33const version = require('./package.json').version;

Full Screen

Using AI Code Generation

copy

Full Screen

1import { semver } from 'storybook-root-components';2import { semver } from 'storybook-root-components';3import { semver } from 'storybook-root-components';4import { semver } from 'storybook-root-components';5import { semver } from 'storybook-root-components';6import { semver } from 'storybook-root-components';7import { semver } from 'storybook-root-components';8import { semver } from 'storybook-root-components';9import { semver } from 'storybook-root-components';10import { semver } from 'storybook-root-components';11import { semver } from 'storybook-root-components';12import { semver } from 'storybook-root-components';13import { semver } from 'storybook-root-components';14import { semver } from 'storybook-root-components';15import { semver } from 'storybook-root-components';16import { semver } from 'storybook-root-components';17import { semver } from 'storybook-root-components';18import { semver } from 'storybook-root-components';19import { semver } from 'storybook-root-components';

Full Screen

Using AI Code Generation

copy

Full Screen

1import { semver } from 'storybook-root';2const version = semver();3console.log(version);4module.exports = {5 webpackFinal: async (config, { configType }) => {6 config.resolve.alias['storybook-root'] = path.resolve(__dirname, '../../');7 }8}9import { addParameters } from '@storybook/react';10import { INITIAL_VIEWPORTS } from '@storybook/addon-viewport';11addParameters({12 viewport: {13 },14});15import { addons } from '@storybook/addons';16import { themes } from '@storybook/theming';17addons.setConfig({18});19 body {20 background-color: #f5f5f5;21 }22 .sbdocs.sbdocs-wrapper {23 padding: 0;24 }25 const body = document.querySelector('body');26 body.style.backgroundColor = '#f5f5f5';27import { addParameters } from '@storybook/react';28import { INITIAL_VIEWPORTS } from '@storybook/addon-viewport';29addParameters({30 viewport: {31 },32});

Full Screen

Using AI Code Generation

copy

Full Screen

1import { version } from 'storybook-root'2console.log('storybook-root version:', version)3"scripts": {4 },5"dependencies": {6 },

Full Screen

Using AI Code Generation

copy

Full Screen

1const semver = require('@storybook/semver');2const version = semver.coerce('v5.2.0-alpha.1');3console.log(version);4const semver = require('@storybook/semver');5const version = semver.coerce('v5.2.0-alpha.1');6console.log(version);7const semver = require('@storybook/semver');8const version = semver.coerce('v5.2.0-alpha.1');9console.log(version);10const semver = require('@storybook/semver');11const version = semver.coerce('v5.2.0-alpha.1');12console.log(version);13const semver = require('@storybook/semver');14const version = semver.coerce('v5.2.0-alpha.1');15console.log(version);16const semver = require('@storybook/semver');17const version = semver.coerce('v5.2.0-alpha.1');18console.log(version);19const semver = require('@storybook/semver');20const version = semver.coerce('v5.2.0-alpha.1');21console.log(version);22const semver = require('@storybook/semver');23const version = semver.coerce('v5.2.0-alpha.1');24console.log(version);25const semver = require('@storybook/semver');26const version = semver.coerce('v5.2.0-alpha.1');27console.log(version);

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run storybook-root automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful