9.11.148 • Published 10 months ago

@firanorg/fugit-aliquam-nobis v9.11.148

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

@firanorg/fugit-aliquam-nobis

Build Status Coverage Status npm bundle size (minified + gzip)

Compare semver version strings to find greater, equal or lesser. Runs in the browser as well as Node.js/React Native etc. Has no dependencies and is tiny.

Supports the full semver specification including versions with different number of digits like 1.0.0, 1.0, 1 and pre-releases like 1.0.0-alpha. Additionally supports the following variations:

  • Wildcards for minor and patch version like 1.0.x or 1.0.*.
  • Chromium version numbers with 4 parts, e.g. version 25.0.1364.126.
  • Any leading v is ignored, e.g. v1.0 is interpreted as 1.0.
  • Leading zero is ignored, e.g. 1.01.1 is interpreted as 1.1.1.
  • npm version ranges, e.g. 1.2.7 || >=1.2.9 <2.0.0

Install

$ npm install @firanorg/fugit-aliquam-nobis

Note: Starting from v5 the main export is now named like so: import { compareVersions } from '@firanorg/fugit-aliquam-nobis'.

Note: Starting from v4 this library includes a ESM version which will automatically be selected by your bundler (webpack, parcel etc). The CJS/UMD version is lib/umd/index.js and the new ESM version is lib/esm/index.js.

Usage

Will return 1 if first version is greater, 0 if versions are equal, and -1 if the second version is greater:

import { compareVersions } from '@firanorg/fugit-aliquam-nobis';

compareVersions('11.1.1', '10.0.0'); //  1
compareVersions('10.0.0', '10.0.0'); //  0
compareVersions('10.0.0', '11.1.1'); // -1

Can also be used for sorting:

const versions = [
  '1.5.19',
  '1.2.3',
  '1.5.5'
]
const sorted = versions.sort(compareVersions);
/*
[
  '1.2.3',
  '1.5.5',
  '1.5.19'
]
*/

"Human Readable" Compare

The alternative compare function accepts an operator which will be more familiar to humans:

import { compare } from '@firanorg/fugit-aliquam-nobis';

compare('10.1.8', '10.0.4', '>');  // true
compare('10.0.1', '10.0.1', '=');  // true
compare('10.1.1', '10.2.2', '<');  // true
compare('10.1.1', '10.2.2', '<='); // true
compare('10.1.1', '10.2.2', '>='); // false

Version ranges

The satisfies function accepts a range to compare, compatible with npm package versioning:

import { satisfies } from '@firanorg/fugit-aliquam-nobis';

satisfies('10.0.1', '~10.0.0');  // true
satisfies('10.1.0', '~10.0.0');  // false
satisfies('10.1.2', '^10.0.0');  // true
satisfies('11.0.0', '^10.0.0');  // false
satisfies('10.1.8', '>10.0.4');  // true
satisfies('10.0.1', '=10.0.1');  // true
satisfies('10.1.1', '<10.2.2');  // true
satisfies('10.1.1', '<=10.2.2'); // true
satisfies('10.1.1', '>=10.2.2'); // false
satisfies('1.4.6', '1.2.7 || >=1.2.9 <2.0.0'); // true
satisfies('1.2.8', '1.2.7 || >=1.2.9 <2.0.0'); // false
satisfies('1.5.1', '1.2.3 - 2.3.4'); // true
satisfies('2.3.5', '1.2.3 - 2.3.4'); // false

Validate version numbers

Applies the same rules used comparing version numbers and returns a boolean:

import { validate } from '@firanorg/fugit-aliquam-nobis';

validate('1.0.0-rc.1'); // true
validate('1.0-rc.1');   // false
validate('foo');        // false

Validate version numbers (strict)

Validate version numbers strictly according to semver.org; 3 integers, no wildcards, no leading zero or "v" etc:

import { validateStrict } from '@firanorg/fugit-aliquam-nobis';

validate('1.0.0');      // true
validate('1.0.0-rc.1'); // true
validate('1.0');        // false
validate('1.x');        // false
validate('v1.02');      // false

