PHP 8.2.30
Preview: helpers.js Size: 1.78 KB
/home/byroehnu/.trash/node_modules11/core-js-compat/helpers.js

'use strict';
// eslint-disable-next-line es/no-object-hasown -- safe
const has = Object.hasOwn || Function.call.bind({}.hasOwnProperty);

const VERSION_PATTERN = /(\d+)(?:\.(\d+))?(?:\.(\d+))?/;

class SemVer {
  constructor(input) {
    const match = VERSION_PATTERN.exec(input);
    if (!match) throw new TypeError(`Invalid version: ${ input }`);
    const [, $major, $minor, $patch] = match;
    this.major = +$major;
    this.minor = $minor ? +$minor : 0;
    this.patch = $patch ? +$patch : 0;
  }
  toString() {
    return `${ this.major }.${ this.minor }.${ this.patch }`;
  }
}

function semver(input) {
  return input instanceof SemVer ? input : new SemVer(input);
}

function compare($a, operator, $b) {
  const a = semver($a);
  const b = semver($b);
  for (const component of ['major', 'minor', 'patch']) {
    if (a[component] < b[component]) return operator === '<' || operator === '<=' || operator === '!=';
    if (a[component] > b[component]) return operator === '>' || operator === '>=' || operator === '!=';
  } return operator === '==' || operator === '<=' || operator === '>=';
}

function filterOutStabilizedProposals(modules) {
  const modulesSet = new Set(modules);

  for (const $module of modulesSet) {
    if ($module.startsWith('esnext.') && modulesSet.has($module.replace(/^esnext\./, 'es.'))) {
      modulesSet.delete($module);
    }
  }

  return [...modulesSet];
}

function intersection(list, order) {
  const set = list instanceof Set ? list : new Set(list);
  return order.filter(name => set.has(name));
}

function sortObjectByKey(object, fn) {
  return Object.keys(object).sort(fn).reduce((memo, key) => {
    memo[key] = object[key];
    return memo;
  }, {});
}

module.exports = {
  compare,
  filterOutStabilizedProposals,
  has,
  intersection,
  semver,
  sortObjectByKey,
};

Directory Contents

Dirs: 0 × Files: 17

Name Size Perms Modified Actions
1.30 KB lrw-r--r-- 2026-02-28 00:28:38
Edit Download
2.44 KB lrw-r--r-- 2026-02-28 00:26:42
Edit Download
182.19 KB lrw-r--r-- 2026-02-28 00:27:48
Edit Download
582.46 KB lrw-r--r-- 2026-02-28 00:28:28
Edit Download
394 B lrw-r--r-- 2026-02-28 00:28:28
Edit Download
198 B lrw-r--r-- 2026-02-28 00:28:38
Edit Download
588 B lrw-r--r-- 2026-02-28 00:26:52
Edit Download
1.78 KB lrw-r--r-- 2026-02-28 00:27:02
Edit Download
782 B lrw-r--r-- 2026-02-28 00:28:40
Edit Download
367 B lrw-r--r-- 2026-02-28 00:27:12
Edit Download
1.11 KB lrw-r--r-- 2026-02-28 00:26:32
Edit Download
15.85 KB lrw-r--r-- 2026-02-28 00:28:30
Edit Download
14.18 KB lrw-r--r-- 2026-02-28 00:28:32
Edit Download
726 B lrw-r--r-- 2026-02-28 00:28:34
Edit Download
8.03 KB lrw-r--r-- 2026-02-28 00:28:36
Edit Download
529 B lrw-r--r-- 2026-02-28 00:28:42
Edit Download
2.38 KB lrw-r--r-- 2026-02-28 00:27:22
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).