{"id":19584824,"url":"https://github.com/flex-development/mlly","last_synced_at":"2026-02-03T03:01:08.475Z","repository":{"id":61845466,"uuid":"544703893","full_name":"flex-development/mlly","owner":"flex-development","description":"ECMAScript module utilities","archived":false,"fork":false,"pushed_at":"2024-05-27T22:42:46.000Z","size":6829,"stargazers_count":3,"open_issues_count":12,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-05-28T08:15:50.860Z","etag":null,"topics":["ecmascript","esm","esmodules","module","typescript"],"latest_commit_sha":null,"homepage":"https://github.com/flex-development/mlly","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flex-development.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/funding.yml","license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["flex-development"]}},"created_at":"2022-10-03T04:28:47.000Z","updated_at":"2024-05-30T01:34:44.124Z","dependencies_parsed_at":"2023-09-21T20:30:26.326Z","dependency_job_id":"674cc8c2-4bc1-4a1b-8610-c4914b1c01dc","html_url":"https://github.com/flex-development/mlly","commit_stats":{"total_commits":496,"total_committers":2,"mean_commits":248.0,"dds":"0.19758064516129037","last_synced_commit":"58e41d6a17679e5d8f70d1fb430ace6cffcafff7"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flex-development%2Fmlly","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flex-development%2Fmlly/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flex-development%2Fmlly/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flex-development%2Fmlly/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flex-development","download_url":"https://codeload.github.com/flex-development/mlly/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224056615,"owners_count":17248326,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ecmascript","esm","esmodules","module","typescript"],"created_at":"2024-11-11T07:49:59.325Z","updated_at":"2026-02-03T03:01:08.466Z","avatar_url":"https://github.com/flex-development.png","language":"TypeScript","funding_links":["https://github.com/sponsors/flex-development"],"categories":[],"sub_categories":[],"readme":"# \\:gear: mlly\n\n[![github release](https://img.shields.io/github/v/release/flex-development/mlly.svg?include_prereleases\\\u0026sort=semver)](https://github.com/flex-development/mlly/releases/latest)\n[![npm](https://img.shields.io/npm/v/@flex-development/mlly.svg)](https://npmjs.com/package/@flex-development/mlly)\n[![npm downloads](https://img.shields.io/npm/dm/@flex-development/mlly.svg)](https://www.npmcharts.com/compare/@flex-development/mlly?interval=30)\n[![install size](https://packagephobia.now.sh/badge?p=@flex-development/mlly)](https://packagephobia.now.sh/result?p=@flex-development/mlly)\n[![codecov](https://codecov.io/gh/flex-development/mlly/graph/badge.svg?token=36NUNRH6FW)](https://codecov.io/gh/flex-development/mlly)\n[![module type: esm](https://img.shields.io/badge/module%20type-esm-brightgreen)](https://github.com/voxpelli/badges-cjs-esm)\n[![license](https://img.shields.io/github/license/flex-development/mlly.svg)](LICENSE.md)\n[![conventional commits](https://img.shields.io/badge/-conventional%20commits-fe5196?logo=conventional-commits\\\u0026logoColor=ffffff)](https://conventionalcommits.org)\n[![typescript](https://img.shields.io/badge/-typescript-3178c6?logo=typescript\\\u0026logoColor=ffffff)](https://typescriptlang.org)\n[![vitest](https://img.shields.io/badge/-vitest-6e9f18?style=flat\\\u0026logo=vitest\\\u0026logoColor=ffffff)](https://vitest.dev)\n[![yarn](https://img.shields.io/badge/-yarn-2c8ebb?style=flat\\\u0026logo=yarn\\\u0026logoColor=ffffff)](https://yarnpkg.com)\n\n[ECMAScript module][node-esm] utilities.\n\n## Contents\n\n- [What is this?](#what-is-this)\n- [Install](#install)\n- [Use](#use)\n- [API](#api)\n  - [`canParseUrl(input[, base])`](#canparseurlinput-base)\n  - [`cwd()`](#cwd)\n  - [`defaultConditions`](#defaultconditions)\n  - [`defaultExtensions`](#defaultextensions)\n  - [`defaultMainFields`](#defaultmainfields)\n  - [`extensionFormatMap`](#extensionformatmap)\n  - [`formats`](#formats)\n  - [`getSource\u003cT\u003e(id[, options])`](#getsourcetid-options)\n  - [`isAbsoluteSpecifier(value)`](#isabsolutespecifiervalue)\n  - [`isArrayIndex(value)`](#isarrayindexvalue)\n  - [`isBareSpecifier(value)`](#isbarespecifiervalue)\n  - [`isDirectory\u003cT\u003e(id[, fs])`](#isdirectorytid-fs)\n  - [`isFile\u003cT\u003e(id[, fs])`](#isfiletid-fs)\n  - [`isImportsSubpath(value)`](#isimportssubpathvalue)\n  - [`isModuleId(value)`](#ismoduleidvalue)\n  - [`isRelativeSpecifier(value)`](#isrelativespecifiervalue)\n  - [`legacyMainResolve\u003cT\u003e(packageUrl[, manifest][, mainFields][, parent][, fs])`](#legacymainresolvetpackageurl-manifest-mainfields-parent-fs)\n  - [`lookupPackageScope\u003cT\u003e(url[, end][, fs])`](#lookuppackagescopeturl-end-fs)\n  - [`moduleResolve\u003cT\u003e(specifier, parent[, conditions][, mainFields][, preserveSymlinks][, fs])`](#moduleresolvetspecifier-parent-conditions-mainfields-preservesymlinks-fs)\n  - [`packageExportsResolve\u003cT\u003e(packageUrl, subpath, exports[, conditions][, parent][, fs])`](#packageexportsresolvetpackageurl-subpath-exports-conditions-parent-fs)\n  - [`packageImportsExportsResolve\u003cT\u003e(matchKey, matchObject, packageUrl[, isImports][, conditions][, mainFields][, parent][, fs])`](#packageimportsexportsresolvetmatchkey-matchobject-packageurl-isimports-conditions-mainfields-parent-fs)\n  - [`packageImportsResolve\u003cT\u003e(specifier, parent[, conditions][, mainFields][, fs])`](#packageimportsresolvetspecifier-parent-conditions-mainfields-fs)\n  - [`packageResolve\u003cT\u003e(specifier, parent[, conditions][, mainFields][, fs])`](#packageresolvetspecifier-parent-conditions-mainfields-fs)\n  - [`packageSelfResolve\u003cT\u003e(name, subpath, parent[, conditions][, fs])`](#packageselfresolvetname-subpath-parent-conditions-fs)\n  - [`packageTargetResolve\u003cT\u003e(packageUrl, target, subpath[, patternMatch][, isImports][, conditions][, mainFields][, parent][, fs])`](#packagetargetresolvetpackageurl-target-subpath-patternmatch-isimports-conditions-mainfields-parent-fs)\n  - [`patternKeyCompare(a, b)`](#patternkeycomparea-b)\n  - [`patternMatch(matchKey, matchObject)`](#patternmatchmatchkey-matchobject)\n  - [`readPackageJson\u003cT\u003e(id[, specifier][, parent][, fs])`](#readpackagejsontid-specifier-parent-fs)\n  - [`resolveAlias(specifier[, options])`](#resolvealiasspecifier-options)\n  - [`resolveModule\u003cT\u003e(specifier, parent[, options])`](#resolvemoduletspecifier-parent-options)\n  - [`resolver`](#resolver)\n  - [`root`](#root)\n  - [`toRelativeSpecifier(url, parent)`](#torelativespecifierurl-parent)\n  - [`toUrl(id[, parent])`](#tourlid-parent)\n- [Types](#types)\n  - [`Aliases`](#aliases)\n  - [`Awaitable\u003cT\u003e`](#awaitablet)\n  - [`ChangeExtFn\u003c[Ext]\u003e`](#changeextfnext)\n  - [`ConditionMap`](#conditionmap)\n  - [`Condition`](#condition)\n  - [`Dot`](#dot)\n  - [`EmptyArray`](#emptyarray)\n  - [`EmptyObject`](#emptyobject)\n  - [`EmptyString`](#emptystring)\n  - [`Ext`](#ext)\n  - [`FileSystem`](#filesystem)\n  - [`GetSourceContext`](#getsourcecontext)\n  - [`GetSourceHandler`](#getsourcehandler)\n  - [`GetSourceHandlers`](#getsourcehandlers)\n  - [`GetSourceOptions`](#getsourceoptions)\n  - [`IsDirectory`](#isdirectory)\n  - [`IsFile`](#isfile)\n  - [`List\u003c[T]\u003e`](#listt)\n  - [`MainFieldMap`](#mainfieldmap)\n  - [`MainField`](#mainfield)\n  - [`ModuleFormatMap`](#moduleformatmap)\n  - [`ModuleFormat`](#moduleformat)\n  - [`ModuleId`](#moduleid)\n  - [`Numeric`](#numeric)\n  - [`PatternKeyComparisonMap`](#patternkeycomparsionmap)\n  - [`PatternKeyComparison`](#patternkeycomparsion)\n  - [`PatternMatch`](#patternmatch)\n  - [`ProtocolMap`](#protocolmap)\n  - [`Protocol`](#protocol)\n  - [`ReadFile\u003c[T]\u003e`](#readfilet)\n  - [`Realpath\u003c[T]\u003e`](#realpatht)\n  - [`ResolveAliasOptions`](#resolvealiasoptions)\n  - [`ResolveModuleOptions`](#resolvemoduleoptions)\n  - [`Stat\u003c[T]\u003e`](#statt)\n  - [`Stats`](#stats)\n- Additional Documentation\n  - [Resolution Algorithm](./docs/resolution-algorithm.md)\n- [Contribute](#contribute)\n\n## What is this?\n\n`mlly` is a set of [ECMAScript module][node-esm] (ESM) utilities.\\\nIt exposes several tools to bridge the gap between developer experience and the current state of ECMAScript modules.\n\n## Install\n\nThis package is [ESM only][esm].\n\nIn Node.js (version 20+) with [yarn][]:\n\n```sh\nyarn add @flex-development/mlly\n```\n\n\u003cblockquote\u003e\n  \u003csmall\u003e\n    See \u003ca href='https://yarnpkg.com/protocol/git'\u003eGit - Protocols | Yarn\u003c/a\u003e\n    \u0026nbsp;for details regarding installing from Git.\n  \u003c/small\u003e\n\u003c/blockquote\u003e\n\nIn Deno with [`esm.sh`][esmsh]:\n\n```ts\nimport { resolveModule } from 'https://esm.sh/@flex-development/mlly'\n```\n\nIn browsers with [`esm.sh`][esmsh]:\n\n```html\n\u003cscript type=\"module\"\u003e\n  import { resolveModule } from 'https://esm.sh/@flex-development/mlly'\n\u003c/script\u003e\n```\n\n## Use\n\n```ts\nimport {\n  lookupPackageScope,\n  readPackageJson,\n  resolveModule,\n  type FileSystem\n} from '@flex-development/mlly'\nimport pkg from '@flex-development/mlly/package.json' with { type: 'json' }\nimport type { PackageJson } from '@flex-development/pkg-types'\nimport nfs from 'node:fs'\n\n/**\n * A file system API with both asynchronous and synchronous methods.\n *\n * @const {FileSystem} fs\n */\nconst fs: FileSystem = {\n  readFile: nfs.promises.readFile,\n  realpath: nfs.promises.realpath,\n  stat: nfs.statSync\n}\n\n/**\n * The URL of the package directory.\n *\n * @const {URL | null} scope\n */\nconst scope: URL | null = lookupPackageScope(import.meta.url, null, fs)\n\nconsole.dir(scope) // file:///Users/lex/Projects/flex-development/mlly/\n\n/**\n * The package manifest.\n *\n * @const {PackageJson | null} manifest\n */\nconst manifest: PackageJson | null = await readPackageJson(\n  scope,\n  null,\n  import.meta.url,\n  fs\n)\n\nconsole.dir(manifest?.name === pkg.name) // true\nconsole.dir(manifest) // `pkg`\n\n/**\n * A fully resolved URL.\n *\n * @const {URL} resolved\n */\nconst resolved = resolveModule(pkg.name, import.meta.url, {\n  conditions: new Set(['mlly']),\n  ext: null\n})\n\nconsole.dir(resolved) // file:///Users/lex/Projects/flex-development/mlly/src/\n```\n\n## API\n\n`mlly` exports the identifiers listed below.\n\nThere is no default export.\n\n### `canParseUrl(input[, base])`\n\nCheck if `input` can be parsed to a `URL`.\n\n\u003e 👉 **Note**: If `input` is relative, `base` is required.\n\u003e If `input` is absolute, `base` is ignored.\n\n#### Parameters\n\n- `id` (`unknown`)\n  — the input url\n- `base` (`unknown`)\n  — the base url to resolve against if `input` is not absolute\n\n#### Returns\n\n(`boolean`) `true` if `input` can be parsed to a `URL`, `false` otherwise\n\n### `cwd()`\n\nGet the URL of the current working directory.\n\n#### Returns\n\n(`URL`) The current working directory URL\n\n### `defaultConditions`\n\n[`Set\u003cCondition\u003e`](#condition)\n\nThe default list of conditions.\n\n### `defaultExtensions`\n\n[`Set\u003cExt\u003e`](#ext)\n\nThe default list of resolvable file extensions.\n\n### `defaultMainFields`\n\n[`Set\u003cMainField\u003e`](#mainfield)\n\nThe default list of main fields.\n\n### `extensionFormatMap`\n\n`Map\u003cExt, ModuleFormat\u003e`\n\nMap, where each key is a [file extension](#ext) and each value is a default [module format](#formats).\n\n### `formats`\n\nDefault module formats (`const enum`).\n\n```ts\nconst enum formats {\n  builtin = 'builtin',\n  commonjs = 'commonjs',\n  cts = 'commonjs-typescript',\n  json = 'json',\n  module = 'module',\n  mts = 'module-typescript',\n  wasm = 'wasm'\n}\n```\n\n### `getSource\u003cT\u003e(id[, options])`\n\nGet the source code for a module.\n\n\u003e 👉 **Note**: Returns a promise if the [handler](#getsourcehandler) for `id` is async.\n\n#### Type Parameters\n\n- `T` ([`Awaitable\u003cstring | null | undefined\u003e`](#awaitablet))\n  — the module source code\n\n#### Parameters\n\n- `id` ([`ModuleId`](#moduleid) | `null` | `undefined`)\n  — the module id\n- `options` ([`GetSourceOptions`](#getsourceoptions) | `null` | `undefined`)\n  — source code retrieval options\n\n#### Returns\n\n(`T`) The module source code\n\n#### Throws\n\n- [`ERR_UNSUPPORTED_ESM_URL_SCHEME`][err-unsupported-esm-url-scheme]\n\n### `isAbsoluteSpecifier(value)`\n\nCheck if `value` is an *absolute specifier*.\n\n\u003e 👉 **Note**: Only checks specifier syntax.\\\n\u003e Does **not** guarantee the specifier references an existing module.\n\n#### Parameters\n\n- `value` (`unknown`)\n  — the value to check\n\n#### Returns\n\n(`boolean`) `true` if `value` is absolute specifier, `false` otherwise\n\n### `isArrayIndex(value)`\n\nCheck if `value` is a valid array index.\n\n#### Parameters\n\n- `value` (`unknown`)\n  — the value to check\n\n#### Returns\n\n([`value is Numeric`](#numeric)) `true` if `value` is valid array index, `false` otherwise\n\n### `isBareSpecifier(value)`\n\nCheck if `value` is a *bare specifier*.\n\n\u003e 👉 **Note**: Only checks specifier syntax.\\\n\u003e Does **not** guarantee the specifier references an existing module.\n\n#### Parameters\n\n- `value` (`unknown`)\n  — the value to check\n\n#### Returns\n\n(`boolean`) `true` if `value` is bare specifier, `false` otherwise\n\n### `isDirectory\u003cT\u003e(id[, fs])`\n\nCheck if a directory exists.\n\n\u003e 👉 **Note**: Returns a promise if `fs.stat` is async.\n\n#### Type Parameters\n\n- `T` ([`Awaitable\u003cboolean\u003e`](#awaitablet))\n  — the result of the check\n\n#### Parameters\n\n- `id` ([`ModuleId`](#moduleid))\n  — the module id to check\n- `fs` ([`FileSystem`](#filesystem) | `null` | `undefined`)\n  — the file system api\n\n#### Returns\n\n(`T`) `true` if directory exists at `id`, `false` otherwise\n\n### `isFile\u003cT\u003e(id[, fs])`\n\nCheck if a file exists.\n\n\u003e 👉 **Note**: Returns a promise if `fs.stat` is async.\n\n#### Type Parameters\n\n- `T` ([`Awaitable\u003cboolean\u003e`](#awaitablet))\n  — the result of the check\n\n#### Parameters\n\n- `id` ([`ModuleId`](#moduleid))\n  — the module id to check\n- `fs` ([`FileSystem`](#filesystem) | `null` | `undefined`)\n  — the file system api\n\n#### Returns\n\n(`T`) `true` if file exists at `id`, `false` otherwise\n\n### `isImportsSubpath(value)`\n\nCheck if `value` is an [`imports`][subpath-imports] subpath.\n\n\u003e 👉 **Note**: Only checks specifier syntax.\\\n\u003e Does **not** guarantee the specifier references an existing module.\n\n#### Parameters\n\n- `value` (`unknown`)\n  — the value to check\n\n#### Returns\n\n([`value is ImportsSubpath`][pkg-imports-subpath]) `true` if `value` is `imports` subpath, `false` otherwise\n\n### `isModuleId(value)`\n\nCheck if `value` is a module id.\n\n#### Parameters\n\n- `value` (`unknown`)\n  — the value to check\n\n#### Returns\n\n([`value is ModuleId`](#moduleid)) `true` if `value` is module id, `false` otherwise\n\n### `isRelativeSpecifier(value)`\n\nCheck if `value` is a *relative specifier*.\n\n\u003e 👉 **Note**: Only checks specifier syntax.\\\n\u003e Does **not** guarantee the specifier references an existing module.\n\n#### Parameters\n\n- `value` (`unknown`)\n  — the value to check\n\n#### Returns\n\n(`boolean`) `true` if `value` is relative specifier, `false` otherwise\n\n\u003c!--lint disable--\u003e\n\n### `legacyMainResolve\u003cT\u003e(packageUrl[, manifest][, mainFields][, parent][, fs])`\n\n\u003c!--lint enable--\u003e\n\nResolve a [`main`][main]-like package entry point.\n\nImplements the [`LEGACY_MAIN_RESOLVE`][algorithm-legacy-main-resolve] resolution algorithm.\n\n\u003e 👉 **Note**: Returns a promise if `fs.stat` is async.\n\n#### Type Parameters\n\n- `T` ([`Awaitable\u003cURL\u003e`](#awaitablet))\n  — the resolved entry point url\n\n#### Parameters\n\n- `packageUrl` ([`ModuleId`](#moduleid))\n  — the url of the package directory, the `package.json` file, or a module in the same directory as a `package.json`\n- `manifest` ([`PackageJson`][pkg-package-json] | `null` | `undefined`)\n  — the package manifest\n- `mainFields` ([`List\u003cMainField\u003e`](#mainfield) | `null` | `undefined`)\n  — the list of legacy main fields\n  - **default**: [`defaultMainFields`](#defaultmainfields)\n- `parent` ([`ModuleId`](#moduleid) | `null` | `undefined`)\n  — the url of the parent module\n- `fs` ([`FileSystem`](#filesystem) | `null` | `undefined`)\n  — the file system api\n\n#### Returns\n\n(`T`) The resolved entry point URL\n\n#### Throws\n\n- [`ERR_MODULE_NOT_FOUND`][err-module-not-found]\n\n### `lookupPackageScope\u003cT\u003e(url[, end][, fs])`\n\nGet the package scope URL for a module `url`.\n\nImplements the [`LOOKUP_PACKAGE_SCOPE`][algorithm-lookup-package-scope] algorithm.\n\n\u003e 👉 **Note**: Returns a promise if `fs.stat` is async.\n\n#### Overloads\n\n```ts\nfunction lookupPackageScope(\n  this: void,\n  url: EmptyString | null | undefined,\n  end?: ModuleId | null | undefined,\n  fs?: FileSystem | null | undefined\n): null\n```\n\n```ts\nfunction lookupPackageScope\u003cT extends Awaitable\u003cURL | null\u003e\u003e(\n  this: void,\n  url: ModuleId | null | undefined,\n  end?: ModuleId | null | undefined,\n  fs?: FileSystem | null | undefined\n): T\n```\n\n#### Type Parameters\n\n- `T` ([`Awaitable\u003cURL | null\u003e`](#awaitablet))\n  — the resolved package scope url\n\n#### Parameters\n\n- `id` ([`ModuleId`](#moduleid) | `null` | `undefined`)\n  — the url of the module to scope\n- `end` ([`ModuleId`](#moduleid) | `null` | `undefined`)\n  — the url of the directory to end search at\n  - **default**: [`root`](#root)\n- `fs` ([`FileSystem`](#filesystem) | `null` | `undefined`)\n  — the file system api\n\n#### Returns\n\n(`T`) The URL of nearest directory containing a `package.json` file\n\n\u003c!--lint disable--\u003e\n\n### `moduleResolve\u003cT\u003e(specifier, parent[, conditions][, mainFields][, preserveSymlinks][, fs])`\n\n\u003c!--lint enable--\u003e\n\nResolve a module `specifier`.\n\nImplements the [`ESM_RESOLVE`][algorithm-esm-resolve] algorithm.\n\n\u003e 👉 **Note**: Returns a promise if `fs.realpath` or `fs.stat` is async, or one the following methods returns a promise:\n\u003e [`packageImportsResolve`](#packageimportsresolvetspecifier-parent-conditions-mainfields-fs),\n\u003e [`packageResolve`](#packageresolvetspecifier-parent-conditions-mainfields-fs).\n\n#### Type Parameters\n\n- `T` ([`Awaitable\u003cURL\u003e`](#awaitablet))\n  — the resolved url\n\n#### Parameters\n\n- `specifier` (`string`)\n  — the module specifier to resolve\n- `parent` ([`ModuleId`](#moduleid))\n  — the url of the parent module\n- `conditions` ([`List\u003cCondition\u003e`](#condition) | `null` | `undefined`)\n  — the list of export/import conditions\n  - **default**: [`defaultConditions`](#defaultconditions)\n- `mainFields` ([`List\u003cMainField\u003e`](#mainfield) | `null` | `undefined`)\n  — the list of legacy main fields\n  - **default**: [`defaultMainFields`](#defaultmainfields)\n- `preserveSymlinks` (`boolean` | `null` | `undefined`)\n  — whether to keep symlinks instead of resolving them\n- `fs` ([`FileSystem`](#filesystem) | `null` | `undefined`)\n  — the file system api\n\n#### Returns\n\n(`T`) The resolved URL\n\n\u003c!--lint disable--\u003e\n\n### `packageExportsResolve\u003cT\u003e(packageUrl, subpath, exports[, conditions][, parent][, fs])`\n\n\u003c!--lint enable--\u003e\n\nResolve a package export.\n\nImplements the [`PACKAGE_EXPORTS_RESOLVE`][algorithm-package-exports-resolve] algorithm.\n\n\u003e 👉 **Note**: Never returns a promisee.\n\n#### Type Parameters\n\n- `T` ([`Awaitable\u003cURL\u003e`](#awaitablet))\n  — the resolved package export url\n\n#### Parameters\n\n- `packageUrl` ([`ModuleId`](#moduleid))\n  — the url of the package directory, the `package.json` file, or a module in the same directory as a `package.json`\n- `subpath` (`string`)\n  — the package subpath\n- `exports` ([`Exports`][pkg-exports] | `undefined`)\n  — the package exports\n- `conditions` ([`List\u003cCondition\u003e`](#condition) | `null` | `undefined`)\n  — the list of export/import conditions\n  - **default**: [`defaultConditions`](#defaultconditions)\n- `parent` ([`ModuleId`](#moduleid) | `null` | `undefined`)\n  — the url of the parent module\n- `fs` ([`FileSystem`](#filesystem) | `null` | `undefined`)\n  — the file system api\n\n#### Returns\n\n(`T`) The resolved package export URL\n\n\u003c!--lint disable--\u003e\n\n### `packageImportsExportsResolve\u003cT\u003e(matchKey, matchObject, packageUrl[, isImports][, conditions][, mainFields][, parent][, fs])`\n\n\u003c!--lint enable--\u003e\n\nResolve a package export or import.\n\nImplements the [`PACKAGE_IMPORTS_EXPORTS_RESOLVE`][algorithm-package-imports-exports-resolve] algorithm.\n\n\u003e 👉 **Note**: Returns a promise if\n\u003e [`packageTargetResolve`](#packagetargetresolvetpackageurl-target-subpath-patternmatch-isimports-conditions-mainfields-parent-fs),\n\u003e returns a promise.\n\n#### Type Parameters\n\n- `T` ([`Awaitable\u003cURL | null | undefined\u003e`](#awaitablet))\n  — the resolved package export or import url\n\n#### Parameters\n\n- `matchKey` (`string`)\n  — the package subpath extracted from a module specifier, or a dot character (`.`)\n- `matchObject` ([`ExportsObject`][pkg-exports-object] | [`Imports`][pkg-imports] | `null` | `undefined`)\n  — the package exports or imports\n- `packageUrl` ([`ModuleId`](#moduleid))\n  — the url of the directory containing the `package.json` file\n- `isImports` (`boolean` | `null` | `undefined`)\n  — whether `matchObject` is internal to the package\n- `conditions` ([`List\u003cCondition\u003e`](#condition) | `null` | `undefined`)\n  — the list of export/import conditions\n  - **default**: [`defaultConditions`](#defaultconditions)\n- `mainFields` ([`List\u003cMainField\u003e`](#mainfield) | `null` | `undefined`)\n  — the list of legacy main fields\n  - **default**: [`defaultMainFields`](#defaultmainfields)\n- `parent` ([`ModuleId`](#moduleid) | `null` | `undefined`)\n  — the url of the parent module\n- `fs` ([`FileSystem`](#filesystem) | `null` | `undefined`)\n  — the file system api\n\n#### Returns\n\n(`T`) The resolved package export or import URL\n\n\u003c!--lint disable--\u003e\n\n### `packageImportsResolve\u003cT\u003e(specifier, parent[, conditions][, mainFields][, fs])`\n\n\u003c!--lint enable--\u003e\n\nResolve a package import.\n\nImplements the [`PACKAGE_IMPORTS_RESOLVE`][algorithm-package-imports-resolve] algorithm.\n\n\u003e 👉 **Note**: Returns a promise if [`lookupPackageScope`](#lookuppackagescopeturl-end-fs),\n\u003e [`packageImportsExportsResolve`](#packageimportsexportsresolvetmatchkey-matchobject-packageurl-isimports-conditions-mainfields-parent-fs),\n\u003e or [`readPackageJson`](#readpackagejsontid-specifier-parent-fs) returns a promise.\n\n#### Type Parameters\n\n- `T` ([`Awaitable\u003cURL\u003e`](#awaitablet))\n  — the resolved package import url\n\n#### Parameters\n\n- `specifier` (`string`)\n  — the import specifier to resolve\n- `parent` ([`ModuleId`](#moduleid))\n  — the url of the parent module\n- `conditions` ([`List\u003cCondition\u003e`](#condition) | `null` | `undefined`)\n  — the list of export conditions\n  - **default**: [`defaultConditions`](#defaultconditions)\n- `mainFields` ([`List\u003cMainField\u003e`](#mainfield) | `null` | `undefined`)\n  — the list of legacy main fields\n  - **default**: [`defaultMainFields`](#defaultmainfields)\n- `fs` ([`FileSystem`](#filesystem) | `null` | `undefined`)\n  — the file system api\n\n#### Returns\n\n(`T`) The resolved package import URL\n\n#### Throws\n\n- [`ERR_INVALID_MODULE_SPECIFIER`][err-invalid-module-specifier]\n- [`ERR_PACKAGE_IMPORT_NOT_DEFINED`][err-package-import-not-defined]\n\n\u003c!--lint disable--\u003e\n\n### `packageResolve\u003cT\u003e(specifier, parent[, conditions][, mainFields][, fs])`\n\n\u003c!--lint enable--\u003e\n\nResolve a *bare specifier*.\n\nImplements the [`PACKAGE_RESOLVE`][algorithm-package-resolve] algorithm.\n\n\u003e *Bare specifiers* like `'some-package'` or `'some-package/shuffle'` refer to the main entry point of a package by\n\u003e package name, or a specific feature module within a package prefixed by the package name.\n\u003e Including the file extension is only necessary for packages without an [`exports`][exports] field.\n\n\u003e 👉 **Note**: Returns a promise if `fs.stat` is async or one of the following methods returns a promise:\n\u003e [`legacyMainResolve`](#legacymainresolvetpackageurl-manifest-mainfields-parent-fs),\n\u003e [`packageExportsResolve`](#packageexportsresolvetpackageurl-subpath-exports-conditions-parent-fs),\n\u003e [`packageSelfResolve`](#packageselfresolvetname-subpath-parent-conditions-fs), or\n\u003e [`readPackageJson`](#readpackagejsontid-specifier-parent-fs).\n\n#### Type Parameters\n\n- `T` ([`Awaitable\u003cURL\u003e`](#awaitablet))\n  — the resolved package url\n\n#### Parameters\n\n- `specifier` (`string`)\n  — the package specifier\n- `parent` ([`ModuleId`](#moduleid))\n  — the url of the parent module\n- `conditions` ([`List\u003cCondition\u003e`](#condition) | `null` | `undefined`)\n  — the list of export conditions\n  - **default**: [`defaultConditions`](#defaultconditions)\n- `mainFields` ([`List\u003cMainField\u003e`](#mainfield) | `null` | `undefined`)\n  — the list of legacy main fields\n  - **default**: [`defaultMainFields`](#defaultmainfields)\n- `fs` ([`FileSystem`](#filesystem) | `null` | `undefined`)\n  — the file system api\n\n#### Returns\n\n(`T`) The resolved package URL\n\n#### Throws\n\n- [`ERR_INVALID_MODULE_SPECIFIER`][err-invalid-module-specifier]\n- [`ERR_MODULE_NOT_FOUND`][err-module-not-found]\n\n\u003c!--lint disable--\u003e\n\n### `packageSelfResolve\u003cT\u003e(name, subpath, parent[, conditions][, fs])`\n\n\u003c!--lint enable--\u003e\n\nResolve the self-import of a package.\n\nImplements the [`PACKAGE_SELF_RESOLVE`][algorithm-package-self-resolve] algorithm.\n\n\u003e 👉 **Note**: Returns a promise if [`lookupPackageScope`](#lookuppackagescopeturl-end-fs),\n\u003e [`packageExportsResolve`](#packageexportsresolvetpackageurl-subpath-exports-conditions-parent-fs),\n\u003e or [`readPackageJson`](#readpackagejsontid-specifier-parent-fs) returns a promise.\n\n#### Type Parameters\n\n- `T` ([`Awaitable\u003cURL | undefined\u003e`](#awaitablet))\n  — the resolved package url\n\n#### Parameters\n\n- `name` (`string`)\n  — the package name\n- `subpath` (`string`)\n  — the package subpath\n- `parent` ([`ModuleId`](#moduleid))\n  — the url of the parent module\n- `conditions` ([`List\u003cCondition\u003e`](#condition) | `null` | `undefined`)\n  — the list of export conditions\n  - **default**: [`defaultConditions`](#defaultconditions)\n- `fs` ([`FileSystem`](#filesystem) | `null` | `undefined`)\n  — the file system api\n\n#### Returns\n\n(`T`) The resolved package URL\n\n\u003c!--lint disable--\u003e\n\n### `packageTargetResolve\u003cT\u003e(packageUrl, target, subpath[, patternMatch][, isImports][, conditions][, mainFields][, parent][, fs])`\n\n\u003c!--lint enable--\u003e\n\nResolve a package target.\n\nImplements the [`PACKAGE_TARGET_RESOLVE`][algorithm-package-target-resolve] algorithm.\n\n\u003e 👉 **Note**: Returns a promise if `target` is internal to the package and\n\u003e [`packageResolve`](#packageresolvetspecifier-parent-conditions-mainfields-fs) returns a promise.\n\n#### Type Parameters\n\n- `T` ([`Awaitable\u003cURL | null | undefined\u003e`](#awaitablet))\n  — the resolved package target url\n\n#### Parameters\n\n- `packageUrl` ([`ModuleId`](#moduleid))\n  — the url of the directory containing the `package.json` file\n- `target` (`unknown`)\n  — the package target (i.e. a `exports`/`imports` value)\n- `subpath` (`string`)\n  — the package subpath (i.e. a `exports`/`imports` key)\n- `patternMatch` (`string` | `null` | `undefined`)\n  — the `subpath` pattern match\n- `isImports` (`boolean` | `null` | `undefined`)\n  — whether `target` is internal to the package\n- `conditions` ([`List\u003cCondition\u003e`](#condition) | `null` | `undefined`)\n  — the list of export/import conditions\n  - **default**: [`defaultConditions`](#defaultconditions)\n- `mainFields` ([`List\u003cMainField\u003e`](#mainfield) | `null` | `undefined`)\n  — the list of legacy main fields\n  - **default**: [`defaultMainFields`](#defaultmainfields)\n- `parent` ([`ModuleId`](#moduleid))\n  — the url of the parent module\n- `fs` ([`FileSystem`](#filesystem) | `null` | `undefined`)\n  — the file system api\n\n#### Returns\n\n(`T`) The resolved package target URL\n\n#### Throws\n\n- [`ERR_INVALID_PACKAGE_CONFIG`][err-invalid-package-config]\n- [`ERR_INVALID_PACKAGE_TARGET`][err-invalid-package-target]\n\n### `patternKeyCompare(a, b)`\n\nCompare two pattern keys and return a value indicating their order.\n\nImplements the [`PATTERN_KEY_COMPARE`][algorithm-pattern-key-compare] algorithm.\n\n#### Parameters\n\n- `a` (`string`)\n  — the first key\n- `b` (`string`)\n  — the key to compare against `a`\n\n#### Returns\n\n([`PatternKeyComparison`](#patternkeycomparsion)) The pattern key comparsion result\n\n### `patternMatch(matchKey, matchObject)`\n\nGet a subpath pattern match for `matchKey`.\n\n#### Parameters\n\n- `matchKey` (`string`)\n  — the key to expand\n- `matchObject` (`unknown`)\n  — the match keys object\n\n#### Returns\n\n([`PatternMatch`](#patternmatch) | `null`) List, where the first item is the key of a package exports or imports target\nobject, and the last is a subpath pattern match\n\n### `readPackageJson\u003cT\u003e(id[, specifier][, parent][, fs])`\n\nRead a `package.json` file.\n\nImplements the [`READ_PACKAGE_JSON`][algorithm-read-package-json] algorithm.\n\n\u003e 👉 **Note**: Returns a promise if `fs.readFile` or `fs.stat` is async.\n\n#### Overloads\n\n```ts\nfunction readPackageJson(\n  this: void,\n  id: EmptyString | null | undefined,\n  specifier?: string | null | undefined,\n  parent?: ModuleId | null | undefined,\n  fs?: FileSystem | null | undefined\n): null\n```\n\n```ts\nfunction readPackageJson\u003cT extends Awaitable\u003cPackageJson | null\u003e\u003e(\n  this: void,\n  id: ModuleId | null | undefined,\n  specifier?: string | null | undefined,\n  parent?: ModuleId | null | undefined,\n  fs?: FileSystem | null | undefined\n): T\n```\n\n#### Type Parameters\n\n- `T` ([`Awaitable\u003cPackageJson | null\u003e`][pkg-package-json])\n  — the parsed file contents\n\n#### Parameters\n\n- `id` ([`ModuleId`](#moduleid) | `null` | `undefined`)\n  — the url of the package directory, the `package.json` file, or a module in the same directory as a `package.json`\n- `specifier` (`string` | `null` | `undefined`)\n  — the module specifier that initiated the reading of the `package.json` file\n  \u003e 👉 **note**: should be a `file:` url if `parent` is not a url\n- `parent` ([`ModuleId`](#moduleid) | `null` | `undefined`)\n  — the url of the parent module\n- `fs` ([`FileSystem`](#filesystem) | `null` | `undefined`)\n  — the file system api\n\n#### Returns\n\n(`T`) The parsed file contents\n\n#### Throws\n\n- [`ERR_INVALID_PACKAGE_CONFIG`][err-invalid-package-config]\n\n### `resolveAlias(specifier[, options])`\n\nResolve an aliased `specifier`.\n\n#### Parameters\n\n- `specifier` (`string`)\n  — the specifier using an alias\n- `options` ([`ResolveAliasOptions`](#resolvealiasoptions) | `null` | `undefined`)\n  — alias resolution options\n\n#### Returns\n\n(`string` | `null`) The specifier of the aliased module\n\n### `resolveModule\u003cT\u003e(specifier, parent[, options])`\n\nResolve a module `specifier`.\n\nImplements the [`ESM_RESOLVE`][algorithm-esm-resolve] algorithm, mostly \\:wink:.\n\nAdds support for:\n\n- Changing file extensions\n- Directory index resolution\n- Extensionless file resolution\n- Path alias resolution\n- Scopeless `@types/*` resolution (i.e. `unist` -\u003e `@types/unist`)\n\n\u003e 👉 **Note**: Returns a promise if\n\u003e [`moduleResolve`](#moduleresolvetspecifier-parent-conditions-mainfields-preservesymlinks-fs) returns a promise.\n\n#### Type Parameters\n\n- `T` ([`Awaitable\u003cURL\u003e`](#awaitablet))\n  — the resolved url\n\n#### Parameters\n\n- `specifier` (`string`)\n  — the module specifier to resolve\n- `parent` ([`ModuleId`](#moduleid))\n  — the url of the parent module\n- `options` ([`ResolveModuleOptions`](#resolvemoduleoptions))\n  — module resolution options\n\n#### Returns\n\n(`T`) The resolved URL\n\n### `resolver`\n\nAn object containing resolution algorithm implementations.\n\n- [`legacyMainResolve`](#legacymainresolvetpackageurl-manifest-mainfields-parent-fs)\n- [`moduleResolve`](#moduleresolvetspecifier-parent-conditions-mainfields-preservesymlinks-fs)\n- [`packageExportsResolve`](#packageexportsresolvetpackageurl-subpath-exports-conditions-parent-fs)\n- [`packageImportsExportsResolve`](#packageimportsexportsresolvetmatchkey-matchobject-packageurl-isimports-conditions-mainfields-parent-fs)\n- [`packageImportsResolve`](#packageimportsresolvetspecifier-parent-conditions-mainfields-fs)\n- [`packageResolve`](#packageresolvetspecifier-parent-conditions-mainfields-fs)\n- [`packageSelfResolve`](#packageselfresolvetname-subpath-parent-conditions-fs)\n- [`packageTargetResolve`](#packagetargetresolvetpackageurl-target-subpath-patternmatch-isimports-conditions-mainfields-parent-fs)\n\n### `root`\n\n`URL`\n\nThe URL of the file system root.\n\n### `toRelativeSpecifier(url, parent)`\n\nTurn `url` into a *relative specifier*.\n\n\u003e 👉 **Note**: The relative specifier will only have a file extension if `specifier` also has an extension.\n\n#### Parameters\n\n- `url` ([`ModuleId`](#moduleid))\n  — the `file:` url to convert\n- `parent` ([`ModuleId`](#moduleid))\n  — the parent module id\n\n#### Returns\n\n(`string`) The relative specifier\n\n### `toUrl(id[, parent])`\n\nConvert `id` to a `URL`.\n\n\u003e 👉 **Note**: If `id` cannot be parsed as a `URL` and is also not a [builtin module][builtin-module],\n\u003e it will be assumed to be a path and converted to a [`file:` URL][file-url].\n\n#### Parameters\n\n- `id` ([`ModuleId`](#moduleid))\n  — the module id to convert\n- `parent` ([`ModuleId`](#moduleid) | `null` | `undefined`)\n  — the base url to resolve against if `id` is not absolute\n\n#### Returns\n\n(`URL`) The new URL\n\n## Types\n\nThis package is fully typed with [TypeScript][].\n\n### `Aliases`\n\nRecord, where each key is a path alias or pattern\nand each value is a path mapping configuration (`interface`).\n\n```ts\ninterface Aliases {\n  [alias: string]: (string | null | undefined)[] | string | null | undefined\n}\n```\n\nWhen developing extensions that use additional aliases, augment `Aliases` to register custom aliases:\n\n```ts\ndeclare module '@flex-development/mlly' {\n  interface Aliases {\n    custom?: string[] | string | null\n  }\n}\n```\n\n### `Awaitable\u003cT\u003e`\n\nCreate a union of `T` and `T` as a promise-like object (`type`).\n\n```ts\ntype Awaitable\u003cT\u003e = PromiseLike\u003cT\u003e | T\n```\n\n#### Type Parameters\n\n- `T` (`any`)\n  - the value\n\n### `ChangeExtFn\u003c[Ext]\u003e`\n\nGet a new file extension for `url` (`type`).\n\nReturning an empty string (`''`), `null`, or `undefined` will remove the current file extension.\n\n```ts\ntype ChangeExtFn\u003c\n  Ext extends string | null | undefined = string | null | undefined\n\u003e = (this: void, url: URL, specifier: string) =\u003e Ext\n```\n\n#### Type Parameters\n\n- `Ext` (`string` | `null` | `undefined`, optional)\n  — the new file extension\n\n#### Parameters\n\n- `url` (`URL`)\n  — the resolved module URL\n- `specifier` (`string`)\n  — the module specifier being resolved\n\n#### Returns\n\n(`Ext`) The new file extension\n\n### `ConditionMap`\n\nRegistry of export/import conditions (`interface`).\n\nWhen developing extensions that use additional conditions, augment `ConditionMap` to register custom conditions:\n\n```ts\ndeclare module '@flex-development/mlly' {\n  interface ConditionMap {\n    custom: 'custom'\n  }\n}\n```\n\n### `Condition`\n\nUnion of values that can occur where a export/import condition is expected (`type`).\n\nTo register new conditions, augment [`ConditionMap`](#conditionmap).\nThey will be added to this union automatically.\n\n```ts\ntype Condition = ConditionMap[keyof ConditionMap]\n```\n\n### `Dot`\n\nA dot character (`'.'`) (`type`).\n\n```ts\ntype Dot = '.'\n```\n\n### `EmptyArray`\n\nAn empty array (`type`).\n\n```ts\ntype EmptyArray = []\n```\n\n### `EmptyObject`\n\nAn empty object (`type`).\n\n```ts\ntype EmptyObject = { [tag]?: never }\n```\n\n### `EmptyString`\n\nAn empty string (`type`).\n\n```ts\ntype EmptyString = ''\n```\n\n### `Ext`\n\nA file extension (`type`).\n\n```ts\ntype Ext = `${Dot}${string}`\n```\n\n### `FileSystem`\n\nThe file system API (`interface`).\n\n#### Properties\n\n- `readFile` ([`ReadFile`](#readfilet))\n  — read the entire contents of a file\n- `realpath` ([`Realpath`](#realpatht))\n  — compute a canonical pathname by resolving `.`, `..`, and symbolic links\n- `stat` ([`Stat`](#statt))\n  — get information about a directory or file\n\n### `GetSourceContext`\n\nSource code retrieval context (`interface`).\n\n#### Extends\n\n- [`GetSourceOptions`](#getsourceoptions)\n\n#### Properties\n\n- `fs` ([`FileSystem`](#filesystem))\n  — the file system api\n- `handlers` ([`GetSourceHandlers`](#getsourcehandlers))\n  — record, where each key is a url protocol and each value is a source code handler\n- `req` (`RequestInit`)\n  — request options for network based modules\n- `schemes` (`Set\u003cstring\u003e`)\n  — the list of supported url schemes\n\n### `GetSourceHandler`\n\nGet the source code for a module (`type`).\n\n```ts\ntype GetSourceHandler = (\n  this: GetSourceContext,\n  url: URL\n) =\u003e Awaitable\u003cUint8Array | string | null | undefined\u003e\n```\n\n#### Parameters\n\n- **`this`** ([`GetSourceContext`](#getsourcecontext))\n  — the retrieval context\n- `url` (`URL`)\n  — the module URL\n\n#### Returns\n\n([`Awaitable\u003cUint8Array | string | null | undefined\u003e`](#awaitablet)) The source code\n\n### `GetSourceHandlers`\n\nRecord, where key is a URL protocol and each value is a source code handler (`type`).\n\n```ts\ntype GetSourceHandlers = {\n  [H in Protocol]?: GetSourceHandler | null | undefined\n}\n```\n\n### `GetSourceOptions`\n\nOptions for retrieving source code (`interface`).\n\n#### Properties\n\n- `format?` ([`ModuleFormat`](#moduleformat) | `null` | `undefined`)\n  — the module format hint\n- `fs?` ([`FileSystem`](#filesystem) | `null` | `undefined`)\n  — the file system api\n- `handlers?` ([`GetSourceHandlers`](#getsourcehandlers) | `null` | `undefined`)\n  — record, where each key is a url protocol and each value is a source code handler\n- `ignoreErrors?` (`boolean` | `null` | `undefined`)\n  — whether to ignore [`ERR_UNSUPPORTED_ESM_URL_SCHEME`][err-unsupported-esm-url-scheme] if thrown\n- `req?` (`RequestInit` | `null` | `undefined`)\n  — request options for network based modules\n- `schemes?` ([`List\u003cstring\u003e`](#listt) | `null` | `undefined`)\n  — the list of supported url schemes\n  - **default**: `['data', 'file', 'http', 'https', 'node']`\n\n### `IsDirectory`\n\nCheck if a stats object describes a directory (`interface`).\n\n#### Returns\n\n(`boolean`) `true` if stats describes directory, `false` otherwise\n\n### `IsFile`\n\nCheck if a stats object describes a file (`interface`).\n\n#### Returns\n\n(`boolean`) `true` if stats describes regular file, `false` otherwise\n\n### `List\u003c[T]\u003e`\n\nA list (`type`).\n\n```ts\ntype List\u003cT = unknown\u003e = ReadonlySet\u003cT\u003e | readonly T[]\n```\n\n#### Type Parameters\n\n- `T` (`any`, optional)\n  — list item type\n\n### `MainFieldMap`\n\nRegistry of main fields (`interface`).\n\nWhen developing extensions that use additional fields, augment `MainFieldMap` to register custom fields:\n\n```ts\ndeclare module '@flex-development/mlly' {\n  interface MainFieldMap {\n    unpkg: 'unpkg'\n  }\n}\n```\n\n### `MainField`\n\nUnion of values that can occur where a main field is expected (`type`).\n\nTo register new main fields, augment [`MainFieldMap`](#mainfieldmap).\nThey will be added to this union automatically.\n\n```ts\ntype MainField = MainFieldMap[keyof MainFieldMap]\n```\n\n### `ModuleFormatMap`\n\nRegistry of module formats (`interface`).\n\nWhen developing extensions that use additional formats, augment `ModuleFormatMap` to register custom formats:\n\n```ts\ndeclare module '@flex-development/mlly' {\n  interface ModuleFormatMap {\n    custom: 'custom'\n  }\n}\n```\n\n### `ModuleFormat`\n\nUnion of values that can occur where a module format is expected (`type`).\n\nTo register new main formats, augment [`ModuleFormatMap`](#moduleformatmap).\nThey will be added to this union automatically.\n\n```ts\ntype ModuleFormat = ModuleFormatMap[keyof ModuleFormatMap]\n```\n\n### `ModuleId`\n\nUnion of values that can occur where a ECMAScript (ES) module identifier is expected (`type`).\n\n```ts\ntype ModuleId = URL | string\n```\n\n### `Numeric`\n\nA string that can be parsed to a valid number (`type`).\n\n```ts\ntype Numeric = `${number}`\n```\n\n### `PatternKeyComparsionMap`\n\nRegistry of [`PATTERN_KEY_COMPARE`][algorithm-pattern-key-compare] algorithm results (`interface`).\n\nWhen developing extensions that use additional results, augment `PatternKeyComparsionMap` to register custom results:\n\n```ts\ndeclare module '@flex-development/mlly' {\n  interface PatternKeyComparsionMap {\n    afterThree: 3\n  }\n}\n```\n\n### `PatternKeyComparsion`\n\nUnion of values that can occur where a [`PATTERN_KEY_COMPARE`][algorithm-pattern-key-compare] algorithm result\nis expected (`type`).\n\nTo register new results, augment [`PatternKeyComparisonMap`](#patternkeycomparsionmap).\nThey will be added to this union automatically.\n\n```ts\ntype PatternKeyComparison =\n  PatternKeyComparisonMap[keyof PatternKeyComparisonMap]\n```\n\n### `PatternMatch`\n\nList, where the first item is the key of a package `exports` or `imports` target object,\nand the last is a subpath pattern match (`type`).\n\n```ts\ntype PatternMatch = [expansionKey: string, patternMatch: string | null]\n```\n\n### `ProtocolMap`\n\nRegistry of URL protocols (`interface`).\n\nWhen developing extensions that use additional protocols, augment `ProtocolMap` to register custom protocols:\n\n```ts\ndeclare module '@flex-development/mlly' {\n  interface ProtocolMap {\n    custom: 'custom:'\n  }\n}\n```\n\n### `Protocol`\n\nUnion of values that can occur where a URL protocol is expected (`type`).\n\nTo register new results, augment [`ProtocolMap`](#protocolmap).\nThey will be added to this union automatically.\n\n```ts\ntype Protocol = ProtocolMap[keyof ProtocolMap]\n```\n\n### `ReadFile\u003c[T]\u003e`\n\nRead the entire contents of a file (`interface`).\n\n#### Type Parameters\n\n- `T` ([`Awaitable\u003cBuffer | string\u003e`](#awaitablet), optional)\n  — the file contents\n\n#### Parameters\n\n- `id` ([`ModuleId`](#moduleid))\n  — the module id\n\n#### Returns\n\n(`T`) The file contents\n\n### `Realpath\u003c[T]\u003e`\n\nCompute a canonical pathname by resolving `.`, `..`, and symbolic links (`interface`).\n\n\u003e 👉 **Note**: A canonical pathname is not necessarily unique.\n\u003e Hard links and bind mounts can expose an entity through many pathnames.\n\n#### Type Parameters\n\n- `T` ([`Awaitable\u003cstring\u003e`](#awaitablet), optional)\n  — the canonical pathname\n\n#### Parameters\n\n- `id` ([`ModuleId`](#moduleid))\n  — the module id\n\n#### Returns\n\n(`T`) The canonical pathname\n\n### `ResolveAliasOptions`\n\nOptions for path alias resolution (`interface`).\n\n#### Properties\n\n- `absolute?` (`boolean` | `null` | `undefined`)\n  — whether the resolved specifier should be absolute.\\\n  if `true`, the resolved specifier will be a [`file:` URL][file-url]\n- `aliases?` ([`Aliases`](#aliases) | `null` | `undefined`)\n  — the path mappings dictionary\n  \u003e 👉 **note**: paths should be relative to `cwd`\n- `cwd?` ([`ModuleId`](#moduleid) | `null` | `undefined`)\n  — the url of the directory to resolve non-absolute modules from\n  - **default**: [`cwd()`](#cwd)\n- `parent?` ([`ModuleId`](#moduleid) | `null` | `undefined`)\n  — the url of the parent module\n\n### `ResolveModuleOptions`\n\nOptions for path alias resolution (`interface`).\n\n#### Properties\n\n- `aliases?` ([`Aliases`](#aliases) | `null` | `undefined`)\n  — the path mappings dictionary\n  \u003e 👉 **note**: paths should be relative to `cwd`\n- `conditions?` ([`List\u003cCondition\u003e`](#condition) | `null` | `undefined`)\n  — the list of export/import conditions\n  - **default**: [`defaultConditions`](#defaultconditions)\n  \u003e 👉 **note**: should be sorted by priority\n- `cwd?` ([`ModuleId`](#moduleid) | `null` | `undefined`)\n  — the url of the directory to resolve path `aliases` from\n  - **default**: [`cwd()`](#cwd)\n- `ext?` ([`ChangeExtFn`](#changeextfnext) | `string` | `null` | `undefined`)\n  — a replacement file extension or a function that returns a file extension.\n  \u003e 👉 **note**: an empty string (`''`) or `null` will remove a file extension\n- `extensions?` ([`List\u003cstring\u003e`](#listt) | `null` | `undefined`)\n  — the module extensions to probe for\n  - **default**: [`defaultExtensions`](#defaultextensions)\n  \u003e 👉 **note**: should be sorted by priority\n- `fs?` ([`FileSystem`](#filesystem) | `null` | `undefined`)\n  — the file system api\n- `mainFields?` ([`List\u003cMainField\u003e`](#mainfield) | `null` | `undefined`)\n  — the list of legacy `main` fields\n  - **default**: [`defaultMainFields`](#defaultmainfields)\n  \u003e 👉 **note**: should be sorted by priority\n- `preserveSymlinks?` (`boolean` | `null` | `undefined`)\n  — whether to keep symlinks instead of resolving them\n\n### `Stat\u003c[T]\u003e`\n\nGet information about a directory or file (`interface`).\n\n#### Type Parameters\n\n- `T` ([`Awaitable\u003cStats\u003e`](#stats), optional)\n  — the info\n\n#### Parameters\n\n- `id` ([`ModuleId`](#moduleid))\n  — the module id\n\n#### Returns\n\n(`T`) The info\n\n### `Stats`\n\nAn object describing a directory or file (`interface`).\n\n#### Properties\n\n- `isDirectory` ([`IsDirectory`](#isdirectory))\n  — check if the stats object describes a directory\n- `isFile` ([`IsFile`](#isfile))\n  — check if the stats object describes a file\n\n## Contribute\n\nSee [`CONTRIBUTING.md`](CONTRIBUTING.md).\n\nThis project has a [code of conduct](./CODE_OF_CONDUCT.md). By interacting with this repository, organization, or\ncommunity you agree to abide by its terms.\n\n[algorithm-esm-resolve]: ./docs/resolution-algorithm.md#esm_resolvespecifier-parent-conditions-mainfields-preservesymlinks-extensionformatmap\n\n[algorithm-legacy-main-resolve]: ./docs/resolution-algorithm.md#legacy_main_resolvepackageurl-manifest-mainfields\n\n[algorithm-lookup-package-scope]: ./docs/resolution-algorithm.md#lookup_package_scopeurl-end\n\n[algorithm-package-exports-resolve]: ./docs/resolution-algorithm.md#package_exports_resolvepackageurl-subpath-exports-conditions\n\n[algorithm-package-imports-exports-resolve]: ./docs/resolution-algorithm.md#package_imports_exports_resolvematchkey-matchobject-packageurl-isimports-conditions-mainfields\n\n[algorithm-package-imports-resolve]: ./docs/resolution-algorithm.md#package_imports_resolvespecifier-parent-conditions-mainfields\n\n[algorithm-package-resolve]: ./docs/resolution-algorithm.md#package_resolvespecifier-parent-conditions-mainfields\n\n[algorithm-package-self-resolve]: ./docs/resolution-algorithm.md#package_self_resolvename-subpath-parent-conditions\n\n[algorithm-package-target-resolve]: ./docs/resolution-algorithm.md#package_target_resolvepackageurl-target-subpath-patternmatch-isimports-conditions-mainfields\n\n[algorithm-pattern-key-compare]: ./docs/resolution-algorithm.md#pattern_key_comparea-b\n\n[algorithm-read-package-json]: ./docs/resolution-algorithm.md#read_package_jsonid\n\n[builtin-module]: https://nodejs.org/api/esm.html#builtin-modules\n\n[err-invalid-module-specifier]: https://nodejs.org/api/errors.html#err_invalid_module_specifier\n\n[err-invalid-package-config]: https://nodejs.org/api/errors.html#err_invalid_package_config\n\n[err-invalid-package-target]: https://nodejs.org/api/errors.html#err_invalid_package_target\n\n[err-module-not-found]: https://nodejs.org/api/errors.html#err_module_not_found\n\n[err-package-import-not-defined]: https://nodejs.org/api/errors.html#err_package_import_not_defined\n\n[err-unsupported-esm-url-scheme]: https://nodejs.org/api/errors.html#err_unsupported_esm_url_scheme\n\n[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c\n\n[esmsh]: https://esm.sh\n\n[exports]: https://nodejs.org/api/packages.html#exports\n\n[file-url]: https://nodejs.org/api/esm.html#file-urls\n\n[main]: https://github.com/nodejs/node/blob/v22.9.0/doc/api/packages.md#main\n\n[node-esm]: https://nodejs.org/api/esm.html\n\n[pkg-exports]: https://github.com/flex-development/pkg-types/blob/main/src/exports.ts\n\n[pkg-exports-object]: https://github.com/flex-development/pkg-types/blob/main/src/exports-object.ts\n\n[pkg-imports-subpath]: https://github.com/flex-development/pkg-types/blob/main/src/imports-subpath.ts\n\n[pkg-imports]: https://github.com/flex-development/pkg-types/blob/main/src/imports.ts\n\n[pkg-package-json]: https://github.com/flex-development/pkg-types/blob/main/src/package-json.ts\n\n[subpath-imports]: https://nodejs.org/api/packages.html#subpath-imports\n\n[typescript]: https://www.typescriptlang.org\n\n[yarn]: https://yarnpkg.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflex-development%2Fmlly","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflex-development%2Fmlly","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflex-development%2Fmlly/lists"}