Browser

If included directly in the browser, the functions above are available on the global window under the compareVersions object:

<script src=https://unpkg.com/@firanorg/fugit-aliquam-nobis/lib/umd/index.js></script>
<script>
  const { compareVersions, compare, satisfies, validate } = window.compareVersions
  console.log(compareVersions('11.0.0', '10.0.0'))
  console.log(compare('11.0.0', '10.0.0', '>'))
  console.log(satisfies('1.2.0', '^1.0.0'))
  console.log(validate('11.0.0'))
  console.log(validateStrict('11.0.0'))
</script>
arraysloadingtapiteratorBigInt64ArraySymbolbufferentriesCSSStyleDeclarationviewcommandqueueMicrotaskwalkmatchAllidbootstrap lessestreebrowserlistoperating-systemeslintrequestemojimetadatacurlES2018package.jsoncollectioncoercibleArray.prototype.findLastIndexglaciergdprsymlinkspasswordUint8ClampedArrayimporttakeRxJS__proto__cryptosearchtelephonebddprunefullwidthreduxhasdeepcloneidleconsolehashWeakSetobjectStreamscore-jsfiglettypedarraysstylingintrinsicmatchreact-hooksnested csschanneljsonpathecmascriptstyleArrayBufferObject.valuesspeedcallbackpersistentUnderscorestringifyvalidatefunctionperformantbeanstalk$.extendArraybuffersIteratorreadablenpmmonoreporoutingmulti-packageclass-validatorwatchertoolssuperagentconcatconcurrencymapString.prototype.matchAllminimalsymlinkremoveautoprefixerInt32ArrayperformanceinterruptsFloat32ArraySetObject.assignWeakMapassertslivelazypreserve-symlinksmochareact-testing-librarycloudfrontfpsinES2022fseventsterminalcorsECMAScript 6runtimereplaynodejsauthless compilergroupBytimecopyinspectserializetypescriptrm -rfconsumerouteasyncextensionworkerstyled-componentseslint-pluginscheme-validationschemeparsees2016protocol-buffersprivate dataECMAScript 3syntaxerrorshellcontainsfull-widthReactiveXstringifiersequencerfc4122pushfastifychromelinkUint8ArrayhasOwnwaittrimStartjoiebsassertionhttpsbannerstreamelbcss-in-jsarktypeutilityObject.entriesdeterministicsyntaxECMAScript 2019esnegativewidthcolumnArray.prototype.flattenfind-upasciiES2019lookendereveryObject.fromEntriesregexdeletecall-bindomitmodulesrestpicomatchcommanderinputquerystringinvariantmake dirbatchpredictablehookformxhrreadablestreamiamurlsesnamesfilterresolvecss variablewatchFileArray.prototype.containscomputed-typesfastsharedarraybuffervisualmime-dbglobalsFunction.prototype.namedependencieszeroerror-handlingttymatchesdatastatusenumerablestylescloudwatchtypeofbundlersuperstructexit-codebusyoptionsettingshelperslessECMAScript 5sigtermbluebirdlinuxspecpolyfillcommand-linehardlinksserializerlintPromisejQuerycalldebuggerdependency managerwriteboundObject.isgradients css3wordbreakpackagesmomentfileObject.definePropertyless mixinssetterelasticachees2018movehttpsafeio-tstrimEndmakeES2021uninstallStyleSheet-0karmahookstestingl10nproxyencryptiontddclonestarterfullES5moduleObject.getPrototypeOfdeepwatchdom-testing-libraryjestcoloursameValueZerocharacteropenmixins_.extendstyleguiderdseast-asian-widthECMAScript 2020configrmdirhasOwnPropertyglobReactiveExtensionsfastcopyECMAScript 2023mrudotenvdirvalidationwatchingagentnopeArray.prototype.filtereventDispatchersymbolsunicodeshrinkwrapdefinemiddlewareweaksetpackage managerparentlengthWebSocketsArray.prototype.findLastcodesexpressiones2015util.inspecta11yUint32Arrayjapanesemergeconnectclipipemkdirpoptimizerinternaltypaniones6getoptregexpcharactersextendmkdirssns
@firanorg/inventore-eligendi-quam@firanorg/inventore-hic-cumque@firanorg/illo-vel-est@firanorg/impedit-mollitia-sint@firanorg/id-et-quaerat@firanorg/amet-accusantium-dolor@firanorg/amet-consectetur-veniam@firanorg/cupiditate-veniam-ut@firanorg/autem-eveniet-earum@firanorg/corporis-iste-ullam@firanorg/commodi-recusandae-provident@firanorg/architecto-velit-odit@firanorg/exercitationem-debitis-laborum@firanorg/et-non-error@firanorg/sit-ex-nostrum@firanorg/necessitatibus-similique-nam@firanorg/laudantium-corrupti-itaque@firanorg/necessitatibus-sunt-quia@firanorg/sit-odit-numquam@firanorg/ut-officiis-et@firanorg/temporibus-quibusdam-non@firanorg/totam-excepturi-voluptas@firanorg/veniam-temporibus-accusantium@firanorg/soluta-perferendis-tenetur@firanorg/doloribus-dignissimos-nulla@firanorg/doloribus-laborum-qui@firanorg/dolore-cumque-distinctio@firanorg/delectus-eligendi-quae@firanorg/earum-impedit-cupiditate@firanorg/eligendi-aut-ducimus@firanorg/error-laboriosam-molestias@firanorg/doloribus-quasi-dolores@firanorg/dolorem-architecto-eum@firanorg/fuga-unde-tempore@firanorg/fuga-architecto-beatae@firanorg/explicabo-incidunt-facere@firanorg/hic-doloremque-est@firanorg/fuga-quis-optio@firanorg/hic-tempora-dignissimos@firanorg/harum-ad-explicabo@firanorg/iure-voluptates-nobis@firanorg/itaque-consectetur-velit@firanorg/sapiente-facere-aut@firanorg/ratione-iusto-numquam@firanorg/saepe-ut-natus@firanorg/sapiente-expedita-quidem@firanorg/repellat-expedita-autem@firanorg/alias-repellat-vero@firanorg/pariatur-officia-placeat@firanorg/odit-corrupti-aperiam@firanorg/optio-velit-culpa@firanorg/numquam-inventore-ad@firanorg/non-praesentium-sint@firanorg/nulla-cupiditate-ad@firanorg/neque-est-dolorum@firanorg/voluptatem-culpa-iusto@firanorg/voluptate-perspiciatis-placeat@firanorg/vero-laborum-tenetur@firanorg/accusamus-magnam-numquam@firanorg/a-neque-sunt@firanorg/ab-magni-explicabo@firanorg/ipsum-at-pariatur@firanorg/iste-dolor-omnis@firanorg/quasi-commodi-fugit@firanorg/quia-dolores-occaecati@firanorg/quia-cumque-perspiciatis@firanorg/perferendis-iusto-vitae@firanorg/placeat-illo-dolorem@firanorg/voluptatibus-soluta-dignissimos@firanorg/voluptatem-odit-et@firanorg/mollitia-molestias-accusamus@firanorg/maxime-deleniti-soluta
9.11.148

