Skip to content

Commit 11121f9

Browse files
committed
update typescript def gen
1 parent b3821fe commit 11121f9

File tree

2 files changed

+16
-20
lines changed

2 files changed

+16
-20
lines changed

src/functions.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@ import path from 'path';
33

44
import TraversalData from './TraversalData.js';
55

6-
import { type } from './typedef.js'; // eslint-disable-line no-unused-vars
7-
86
/**
97
* Get essential info for the given package object consistently formatted.
108
*
119
* @param {object} packageObj - A loaded `package.json` object.
1210
*
13-
* @returns {type.PackageObjFormatted|undefined} The formatted package object or undefined.
11+
* @returns {PackageObjFormatted|undefined} The formatted package object or undefined.
1412
*/
1513
export function formatPackage(packageObj)
1614
{
@@ -58,7 +56,7 @@ export function formatPackage(packageObj)
5856
/**
5957
* Creates the PackageObjFormatted result.
6058
*
61-
* @type {type.PackageObjFormatted}
59+
* @type {PackageObjFormatted}
6260
*/
6361
const packageData = {
6462
name,
@@ -89,7 +87,7 @@ export function formatPackage(packageObj)
8987
* Note: If malformed data is presented the result will undefined. Also note that a file may be specified that
9088
* does not exist and the directory will be resolved. If that directory exists then resolution will continue.
9189
*
92-
* @param {type.PackageQueryOptions} options - The package query options.
90+
* @param {PackageQueryOptions} options - The package query options.
9391
*
9492
* @returns {object|undefined} Loaded `package.json` or undefined if an error has occurred or basepath or root
9593
* directory has been reached.
@@ -105,9 +103,9 @@ export function getPackage(options)
105103
/**
106104
* Attempts to find the nearest package.json via `getPackage` then passes the results to `formatPackage`.
107105
*
108-
* @param {type.PackageQueryOptions} options - The package query options.
106+
* @param {PackageQueryOptions} options - The package query options.
109107
*
110-
* @returns {type.PackageObjFormatted|undefined} Formatted package.json or undefined.
108+
* @returns {PackageObjFormatted|undefined} Formatted package.json or undefined.
111109
*/
112110
export function getPackageAndFormat(options)
113111
{
@@ -121,9 +119,9 @@ export function getPackageAndFormat(options)
121119
* object / `PackageObjData`. Also note that a file may be specified that does not exist and the directory will be
122120
* resolved. If that directory exists then resolution will continue.
123121
*
124-
* @param {type.PackageQueryOptions} options - The package query options.
122+
* @param {PackageQueryOptions} options - The package query options.
125123
*
126-
* @returns {type.PackageObjData} Loaded package.json / path or potentially an error.
124+
* @returns {PackageObjData} Loaded package.json / path or potentially an error.
127125
*/
128126
export function getPackageWithPath(options)
129127
{
@@ -209,7 +207,7 @@ export function getPackageWithPath(options)
209207
* Traversal stops at the first valid `package.json` file as this is how Node works. If the first found `package.json`
210208
* does not have a `type` field then `commonjs` is returned.
211209
*
212-
* @param {type.PackageQueryOptions} options - The package query options.
210+
* @param {PackageQueryOptions} options - The package query options.
213211
*
214212
* @returns {string} Type of package - 'module' for ESM otherwise 'commonjs'.
215213
*/

src/typedef.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* The returned data object from a `getPackageWithPath` query.
33
*
4-
* @typedef {object} type.PackageObjData
4+
* @typedef {object} PackageObjData
55
*
66
* @property {object|undefined} [packageObj] - Loaded `package.json` object.
77
*
@@ -15,7 +15,7 @@
1515
/**
1616
* The returned data object from formatting a `package.json` object.
1717
*
18-
* @typedef {object} type.PackageObjFormatted
18+
* @typedef {object} PackageObjFormatted
1919
*
2020
* @property {string} name - Name property.
2121
*
@@ -41,25 +41,25 @@
4141
/**
4242
* Defines the data object passed to the functions to perform a `package.json` query.
4343
*
44-
* @typedef {object} type.PackageQueryOptions
44+
* @typedef {object} PackageQueryOptions
4545
*
4646
* @property {string|URL} filepath - Initial file or directory path to search for `package.json`.
4747
*
4848
* @property {string|URL} [basepath] - Base path to stop traversing. Set to the root path of `filepath` if not
4949
* provided.
5050
*
51-
* @property {type.TraversalCallback} [callback] - A function that evaluates a loaded package.json object and
51+
* @property {TraversalCallback} [callback] - A function that evaluates a loaded package.json object and
5252
* associated traversal data returning a truthy value to stops or
5353
* continue the traversal.
5454
*/
5555

5656
/**
57-
* An optional callback function for {@link type.PackageQueryOptions} that evaluates a loaded package.json object and
57+
* An optional callback function for {@link PackageQueryOptions} that evaluates a loaded package.json object and
5858
* associated traversal data returning a truthy value to stop or continue the traversal.
5959
*
60-
* @callback type.TraversalCallback
60+
* @callback TraversalCallback
6161
*
62-
* @param {type.TraversalDataObj} data - The traversal data object.
62+
* @param {TraversalDataObj} data - The traversal data object.
6363
*
6464
* @returns {boolean} True to stop traversal / false to continue.
6565
*/
@@ -68,7 +68,7 @@
6868
* Defines the data object passed to any traversal callback function. All paths are converted to Unix style paths,
6969
* so for instance on Windows `\` and `\\` are replaced with `/`.
7070
*
71-
* @typedef {object} type.TraversalDataObj
71+
* @typedef {object} TraversalDataObj
7272
*
7373
* @property {string} baseDir - Stores the `basepath` directory as a Unix styled path.
7474
*
@@ -84,5 +84,3 @@
8484
*
8585
* @property {string} rootPath - The root path to stop traversal as a Unix styled path.
8686
*/
87-
88-
export const type = {};

0 commit comments

Comments
 (0)