node-datachannel 0.2.2 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/.editorconfig +12 -0
  2. package/.eslintignore +2 -0
  3. package/.eslintrc.js +8 -0
  4. package/.github/FUNDING.yml +2 -0
  5. package/.github/workflows/build-linux.yml +5 -3
  6. package/.github/workflows/build-mac.yml +1 -1
  7. package/.github/workflows/build-win.yml +4 -10
  8. package/.prettierrc.js +7 -0
  9. package/CMakeLists.txt +8 -2
  10. package/README.md +4 -4
  11. package/lib/datachannel-stream.js +97 -0
  12. package/lib/index.d.ts +60 -53
  13. package/lib/index.js +5 -2
  14. package/node_modules/decompress-response/index.d.ts +14 -21
  15. package/node_modules/decompress-response/index.js +34 -16
  16. package/node_modules/decompress-response/license +1 -1
  17. package/node_modules/decompress-response/package.json +23 -17
  18. package/node_modules/decompress-response/readme.md +2 -6
  19. package/node_modules/detect-libc/README.md +124 -42
  20. package/node_modules/detect-libc/index.d.ts +11 -0
  21. package/node_modules/detect-libc/lib/detect-libc.js +166 -80
  22. package/node_modules/detect-libc/lib/process.js +16 -0
  23. package/node_modules/detect-libc/package.json +20 -19
  24. package/node_modules/{semver → lru-cache}/LICENSE +0 -0
  25. package/node_modules/lru-cache/README.md +166 -0
  26. package/node_modules/lru-cache/index.js +334 -0
  27. package/node_modules/lru-cache/node_modules/yallist/LICENSE +15 -0
  28. package/node_modules/lru-cache/node_modules/yallist/README.md +204 -0
  29. package/node_modules/lru-cache/node_modules/yallist/iterator.js +8 -0
  30. package/node_modules/lru-cache/node_modules/yallist/package.json +65 -0
  31. package/node_modules/lru-cache/node_modules/yallist/yallist.js +426 -0
  32. package/node_modules/lru-cache/package.json +75 -0
  33. package/node_modules/mimic-response/index.d.ts +2 -2
  34. package/node_modules/mimic-response/index.js +41 -2
  35. package/node_modules/mimic-response/package.json +17 -17
  36. package/node_modules/mimic-response/readme.md +22 -1
  37. package/node_modules/minimist/index.js +6 -2
  38. package/node_modules/minimist/package.json +10 -10
  39. package/node_modules/minimist/readme.markdown +4 -1
  40. package/node_modules/minimist/test/proto.js +16 -0
  41. package/node_modules/node-abi/.circleci/config.yml +63 -0
  42. package/node_modules/node-abi/.releaserc.json +9 -0
  43. package/node_modules/node-abi/abi_registry.json +45 -3
  44. package/node_modules/node-abi/index.js +5 -2
  45. package/node_modules/node-abi/node_modules/semver/CHANGELOG.md +111 -0
  46. package/node_modules/node-abi/node_modules/semver/LICENSE +15 -0
  47. package/node_modules/{semver → node-abi/node_modules/semver}/README.md +180 -26
  48. package/node_modules/node-abi/node_modules/semver/bin/semver.js +173 -0
  49. package/node_modules/node-abi/node_modules/semver/classes/comparator.js +135 -0
  50. package/node_modules/node-abi/node_modules/semver/classes/index.js +5 -0
  51. package/node_modules/node-abi/node_modules/semver/classes/range.js +510 -0
  52. package/node_modules/node-abi/node_modules/semver/classes/semver.js +287 -0
  53. package/node_modules/node-abi/node_modules/semver/functions/clean.js +6 -0
  54. package/node_modules/node-abi/node_modules/semver/functions/cmp.js +48 -0
  55. package/node_modules/node-abi/node_modules/semver/functions/coerce.js +51 -0
  56. package/node_modules/node-abi/node_modules/semver/functions/compare-build.js +7 -0
  57. package/node_modules/node-abi/node_modules/semver/functions/compare-loose.js +3 -0
  58. package/node_modules/node-abi/node_modules/semver/functions/compare.js +5 -0
  59. package/node_modules/node-abi/node_modules/semver/functions/diff.js +23 -0
  60. package/node_modules/node-abi/node_modules/semver/functions/eq.js +3 -0
  61. package/node_modules/node-abi/node_modules/semver/functions/gt.js +3 -0
  62. package/node_modules/node-abi/node_modules/semver/functions/gte.js +3 -0
  63. package/node_modules/node-abi/node_modules/semver/functions/inc.js +15 -0
  64. package/node_modules/node-abi/node_modules/semver/functions/lt.js +3 -0
  65. package/node_modules/node-abi/node_modules/semver/functions/lte.js +3 -0
  66. package/node_modules/node-abi/node_modules/semver/functions/major.js +3 -0
  67. package/node_modules/node-abi/node_modules/semver/functions/minor.js +3 -0
  68. package/node_modules/node-abi/node_modules/semver/functions/neq.js +3 -0
  69. package/node_modules/node-abi/node_modules/semver/functions/parse.js +33 -0
  70. package/node_modules/node-abi/node_modules/semver/functions/patch.js +3 -0
  71. package/node_modules/node-abi/node_modules/semver/functions/prerelease.js +6 -0
  72. package/node_modules/node-abi/node_modules/semver/functions/rcompare.js +3 -0
  73. package/node_modules/node-abi/node_modules/semver/functions/rsort.js +3 -0
  74. package/node_modules/node-abi/node_modules/semver/functions/satisfies.js +10 -0
  75. package/node_modules/node-abi/node_modules/semver/functions/sort.js +3 -0
  76. package/node_modules/node-abi/node_modules/semver/functions/valid.js +6 -0
  77. package/node_modules/node-abi/node_modules/semver/index.js +48 -0
  78. package/node_modules/node-abi/node_modules/semver/internal/constants.js +17 -0
  79. package/node_modules/node-abi/node_modules/semver/internal/debug.js +9 -0
  80. package/node_modules/node-abi/node_modules/semver/internal/identifiers.js +23 -0
  81. package/node_modules/node-abi/node_modules/semver/internal/parse-options.js +11 -0
  82. package/node_modules/node-abi/node_modules/semver/internal/re.js +182 -0
  83. package/node_modules/{semver → node-abi/node_modules/semver}/package.json +32 -23
  84. package/node_modules/node-abi/node_modules/semver/preload.js +2 -0
  85. package/node_modules/{semver → node-abi/node_modules/semver}/range.bnf +0 -0
  86. package/node_modules/node-abi/node_modules/semver/ranges/gtr.js +4 -0
  87. package/node_modules/node-abi/node_modules/semver/ranges/intersects.js +7 -0
  88. package/node_modules/node-abi/node_modules/semver/ranges/ltr.js +4 -0
  89. package/node_modules/node-abi/node_modules/semver/ranges/max-satisfying.js +25 -0
  90. package/node_modules/node-abi/node_modules/semver/ranges/min-satisfying.js +24 -0
  91. package/node_modules/node-abi/node_modules/semver/ranges/min-version.js +60 -0
  92. package/node_modules/node-abi/node_modules/semver/ranges/outside.js +80 -0
  93. package/node_modules/node-abi/node_modules/semver/ranges/simplify.js +44 -0
  94. package/node_modules/node-abi/node_modules/semver/ranges/subset.js +222 -0
  95. package/node_modules/node-abi/node_modules/semver/ranges/to-comparators.js +8 -0
  96. package/node_modules/node-abi/node_modules/semver/ranges/valid.js +11 -0
  97. package/node_modules/node-abi/package.json +21 -17
  98. package/node_modules/node-abi/test/index.js +7 -15
  99. package/node_modules/prebuild-install/CHANGELOG.md +24 -7
  100. package/node_modules/prebuild-install/README.md +24 -4
  101. package/node_modules/prebuild-install/asset.js +10 -10
  102. package/node_modules/prebuild-install/bin.js +13 -13
  103. package/node_modules/prebuild-install/download.js +22 -22
  104. package/node_modules/prebuild-install/log.js +4 -4
  105. package/node_modules/prebuild-install/package.json +18 -19
  106. package/node_modules/prebuild-install/proxy.js +10 -10
  107. package/node_modules/prebuild-install/rc.js +12 -12
  108. package/node_modules/prebuild-install/util.js +14 -14
  109. package/node_modules/simple-get/.github/dependabot.yml +15 -0
  110. package/node_modules/simple-get/.github/workflows/ci.yml +23 -0
  111. package/node_modules/simple-get/README.md +17 -3
  112. package/node_modules/simple-get/index.js +9 -0
  113. package/node_modules/simple-get/package.json +27 -13
  114. package/package.json +15 -6
  115. package/src/data-channel-wrapper.cpp +56 -22
  116. package/src/data-channel-wrapper.h +3 -0
  117. package/src/media-audio-wrapper.cpp +7 -7
  118. package/src/media-track-wrapper.cpp +40 -21
  119. package/src/media-track-wrapper.h +2 -0
  120. package/src/media-video-wrapper.cpp +5 -5
  121. package/src/peer-connection-wrapper.cpp +48 -27
  122. package/src/peer-connection-wrapper.h +2 -0
  123. package/test/connectivity.js +6 -6
  124. package/test/test.js +46 -1
  125. package/node_modules/detect-libc/.npmignore +0 -7
  126. package/node_modules/detect-libc/bin/detect-libc.js +0 -18
  127. package/node_modules/node-abi/.travis.yml +0 -17
  128. package/node_modules/semver/CHANGELOG.md +0 -39
  129. package/node_modules/semver/bin/semver +0 -160
  130. package/node_modules/semver/semver.js +0 -1483
