3 var has = require('has');
5 function specifierIncluded(current, specifier) {
6 var nodeParts = current.split('.');
7 var parts = specifier.split(' ');
8 var op = parts.length > 1 ? parts[0] : '=';
9 var versionParts = (parts.length > 1 ? parts[1] : parts[0]).split('.');
11 for (var i = 0; i < 3; ++i) {
12 var cur = parseInt(nodeParts[i] || 0, 10);
13 var ver = parseInt(versionParts[i] || 0, 10);
15 continue; // eslint-disable-line no-restricted-syntax, no-continue
28 function matchesRange(current, range) {
29 var specifiers = range.split(/ ?&& ?/);
30 if (specifiers.length === 0) {
33 for (var i = 0; i < specifiers.length; ++i) {
34 if (!specifierIncluded(current, specifiers[i])) {
41 function versionIncluded(nodeVersion, specifierValue) {
42 if (typeof specifierValue === 'boolean') {
43 return specifierValue;
46 var current = typeof nodeVersion === 'undefined'
47 ? process.versions && process.versions.node && process.versions.node
50 if (typeof current !== 'string') {
51 throw new TypeError(typeof nodeVersion === 'undefined' ? 'Unable to determine current node version' : 'If provided, a valid node version is required');
54 if (specifierValue && typeof specifierValue === 'object') {
55 for (var i = 0; i < specifierValue.length; ++i) {
56 if (matchesRange(current, specifierValue[i])) {
62 return matchesRange(current, specifierValue);
65 var data = require('./core.json');
67 module.exports = function isCore(x, nodeVersion) {
68 return has(data, x) && versionIncluded(nodeVersion, data[x]);