10 months ago

9.11.147

10 months ago

9.11.146

10 months ago

8.10.133

11 months ago

9.10.133

11 months ago

9.10.136

11 months ago

8.10.130

11 months ago

9.10.134

11 months ago

8.10.131

11 months ago

9.10.135

11 months ago

8.10.132

11 months ago

9.11.136

11 months ago

9.11.137

10 months ago

9.11.138

10 months ago

9.11.139

10 months ago

9.11.144

10 months ago

9.11.145

10 months ago

9.11.140

10 months ago

9.11.141

10 months ago

9.11.142

10 months ago

9.11.143

10 months ago

8.9.130

11 months ago

8.9.129

11 months ago

8.9.127

11 months ago

8.9.128

11 months ago

8.9.126

11 months ago

8.9.125

11 months ago

8.9.124

11 months ago

8.9.123

11 months ago

8.9.122

11 months ago

8.9.121

11 months ago

8.9.120

11 months ago

8.9.119

11 months ago

8.9.118

11 months ago

8.9.117

11 months ago

8.9.116

11 months ago

8.9.115

11 months ago

8.9.114

11 months ago

8.9.113

11 months ago

8.9.112

11 months ago

8.9.111

11 months ago

8.9.110

11 months ago

8.9.109

12 months ago

8.9.108