@@ -0,0 +1,11 @@
1
+ // parse out just the options we care about so we always get a consistent
2
+ // obj with keys in a consistent order.
3
+ const opts = ['includePrerelease', 'loose', 'rtl']
4
+ const parseOptions = options =>
5
+ !options ? {}
6
+ : typeof options !== 'object' ? { loose: true }
7
+ : opts.filter(k => options[k]).reduce((options, k) => {
8
+ options[k] = true
9
+ return options
10
+ }, {})
11
+ module.exports = parseOptions
@@ -0,0 +1,182 @@
1
+ const { MAX_SAFE_COMPONENT_LENGTH } = require('./constants')
2
+ const debug = require('./debug')
3
+ exports = module.exports = {}
4
+
5
+ // The actual regexps go on exports.re
6
+ const re = exports.re = []
7
+ const src = exports.src = []
8
+ const t = exports.t = {}
9
+ let R = 0
10
+
11
+ const createToken = (name, value, isGlobal) => {
12
+ const index = R++
13
+ debug(index, value)
14
+ t[name] = index
15
+ src[index] = value
16
+ re[index] = new RegExp(value, isGlobal ? 'g' : undefined)
17
+ }
18
+
19
+ // The following Regular Expressions can be used for tokenizing,
20
+ // validating, and parsing SemVer version strings.
21
+
22
+ // ## Numeric Identifier
23
+ // A single `0`, or a non-zero digit followed by zero or more digits.
24
+
25
+ createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*')
26
+ createToken('NUMERICIDENTIFIERLOOSE', '[0-9]+')
27
+
28
+ // ## Non-numeric Identifier
29
+ // Zero or more digits, followed by a letter or hyphen, and then zero or
30
+ // more letters, digits, or hyphens.
31
+
32
+ createToken('NONNUMERICIDENTIFIER', '\\d*[a-zA-Z-][a-zA-Z0-9-]*')
33
+
34
+ // ## Main Version
35
+ // Three dot-separated numeric identifiers.
36
+
37
+ createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` +
38
+ `(${src[t.NUMERICIDENTIFIER]})\\.` +
39
+ `(${src[t.NUMERICIDENTIFIER]})`)
40
+
41
+ createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
42
+ `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
43
+ `(${src[t.NUMERICIDENTIFIERLOOSE]})`)
44
+
45
+ // ## Pre-release Version Identifier
46
+ // A numeric identifier, or a non-numeric identifier.
47
+
48
+ createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER]
49
+ }|${src[t.NONNUMERICIDENTIFIER]})`)
50
+
51
+ createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE]
52
+ }|${src[t.NONNUMERICIDENTIFIER]})`)
53
+
54
+ // ## Pre-release Version
55
+ // Hyphen, followed by one or more dot-separated pre-release version
56
+ // identifiers.
57
+
58
+ createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]
59
+ }(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`)
60
+
61
+ createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]
62
+ }(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`)
63
+
64
+ // ## Build Metadata Identifier
65
+ // Any combination of digits, letters, or hyphens.
66
+
67
+ createToken('BUILDIDENTIFIER', '[0-9A-Za-z-]+')
68
+
69
+ // ## Build Metadata
70
+ // Plus sign, followed by one or more period-separated build metadata
71
+ // identifiers.
72
+
73
+ createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER]
74
+ }(?:\\.${src[t.BUILDIDENTIFIER]})*))`)
75
+
76
+ // ## Full Version String
77
+ // A main version, followed optionally by a pre-release version and
78
+ // build metadata.
79
+
80
+ // Note that the only major, minor, patch, and pre-release sections of
81
+ // the version string are capturing groups. The build metadata is not a
82
+ // capturing group, because it should not ever be used in version
83
+ // comparison.
84
+
85
+ createToken('FULLPLAIN', `v?${src[t.MAINVERSION]
86
+ }${src[t.PRERELEASE]}?${
87
+ src[t.BUILD]}?`)
88
+
89
+ createToken('FULL', `^${src[t.FULLPLAIN]}$`)
90
+
91
+ // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
92
+ // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
93
+ // common in the npm registry.
94
+ createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE]
95
+ }${src[t.PRERELEASELOOSE]}?${
96
+ src[t.BUILD]}?`)
97
+
98
+ createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`)
99
+
100
+ createToken('GTLT', '((?:<|>)?=?)')
101
+
102
+ // Something like "2.*" or "1.2.x".
103
+ // Note that "x.x" is a valid xRange identifer, meaning "any version"
104
+ // Only the first item is strictly required.
105
+ createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`)
106
+ createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`)
107
+
108
+ createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` +
109
+ `(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
110
+ `(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
111
+ `(?:${src[t.PRERELEASE]})?${
112
+ src[t.BUILD]}?` +
113
+ `)?)?`)
114
+
115
+ createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` +
116
+ `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
117
+ `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
118
+ `(?:${src[t.PRERELEASELOOSE]})?${
119
+ src[t.BUILD]}?` +
120
+ `)?)?`)
121
+
122
+ createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`)
123
+ createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`)
124
+
125
+ // Coercion.
126
+ // Extract anything that could conceivably be a part of a valid semver
127
+ createToken('COERCE', `${'(^|[^\\d])' +
128
+ '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` +
129
+ `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
130
+ `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
131
+ `(?:$|[^\\d])`)
132
+ createToken('COERCERTL', src[t.COERCE], true)
133
+
134
+ // Tilde ranges.
135
+ // Meaning is "reasonably at or greater than"
136
+ createToken('LONETILDE', '(?:~>?)')
137
+
138
+ createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true)
139
+ exports.tildeTrimReplace = '$1~'
140
+
141
+ createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`)
142
+ createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`)
143
+
144
+ // Caret ranges.
145
+ // Meaning is "at least and backwards compatible with"
146
+ createToken('LONECARET', '(?:\\^)')
147
+
148
+ createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true)
149
+ exports.caretTrimReplace = '$1^'
150
+
151
+ createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`)
152
+ createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`)
153
+
154
+ // A simple gt/lt/eq thing, or just "" to indicate "any version"
155
+ createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`)
156
+ createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`)
157
+
158
+ // An expression to strip any whitespace between the gtlt and the thing
159
+ // it modifies, so that `> 1.2.3` ==> `>1.2.3`
160
+ createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]
161
+ }\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true)
162
+ exports.comparatorTrimReplace = '$1$2$3'
163
+
164
+ // Something like `1.2.3 - 1.2.4`
165
+ // Note that these all use the loose form, because they'll be
166
+ // checked against either the strict or loose comparator form
167
+ // later.
168
+ createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` +
169
+ `\\s+-\\s+` +
170
+ `(${src[t.XRANGEPLAIN]})` +
171
+ `\\s*$`)
172
+
173
+ createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` +
174
+ `\\s+-\\s+` +
175
+ `(${src[t.XRANGEPLAINLOOSE]})` +
176
+ `\\s*$`)
177
+
178
+ // Star ranges basically just allow anything at all.
179
+ createToken('STAR', '(<|>)?=?\\s*\\*')
180
+ // >=0.0.0 is like a star
181
+ createToken('GTE0', '^\\s*>=\\s*0\.0\.0\\s*$')
182
+ createToken('GTE0PRE', '^\\s*>=\\s*0\.0\.0-0\\s*$')
@@ -1,67 +1,76 @@
1
1
  {
2
2
  "_args": [
3
3
  [
4
- "semver@5.7.1",
4
+ "semver@7.3.5",
5
5
  "/home/runner/work/node-datachannel/node-datachannel"
6
6
  ]
7
7
  ],
8
- "_from": "semver@5.7.1",
9
- "_id": "semver@5.7.1",
8
+ "_from": "semver@7.3.5",
9
+ "_id": "semver@7.3.5",
10
10
  "_inBundle": false,
11
- "_integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==",
12
- "_location": "/semver",
11
+ "_integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==",
12
+ "_location": "/node-abi/semver",
13
13
  "_phantomChildren": {},
14
14
  "_requested": {
15
15
  "type": "version",
16
16
  "registry": true,
17
- "raw": "semver@5.7.1",
17
+ "raw": "semver@7.3.5",
18
18
  "name": "semver",
19
19
  "escapedName": "semver",
20
- "rawSpec": "5.7.1",
20
+ "rawSpec": "7.3.5",
21
21
  "saveSpec": null,
22
- "fetchSpec": "5.7.1"
22
+ "fetchSpec": "7.3.5"
23
23
  },
24
24
  "_requiredBy": [
25
- "/cmake-js",
26
- "/node-abi",
27
- "/node-gyp",
28
- "/node-ninja",
29
- "/prebuild/cmake-js"
25
+ "/node-abi"
30
26
  ],
31
- "_resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
32
- "_spec": "5.7.1",
27
+ "_resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz",
28
+ "_spec": "7.3.5",
33
29
  "_where": "/home/runner/work/node-datachannel/node-datachannel",
34
30
  "bin": {
35
- "semver": "bin/semver"
31
+ "semver": "bin/semver.js"
36
32
  },
37
33
  "bugs": {
38
34
  "url": "https://github.com/npm/node-semver/issues"
39
35
  },
36
+ "dependencies": {
37
+ "lru-cache": "^6.0.0"
38
+ },
40
39
  "description": "The semantic version parser used by npm.",
41
40
  "devDependencies": {
42
- "tap": "^13.0.0-rc.18"
41
+ "tap": "^14.10.7"
42
+ },
43
+ "engines": {
44
+ "node": ">=10"
43
45
  },
44
46
  "files": [
45
- "bin",
47
+ "bin/**/*.js",
46
48
  "range.bnf",
47
- "semver.js"
49
+ "classes/**/*.js",
50
+ "functions/**/*.js",
51
+ "internal/**/*.js",
52
+ "ranges/**/*.js",
53
+ "index.js",
54
+ "preload.js"
48
55
  ],
49
56
  "homepage": "https://github.com/npm/node-semver#readme",
50
57
  "license": "ISC",
51
- "main": "semver.js",
58
+ "main": "index.js",
52
59
  "name": "semver",
53
60
  "repository": {
54
61
  "type": "git",
55
62
  "url": "git+https://github.com/npm/node-semver.git"
56
63
  },
57
64
  "scripts": {
58
- "postpublish": "git push origin --all; git push origin --tags",
65
+ "postpublish": "git push origin --follow-tags",
59
66
  "postversion": "npm publish",
60
67
  "preversion": "npm test",
68
+ "snap": "tap",
61
69
  "test": "tap"
62
70
  },
63
71
  "tap": {
64
- "check-coverage": true
72
+ "check-coverage": true,
73
+ "coverage-map": "map.js"
65
74
  },
66
- "version": "5.7.1"
75
+ "version": "7.3.5"
67
76
  }
