Skip to content

Commit ed8f81b

Browse files
committedApr 5, 2023
[Refactor] deprecated lib/core.js now uses is-core-module
1 parent 1454fdf commit ed8f81b

File tree

1 file changed

+3
-43
lines changed

1 file changed

+3
-43
lines changed
 

‎lib/core.js

+3-43
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,12 @@
1-
var current = (process.versions && process.versions.node && process.versions.node.split('.')) || [];
2-
3-
function 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-
}
19-
return false;
20-
}
21-
return op === '>=';
22-
}
23-
24-
function matchesRange(range) {
25-
var specifiers = range.split(/ ?&& ?/);
26-
if (specifiers.length === 0) { return false; }
27-
for (var i = 0; i < specifiers.length; ++i) {
28-
if (!specifierIncluded(specifiers[i])) { return false; }
29-
}
30-
return true;
31-
}
32-
33-
function versionIncluded(specifierValue) {
34-
if (typeof specifierValue === 'boolean') { return specifierValue; }
35-
if (specifierValue && typeof specifierValue === 'object') {
36-
for (var i = 0; i < specifierValue.length; ++i) {
37-
if (matchesRange(specifierValue[i])) { return true; }
38-
}
39-
return false;
40-
}
41-
return matchesRange(specifierValue);
42-
}
1+
'use strict';
432

3+
var isCoreModule = require('is-core-module');
444
var data = require('./core.json');
455

466
var core = {};
477
for (var mod in data) { // eslint-disable-line no-restricted-syntax
488
if (Object.prototype.hasOwnProperty.call(data, mod)) {
49-
core[mod] = versionIncluded(data[mod]);
9+
core[mod] = isCoreModule(mod);
5010
}
5111
}
5212
module.exports = core;

0 commit comments

Comments
 (0)
Please sign in to comment.