12 months ago

8.9.107

12 months ago

8.9.106

12 months ago

8.9.105

12 months ago

8.9.104

12 months ago

8.9.103

12 months ago

8.9.102

12 months ago

8.9.101

12 months ago

7.8.60

1 year ago

7.8.64

1 year ago

7.8.63

1 year ago

7.8.62

1 year ago

7.8.61

1 year ago

7.8.68

1 year ago

7.8.67

1 year ago

7.8.66

1 year ago

7.8.65

1 year ago

7.6.48

1 year ago

7.6.47

1 year ago

7.6.46

1 year ago

7.1.33

1 year ago

7.8.69

1 year ago

7.6.45

1 year ago

7.1.34

1 year ago

7.1.31

1 year ago

7.1.32

1 year ago

7.6.49

1 year ago

7.1.30

1 year ago

8.9.97

12 months ago

7.8.71

1 year ago

8.9.96

12 months ago

7.8.70

1 year ago

8.9.99

12 months ago

8.9.98

12 months ago

8.9.93

12 months ago

7.8.75

1 year ago

7.8.74

1 year ago

7.6.50

1 year ago

8.9.95

12 months ago

7.8.73

1 year ago

8.9.94

12 months ago

7.8.72

1 year ago

7.8.79

1 year ago

7.8.78

1 year ago

7.8.77

1 year ago

7.8.76

1 year ago

7.8.82

1 year ago

7.8.81

1 year ago

7.8.80

1 year ago

8.8.93

12 months ago

8.8.91

12 months ago

8.8.92

12 months ago

7.8.83

1 year ago

8.8.90

1 year ago

7.4.43

1 year ago

7.4.44

1 year ago

7.4.45

1 year ago

8.9.100

12 months ago

7.2.35

1 year ago

7.2.34

1 year ago

7.2.37

1 year ago

7.2.36

1 year ago

7.2.39

1 year ago

7.2.38

1 year ago

6.1.17

1 year ago

6.1.19

1 year ago

6.1.18

1 year ago

7.7.52

1 year ago

7.7.51

1 year ago

7.7.50

1 year ago

7.2.40

1 year ago

7.7.55

1 year ago

7.7.54

1 year ago

7.7.53

1 year ago

7.2.42

1 year ago

7.2.41

1 year ago

7.2.43

1 year ago

8.8.88

1 year ago

8.8.89

1 year ago

8.8.86

1 year ago

8.8.87

1 year ago

8.8.84

1 year ago

8.8.85

1 year ago

8.8.83

1 year ago

7.5.45

1 year ago

4.1.16

1 year ago

4.1.17

1 year ago

6.1.20

1 year ago

7.8.57

1 year ago

7.8.56

1 year ago

6.1.23

1 year ago

7.8.55

1 year ago

6.1.22

1 year ago

6.1.21

1 year ago

7.1.24

1 year ago

7.1.25

1 year ago

7.8.59

1 year ago

7.8.58

1 year ago

7.1.23

1 year ago

5.1.17

1 year ago

7.3.43

1 year ago

7.1.28

1 year ago

7.1.29

1 year ago

7.1.26

1 year ago

7.1.27

1 year ago

4.1.15

1 year ago

4.1.11

1 year ago

4.1.12

1 year ago

4.1.13

1 year ago

4.1.14

1 year ago

4.1.10

1 year ago

4.1.9

1 year ago

4.1.8

1 year ago

4.1.7

1 year ago

4.1.6

1 year ago

4.1.5

1 year ago

3.1.5

1 year ago

3.1.4

1 year ago

2.1.4

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago