hatch-surf/node_modules/resolve/lib/select-most-restrictive.js
Riley Zhang df378d33ef
Some checks failed
CI / go (push) Waiting to run
CI / docker (push) Waiting to run
CI / lint-go (push) Waiting to run
CI / lint-docs (push) Waiting to run
CI / check-paperclip (push) Waiting to run
Deploy static site / Deploy to GitHub Pages (push) Has been cancelled
Deploy static site / Deploy via Docker to hatch.surf (push) Has been cancelled
Merge GitHub main into Gitea repo (allow unrelated histories)
Resolved conflicts by taking GitHub versions for:
- .dockerignore, .gitignore, Dockerfile, README.md, docker-compose.yml

Kept deploy.sh updated to:
- Pull from GitHub (primary source)
- Push to Gitea (push-mirror)
- Build from site/ directory (GitHub structure)

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-06-25 05:20:46 +02:00

43 lines
1.6 KiB
JavaScript

'use strict';
// Category ranking from most restrictive (lowest rank) to least restrictive (highest rank)
// Lower rank = more restrictive = fewer features supported
var categoryRank = /** @type {const} */ {
__proto__: null,
'pre-exports': /** @type {const} */ (0),
broken: /** @type {const} */ (1),
experimental: /** @type {const} */ (2),
conditions: /** @type {const} */ (3),
'broken-dir-slash-conditions': /** @type {const} */ (4),
patterns: /** @type {const} */ (5),
'pattern-trailers': /** @type {const} */ (6),
'pattern-trailers+json-imports': /** @type {const} */ (7),
'pattern-trailers-no-dir-slash': /** @type {const} */ (8),
'pattern-trailers-no-dir-slash+json-imports': /** @type {const} */ (9),
'require-esm': /** @type {const} */ (10),
'strips-types': /** @type {const} */ (11),
'subpath-imports-slash': /** @type {const} */ (12)
};
// Select the most restrictive category from an array of categories
/** @type {(categories?: ReturnType<import('node-exports-info/getCategory')>[]) => import('node-exports-info/getCategory').Category | null} */
module.exports = function selectMostRestrictive(categories) {
if (!categories || categories.length === 0) {
return null;
}
var mostRestrictive = null;
var lowestRank = Infinity;
for (var i = 0; i < categories.length; i++) {
var cat = categories[i];
var rank = categoryRank[cat];
if (typeof rank === 'number' && rank < lowestRank) {
lowestRank = rank;
mostRestrictive = cat;
}
}
return mostRestrictive;
};