Skip to content

Commit 0dbbcdd

Browse files
committed
refactor(types): add type comments for util/identifier
1 parent 0be0d1f commit 0dbbcdd

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

lib/util/identifier.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,30 @@
11
"use strict";
22
const path = require("path");
33

4+
/** @typedef {{relativePaths: Map<string, string|Map<string,string>>}} MakeRelativePathsCache */
5+
6+
/**
7+
*
8+
* @param {string} maybeAbsolutePath path to check
9+
* @return {boolean} returns true if path is "Absolute Path"-like
10+
*/
411
const looksLikeAbsolutePath = maybeAbsolutePath => {
512
return /^(?:[a-z]:\\|\/)/i.test(maybeAbsolutePath);
613
};
714

15+
/**
16+
*
17+
* @param {string} p path to normalize
18+
* @return {string} normalized version of path
19+
*/
820
const normalizePathSeparator = p => p.replace(/\\/g, "/");
921

22+
/**
23+
*
24+
* @param {string} context context for relative path
25+
* @param {string} identifier identifier for path
26+
* @return {string} a converted relative path
27+
*/
1028
const _makePathsRelative = (context, identifier) => {
1129
return identifier
1230
.split(/([|! ])/)
@@ -19,6 +37,13 @@ const _makePathsRelative = (context, identifier) => {
1937
.join("");
2038
};
2139

40+
/**
41+
*
42+
* @param {string} context context used to create relative path
43+
* @param {string} identifier identifier used to create relative path
44+
* @param {MakeRelativePathsCache=} cache the cache object being set
45+
* @return {string} the returned relative path
46+
*/
2247
exports.makePathsRelative = (context, identifier, cache) => {
2348
if (!cache) return _makePathsRelative(context, identifier);
2449

0 commit comments

Comments
 (0)