node-exports-info
Advanced tools
| import { type Category } from './types'; | ||
| declare function getCategoriesForRange(rangeA: string): Category[]; | ||
| export = getCategoriesForRange; |
| import type { Category } from './types'; | ||
| declare function getCategory(nodeVersion?: string): Category; | ||
| export = getCategory; |
| import type { Category, Condition } from './types'; | ||
| declare function getConditionsForCategory( | ||
| category: Category, | ||
| moduleSystem?: 'import' | 'require' | ||
| ): ( | ||
| | ['default'] | ||
| | ['import', 'node', 'default'] | ||
| | ['node', 'require', 'default'] | ||
| | ['import', 'node', 'require', 'default'] | ||
| | null | ||
| ); | ||
| export = getConditionsForCategory; |
| import type { Category, Range } from './types'; | ||
| declare function getRange(category: Category): Range; | ||
| export = getRange; |
| import type { Category, Range } from "./types"; | ||
| declare function getRangePairs(): [Range, Category][]; | ||
| export = getRangePairs; |
| import type { Category } from './types'; | ||
| declare function isCategory(category: unknown): category is Category; | ||
| export = isCategory; |
+15
| type Ranges = { | ||
| __proto__: null, | ||
| '>= 17': 'pattern-trailers-no-dir-slash'; | ||
| '^14.19 || ^16.9': 'pattern-trailers'; | ||
| '^12.20 || 14.13 - 14.18 || 15.x || 16.0 - 16.8': 'patterns'; | ||
| '12.17 - 12.19 || ^13.13 || 14.0 - 14.12': 'broken-dir-slash-conditions'; | ||
| '13.7 - 13.12': 'conditions'; | ||
| '13.3 - 13.6': 'experimental'; | ||
| '13.0 - 13.2': 'broken'; | ||
| '< 12.17': 'pre-exports'; | ||
| }; | ||
| declare const ranges: Ranges; | ||
| export = ranges; |
| { | ||
| "compilerOptions": { | ||
| /* Visit https://aka.ms/tsconfig to read more about this file */ | ||
| /* Projects */ | ||
| /* Language and Environment */ | ||
| "target": "ESNext", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ | ||
| // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ | ||
| // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ | ||
| "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ | ||
| // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ | ||
| /* Modules */ | ||
| "module": "commonjs", /* Specify what module code is generated. */ | ||
| // "rootDir": "./", /* Specify the root folder within your source files. */ | ||
| // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ | ||
| // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ | ||
| // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ | ||
| // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ | ||
| // "typeRoots": ["types"], /* Specify multiple folders that act like './node_modules/@types'. */ | ||
| "resolveJsonModule": true, /* Enable importing .json files. */ | ||
| // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ | ||
| /* JavaScript Support */ | ||
| "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ | ||
| "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ | ||
| "maxNodeModuleJsDepth": 0, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ | ||
| /* Emit */ | ||
| "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ | ||
| "declarationMap": true, /* Create sourcemaps for d.ts files. */ | ||
| "noEmit": true, /* Disable emitting files from a compilation. */ | ||
| /* Interop Constraints */ | ||
| "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ | ||
| "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ | ||
| "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ | ||
| /* Type Checking */ | ||
| "strict": true, /* Enable all strict type-checking options. */ | ||
| /* Completeness */ | ||
| //"skipLibCheck": true /* Skip type checking all .d.ts files. */ | ||
| }, | ||
| "exclude": [ | ||
| "coverage" | ||
| ] | ||
| } |
| import ranges from './ranges'; | ||
| export type Category = typeof ranges[Exclude<keyof typeof ranges, '__proto__'>]; | ||
| export type Range = Exclude<keyof typeof ranges, '__proto__'>; | ||
| export type RangePair = [Range, Category]; | ||
| export type Condition = 'node' | 'import' | 'require' | 'default'; |
+9
-0
@@ -8,2 +8,11 @@ # Changelog | ||
| ## [v1.3.1](https://github.com/inspect-js/node-exports-info/compare/v1.3.0...v1.3.1) - 2024-02-26 | ||
| ### Commits | ||
| - add types [`c3449ed`](https://github.com/inspect-js/node-exports-info/commit/c3449edd1e3c0e1dd019c3c5ef9f075305577372) | ||
| - [actions] skip ls check on node < 10; remove redundant finisher [`8a88b7b`](https://github.com/inspect-js/node-exports-info/commit/8a88b7b82a05787540541bd40dd92c4d73083e19) | ||
| - [actions] remove erroneous `none` permission [`9145df6`](https://github.com/inspect-js/node-exports-info/commit/9145df664d6ccbb49a812ccadb35ecad5957a6ba) | ||
| - [Dev Deps] update `tape` [`ff1f4de`](https://github.com/inspect-js/node-exports-info/commit/ff1f4ded536ea936a96c1c01f026768abc41ac27) | ||
| ## [v1.3.0](https://github.com/inspect-js/node-exports-info/compare/v1.2.1...v1.3.0) - 2023-12-15 | ||
@@ -10,0 +19,0 @@ |
@@ -9,11 +9,13 @@ 'use strict'; | ||
| /** @type {import('./getCategoriesForRange')} */ | ||
| module.exports = function getCategoriesForRange(rangeA) { | ||
| return flatMap( | ||
| entries(ranges), | ||
| /** @type {(entry: import('./types').RangePair) => import('./types').Category[] | []} */ | ||
| function (entry) { | ||
| var rangeB = entry[0]; | ||
| var category = entry[1]; | ||
| return intersects(rangeA, rangeB) ? category : []; | ||
| return intersects(rangeA, rangeB) ? [category] : []; | ||
| } | ||
| ); | ||
| }; |
+3
-0
@@ -9,6 +9,9 @@ 'use strict'; | ||
| /** @type {import('./getCategory')} */ | ||
| module.exports = function getCategory() { | ||
| var version = arguments.length > 0 ? arguments[0] : process.version; | ||
| /** @type {import('./types').RangePair | undefined} */ | ||
| var found = find( | ||
| entries(ranges), | ||
| /** @type {(entry: import('./types').RangePair) => boolean} */ | ||
| function (entry) { | ||
@@ -15,0 +18,0 @@ var range = entry[0]; |
@@ -8,5 +8,8 @@ 'use strict'; | ||
| /** @type {import('./getConditionsForCategory')} */ | ||
| module.exports = function getConditionsForCategory(category) { | ||
| /** @type {import('./types').RangePair | undefined} */ | ||
| var found = find( | ||
| entries(ranges), | ||
| /** @type {(entry: import('./types').RangePair) => boolean} */ | ||
| function (entry) { | ||
@@ -13,0 +16,0 @@ var cat = entry[1]; |
+3
-0
@@ -8,5 +8,8 @@ 'use strict'; | ||
| /** @type {import('./getRange')} */ | ||
| module.exports = function getRange(category) { | ||
| /** @type {import('./types').RangePair | undefined} */ | ||
| var found = find( | ||
| entries(ranges), | ||
| /** @type {(entry: import('./types').RangePair) => boolean} */ | ||
| function (entry) { | ||
@@ -13,0 +16,0 @@ var cat = entry[1]; |
+1
-0
@@ -7,4 +7,5 @@ 'use strict'; | ||
| /** @type {import('./getRangePairs')} */ | ||
| module.exports = function getRangePairs() { | ||
| return entries(ranges); | ||
| }; |
+2
-1
@@ -5,4 +5,5 @@ 'use strict'; | ||
| /** @type {import('./isCategory')} */ | ||
| module.exports = function isCategory(category) { | ||
| var all = getRangePairs(category); | ||
| var all = getRangePairs(); | ||
@@ -9,0 +10,0 @@ for (var i = 0; i < all.length; i++) { |
+12
-2
| { | ||
| "name": "node-exports-info", | ||
| "version": "1.3.0", | ||
| "version": "1.3.1", | ||
| "description": "Info about node `exports` field support: version ranges, categories, etc.", | ||
@@ -21,2 +21,3 @@ "main": false, | ||
| "lint": "eslint --ext=js,mjs .", | ||
| "postlint": "tsc -p .", | ||
| "pretest": "npm run lint", | ||
@@ -66,2 +67,10 @@ "tests-only": "nyc tape 'test/**/*.js'", | ||
| "@ljharb/eslint-config": "^21.1.0", | ||
| "@types/array.prototype.find": "^2.2.0", | ||
| "@types/array.prototype.flatmap": "^1.2.6", | ||
| "@types/es-value-fixtures": "^1.4.4", | ||
| "@types/for-each": "^0.3.3", | ||
| "@types/object-inspect": "^1.8.4", | ||
| "@types/object.entries": "^1.1.1", | ||
| "@types/semver": "^6.2.7", | ||
| "@types/tape": "^5.6.4", | ||
| "aud": "^2.0.4", | ||
@@ -77,3 +86,4 @@ "auto-changelog": "^2.4.0", | ||
| "safe-publish-latest": "^2.0.0", | ||
| "tape": "^5.7.2" | ||
| "tape": "^5.7.5", | ||
| "typescript": "next" | ||
| }, | ||
@@ -80,0 +90,0 @@ "engines": { |
+1
-0
| 'use strict'; | ||
| /** @type {import('./ranges')} */ | ||
| module.exports = { | ||
@@ -4,0 +5,0 @@ __proto__: null, |
@@ -11,2 +11,3 @@ 'use strict'; | ||
| t['throws']( | ||
| // @ts-expect-error | ||
| function () { getConditionsForCategory('not a category'); }, | ||
@@ -37,2 +38,3 @@ RangeError, | ||
| st['throws']( | ||
| // @ts-expect-error | ||
| function () { getConditionsForCategory(category, 'not a thing'); }, | ||
@@ -39,0 +41,0 @@ TypeError, |
+1
-0
@@ -11,2 +11,3 @@ 'use strict'; | ||
| t['throws']( | ||
| // @ts-expect-error | ||
| function () { getRange('not a category'); }, | ||
@@ -13,0 +14,0 @@ RangeError, |
30062
31.38%30
42.86%420
29.63%21
75%