Repositorio del curso CCOM4030 el semestre B91 del proyecto kilometro0

core.js 1.6KB

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