source: trip-planner-front/node_modules/resolve/lib/core.js@ 76712b2

Last change on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.6 KB
Line 
1var current = (process.versions && process.versions.node && process.versions.node.split('.')) || [];
2
3function specifierIncluded(specifier) {
4 var parts = specifier.split(' ');
5 var op = parts.length > 1 ? parts[0] : '=';
6 var versionParts = (parts.length > 1 ? parts[1] : parts[0]).split('.');
7
8 for (var i = 0; i < 3; ++i) {
9 var cur = parseInt(current[i] || 0, 10);
10 var ver = parseInt(versionParts[i] || 0, 10);
11 if (cur === ver) {
12 continue; // eslint-disable-line no-restricted-syntax, no-continue
13 }
14 if (op === '<') {
15 return cur < ver;
16 } else if (op === '>=') {
17 return cur >= ver;
18 } else {
19 return false;
20 }
21 }
22 return op === '>=';
23}
24
25function matchesRange(range) {
26 var specifiers = range.split(/ ?&& ?/);
27 if (specifiers.length === 0) { return false; }
28 for (var i = 0; i < specifiers.length; ++i) {
29 if (!specifierIncluded(specifiers[i])) { return false; }
30 }
31 return true;
32}
33
34function versionIncluded(specifierValue) {
35 if (typeof specifierValue === 'boolean') { return specifierValue; }
36 if (specifierValue && typeof specifierValue === 'object') {
37 for (var i = 0; i < specifierValue.length; ++i) {
38 if (matchesRange(specifierValue[i])) { return true; }
39 }
40 return false;
41 }
42 return matchesRange(specifierValue);
43}
44
45var data = require('./core.json');
46
47var core = {};
48for (var mod in data) { // eslint-disable-line no-restricted-syntax
49 if (Object.prototype.hasOwnProperty.call(data, mod)) {
50 core[mod] = versionIncluded(data[mod]);
51 }
52}
53module.exports = core;
Note: See TracBrowser for help on using the repository browser.