@@ -0,0 +1,2 @@
1
+ // XXX remove in v8 or beyond
2
+ module.exports = require('./index.js')
@@ -0,0 +1,4 @@
1
+ // Determine if version is greater than all the versions possible in the range.
2
+ const outside = require('./outside')
3
+ const gtr = (version, range, options) => outside(version, range, '>', options)
4
+ module.exports = gtr
@@ -0,0 +1,7 @@
1
+ const Range = require('../classes/range')
2
+ const intersects = (r1, r2, options) => {
3
+ r1 = new Range(r1, options)
4
+ r2 = new Range(r2, options)
5
+ return r1.intersects(r2)
6
+ }
7
+ module.exports = intersects
@@ -0,0 +1,4 @@
1
+ const outside = require('./outside')
2
+ // Determine if version is less than all the versions possible in the range
3
+ const ltr = (version, range, options) => outside(version, range, '<', options)
4
+ module.exports = ltr
@@ -0,0 +1,25 @@
1
+ const SemVer = require('../classes/semver')
2
+ const Range = require('../classes/range')
3
+
4
+ const maxSatisfying = (versions, range, options) => {
5
+ let max = null
6
+ let maxSV = null
7
+ let rangeObj = null
8
+ try {
9
+ rangeObj = new Range(range, options)
10
+ } catch (er) {
11
+ return null
12
+ }
13
+ versions.forEach((v) => {
14
+ if (rangeObj.test(v)) {
15
+ // satisfies(v, range, options)
16
+ if (!max || maxSV.compare(v) === -1) {
17
+ // compare(max, v, true)
18
+ max = v
19
+ maxSV = new SemVer(max, options)
20
+ }
21
+ }
22
+ })
23
+ return max
24
+ }
25
+ module.exports = maxSatisfying
@@ -0,0 +1,24 @@
1
+ const SemVer = require('../classes/semver')
2
+ const Range = require('../classes/range')
3
+ const minSatisfying = (versions, range, options) => {
4
+ let min = null
5
+ let minSV = null
6
+ let rangeObj = null
7
+ try {
8
+ rangeObj = new Range(range, options)
9
+ } catch (er) {
10
+ return null
11
+ }
12
+ versions.forEach((v) => {
13
+ if (rangeObj.test(v)) {
14
+ // satisfies(v, range, options)
15
+ if (!min || minSV.compare(v) === 1) {
16
+ // compare(min, v, true)
17
+ min = v
18
+ minSV = new SemVer(min, options)
19
+ }
20
+ }
21
+ })
22
+ return min
23
+ }
24
+ module.exports = minSatisfying
@@ -0,0 +1,60 @@
1
+ const SemVer = require('../classes/semver')
2
+ const Range = require('../classes/range')
3
+ const gt = require('../functions/gt')
4
+
5
+ const minVersion = (range, loose) => {
6
+ range = new Range(range, loose)
7
+
8
+ let minver = new SemVer('0.0.0')
9
+ if (range.test(minver)) {
10
+ return minver
11
+ }
12
+
13
+ minver = new SemVer('0.0.0-0')
14
+ if (range.test(minver)) {
15
+ return minver
16
+ }
17
+
18
+ minver = null
19
+ for (let i = 0; i < range.set.length; ++i) {
20
+ const comparators = range.set[i]
21
+
22
+ let setMin = null
23
+ comparators.forEach((comparator) => {
24
+ // Clone to avoid manipulating the comparator's semver object.
25
+ const compver = new SemVer(comparator.semver.version)
26
+ switch (comparator.operator) {
27
+ case '>':
28
+ if (compver.prerelease.length === 0) {
29
+ compver.patch++
30
+ } else {
31
+ compver.prerelease.push(0)
32
+ }
33
+ compver.raw = compver.format()
34
+ /* fallthrough */
35
+ case '':
36
+ case '>=':
37
+ if (!setMin || gt(compver, setMin)) {
38
+ setMin = compver
39
+ }
40
+ break
41
+ case '<':
42
+ case '<=':
43
+ /* Ignore maximum versions */
44
+ break
45
+ /* istanbul ignore next */
46
+ default:
47
+ throw new Error(`Unexpected operation: ${comparator.operator}`)
48
+ }
49
+ })
50
+ if (setMin && (!minver || gt(minver, setMin)))
51
+ minver = setMin
52
+ }
53
+
54
+ if (minver && range.test(minver)) {
55
+ return minver
56
+ }
57
+
58
+ return null
59
+ }
60
+ module.exports = minVersion
@@ -0,0 +1,80 @@
1
+ const SemVer = require('../classes/semver')
2
+ const Comparator = require('../classes/comparator')
3
+ const {ANY} = Comparator
4
+ const Range = require('../classes/range')
5
+ const satisfies = require('../functions/satisfies')
6
+ const gt = require('../functions/gt')
7
+ const lt = require('../functions/lt')
8
+ const lte = require('../functions/lte')
9
+ const gte = require('../functions/gte')
10
+
11
+ const outside = (version, range, hilo, options) => {
12
+ version = new SemVer(version, options)
13
+ range = new Range(range, options)
14
+
15
+ let gtfn, ltefn, ltfn, comp, ecomp
16
+ switch (hilo) {
17
+ case '>':
18
+ gtfn = gt
19
+ ltefn = lte
20
+ ltfn = lt
21
+ comp = '>'
22
+ ecomp = '>='
23
+ break
24
+ case '<':
25
+ gtfn = lt
26
+ ltefn = gte
27
+ ltfn = gt
28
+ comp = '<'
29
+ ecomp = '<='
30
+ break
31
+ default:
32
+ throw new TypeError('Must provide a hilo val of "<" or ">"')
33
+ }
34
+
35
+ // If it satisfies the range it is not outside
36
+ if (satisfies(version, range, options)) {
37
+ return false
38
+ }
39
+
40
+ // From now on, variable terms are as if we're in "gtr" mode.
41
+ // but note that everything is flipped for the "ltr" function.
42
+
43
+ for (let i = 0; i < range.set.length; ++i) {
44
+ const comparators = range.set[i]
45
+
46
+ let high = null
47
+ let low = null
48
+
49
+ comparators.forEach((comparator) => {
50
+ if (comparator.semver === ANY) {
51
+ comparator = new Comparator('>=0.0.0')
52
+ }
53
+ high = high || comparator
54
+ low = low || comparator
55
+ if (gtfn(comparator.semver, high.semver, options)) {
56
+ high = comparator
57
+ } else if (ltfn(comparator.semver, low.semver, options)) {
58
+ low = comparator
59
+ }
60
+ })
61
+
62
+ // If the edge version comparator has a operator then our version
63
+ // isn't outside it
64
+ if (high.operator === comp || high.operator === ecomp) {
65
+ return false
66
+ }
67
+
68
+ // If the lowest version comparator has an operator and our version
69
+ // is less than it then it isn't higher than the range
70
+ if ((!low.operator || low.operator === comp) &&
71
+ ltefn(version, low.semver)) {
72
+ return false
73
+ } else if (low.operator === ecomp && ltfn(version, low.semver)) {
74
+ return false
75
+ }
76
+ }
77
+ return true
78
+ }
79
+
80
+ module.exports = outside
@@ -0,0 +1,44 @@
1
+ // given a set of versions and a range, create a "simplified" range
2
+ // that includes the same versions that the original range does
3
+ // If the original range is shorter than the simplified one, return that.
4
+ const satisfies = require('../functions/satisfies.js')
5
+ const compare = require('../functions/compare.js')
6
+ module.exports = (versions, range, options) => {
7
+ const set = []
8
+ let min = null
9
+ let prev = null
10
+ const v = versions.sort((a, b) => compare(a, b, options))
11
+ for (const version of v) {
12
+ const included = satisfies(version, range, options)
13
+ if (included) {
14
+ prev = version
15
+ if (!min)
16
+ min = version
17
+ } else {
18
+ if (prev) {
19
+ set.push([min, prev])
20
+ }
21
+ prev = null
22
+ min = null
23
+ }
24
+ }
25
+ if (min)
26
+ set.push([min, null])
27
+
28
+ const ranges = []
29
+ for (const [min, max] of set) {
30
+ if (min === max)
31
+ ranges.push(min)
32
+ else if (!max && min === v[0])
33
+ ranges.push('*')
34
+ else if (!max)
35
+ ranges.push(`>=${min}`)
36
+ else if (min === v[0])
37
+ ranges.push(`<=${max}`)
38
+ else
39
+ ranges.push(`${min} - ${max}`)
40
+ }
41
+ const simplified = ranges.join(' || ')
42
+ const original = typeof range.raw === 'string' ? range.raw : String(range)
43
+ return simplified.length < original.length ? simplified : range
44
+ }