@docusaurus/utils 2.0.0-beta.ff31de0ff → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (111) hide show
  1. package/README.md +1 -1
  2. package/lib/constants.d.ts +73 -0
  3. package/lib/constants.d.ts.map +1 -0
  4. package/lib/constants.js +78 -0
  5. package/lib/constants.js.map +1 -0
  6. package/lib/dataFileUtils.d.ts +60 -0
  7. package/lib/dataFileUtils.d.ts.map +1 -0
  8. package/lib/dataFileUtils.js +91 -0
  9. package/lib/dataFileUtils.js.map +1 -0
  10. package/lib/emitUtils.d.ts +32 -0
  11. package/lib/emitUtils.d.ts.map +1 -0
  12. package/lib/emitUtils.js +80 -0
  13. package/lib/emitUtils.js.map +1 -0
  14. package/lib/gitUtils.d.ts +66 -0
  15. package/lib/gitUtils.d.ts.map +1 -0
  16. package/lib/gitUtils.js +63 -0
  17. package/lib/gitUtils.js.map +1 -0
  18. package/lib/globUtils.d.ts +40 -0
  19. package/lib/globUtils.d.ts.map +1 -0
  20. package/lib/globUtils.js +71 -0
  21. package/lib/globUtils.js.map +1 -0
  22. package/lib/hashUtils.d.ts +17 -0
  23. package/lib/hashUtils.d.ts.map +1 -0
  24. package/lib/hashUtils.js +42 -0
  25. package/lib/hashUtils.js.map +1 -0
  26. package/lib/i18nUtils.d.ts +53 -0
  27. package/lib/i18nUtils.d.ts.map +1 -0
  28. package/lib/i18nUtils.js +70 -0
  29. package/lib/i18nUtils.js.map +1 -0
  30. package/lib/index.d.ts +17 -82
  31. package/lib/index.d.ts.map +1 -0
  32. package/lib/index.js +91 -411
  33. package/lib/index.js.map +1 -0
  34. package/lib/jsUtils.d.ts +28 -0
  35. package/lib/jsUtils.d.ts.map +1 -0
  36. package/lib/jsUtils.js +57 -0
  37. package/lib/jsUtils.js.map +1 -0
  38. package/lib/markdownLinks.d.ts +49 -5
  39. package/lib/markdownLinks.d.ts.map +1 -0
  40. package/lib/markdownLinks.js +57 -13
  41. package/lib/markdownLinks.js.map +1 -0
  42. package/lib/markdownUtils.d.ts +112 -0
  43. package/lib/markdownUtils.d.ts.map +1 -0
  44. package/lib/markdownUtils.js +271 -0
  45. package/lib/markdownUtils.js.map +1 -0
  46. package/lib/pathUtils.d.ts +52 -0
  47. package/lib/pathUtils.d.ts.map +1 -0
  48. package/lib/pathUtils.js +115 -0
  49. package/lib/pathUtils.js.map +1 -0
  50. package/lib/shellUtils.d.ts +8 -0
  51. package/lib/shellUtils.d.ts.map +1 -0
  52. package/lib/shellUtils.js +21 -0
  53. package/lib/shellUtils.js.map +1 -0
  54. package/lib/slugger.d.ts +24 -0
  55. package/lib/slugger.d.ts.map +1 -0
  56. package/lib/slugger.js +23 -0
  57. package/lib/slugger.js.map +1 -0
  58. package/lib/tags.d.ts +59 -0
  59. package/lib/tags.d.ts.map +1 -0
  60. package/lib/tags.js +91 -0
  61. package/lib/tags.js.map +1 -0
  62. package/lib/urlUtils.d.ts +66 -0
  63. package/lib/urlUtils.d.ts.map +1 -0
  64. package/lib/urlUtils.js +207 -0
  65. package/lib/urlUtils.js.map +1 -0
  66. package/lib/webpackUtils.d.ts +35 -0
  67. package/lib/webpackUtils.d.ts.map +1 -0
  68. package/lib/webpackUtils.js +115 -0
  69. package/lib/webpackUtils.js.map +1 -0
  70. package/package.json +28 -10
  71. package/src/constants.ts +98 -0
  72. package/src/dataFileUtils.ts +122 -0
  73. package/src/deps.d.ts +10 -0
  74. package/src/emitUtils.ts +99 -0
  75. package/src/gitUtils.ts +146 -0
  76. package/src/globUtils.ts +85 -0
  77. package/src/hashUtils.ts +38 -0
  78. package/src/i18nUtils.ts +114 -0
  79. package/src/index.ts +98 -521
  80. package/src/jsUtils.ts +59 -0
  81. package/src/markdownLinks.ts +101 -30
  82. package/src/markdownUtils.ts +357 -0
  83. package/src/pathUtils.ts +123 -0
  84. package/src/shellUtils.ts +18 -0
  85. package/src/slugger.ts +36 -0
  86. package/src/tags.ts +130 -0
  87. package/src/urlUtils.ts +234 -0
  88. package/src/webpackUtils.ts +153 -0
  89. package/lib/.tsbuildinfo +0 -3928
  90. package/lib/codeTranslationsUtils.d.ts +0 -11
  91. package/lib/codeTranslationsUtils.js +0 -50
  92. package/lib/escapePath.d.ts +0 -17
  93. package/lib/escapePath.js +0 -25
  94. package/lib/markdownParser.d.ts +0 -28
  95. package/lib/markdownParser.js +0 -132
  96. package/lib/posixPath.d.ts +0 -14
  97. package/lib/posixPath.js +0 -28
  98. package/src/__tests__/__fixtures__/defaultCodeTranslations/en.json +0 -4
  99. package/src/__tests__/__fixtures__/defaultCodeTranslations/fr-FR.json +0 -5
  100. package/src/__tests__/__fixtures__/defaultCodeTranslations/fr.json +0 -4
  101. package/src/__tests__/__snapshots__/index.test.ts.snap +0 -8
  102. package/src/__tests__/codeTranslationsUtils.test.ts +0 -112
  103. package/src/__tests__/escapePath.test.ts +0 -25
  104. package/src/__tests__/index.test.ts +0 -681
  105. package/src/__tests__/markdownParser.test.ts +0 -772
  106. package/src/__tests__/posixPath.test.ts +0 -25
  107. package/src/codeTranslationsUtils.ts +0 -56
  108. package/src/escapePath.ts +0 -23
  109. package/src/markdownParser.ts +0 -177
  110. package/src/posixPath.ts +0 -27
  111. package/tsconfig.json +0 -9
package/lib/index.js CHANGED
@@ -6,414 +6,94 @@
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.parseMarkdownHeadingId = exports.updateTranslationFileMessages = exports.getSwizzledComponent = exports.mergeTranslations = exports.reportMessage = exports.getFolderContainingFile = exports.findFolderContainingFile = exports.findAsyncSequential = exports.mapAsyncSequencial = exports.getPluginI18nPath = exports.getElementsAround = exports.getFilePathForRoutePath = exports.removePrefix = exports.removeSuffix = exports.removeTrailingSlash = exports.addTrailingPathSeparator = exports.addTrailingSlash = exports.addLeadingSlash = exports.resolvePathname = exports.isValidPathname = exports.getEditUrl = exports.aliasedSitePath = exports.normalizeUrl = exports.getSubFolder = exports.idx = exports.genChunkName = exports.toMessageRelativeFilePath = exports.genComponentName = exports.upperFirst = exports.docuHash = exports.simpleHash = exports.encodePath = exports.fileToPath = exports.objectWithKeySorted = exports.generate = exports.posixPath = void 0;
10
- const tslib_1 = require("tslib");
11
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
12
- const path_1 = tslib_1.__importDefault(require("path"));
13
- const crypto_1 = require("crypto");
14
- const lodash_1 = require("lodash");
15
- const escape_string_regexp_1 = tslib_1.__importDefault(require("escape-string-regexp"));
16
- const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
17
- const url_1 = require("url");
18
- // @ts-expect-error: no typedefs :s
19
- const resolve_pathname_1 = tslib_1.__importDefault(require("resolve-pathname"));
20
- const posixPath_1 = require("./posixPath");
21
- exports.posixPath = posixPath_1.posixPath;
22
- tslib_1.__exportStar(require("./codeTranslationsUtils"), exports);
23
- tslib_1.__exportStar(require("./markdownParser"), exports);
24
- tslib_1.__exportStar(require("./markdownLinks"), exports);
25
- tslib_1.__exportStar(require("./escapePath"), exports);
26
- const fileHash = new Map();
27
- async function generate(generatedFilesDir, file, content, skipCache = process.env.NODE_ENV === 'production') {
28
- const filepath = path_1.default.join(generatedFilesDir, file);
29
- if (skipCache) {
30
- await fs_extra_1.default.ensureDir(path_1.default.dirname(filepath));
31
- await fs_extra_1.default.writeFile(filepath, content);
32
- return;
33
- }
34
- let lastHash = fileHash.get(filepath);
35
- // If file already exists but its not in runtime cache yet,
36
- // we try to calculate the content hash and then compare
37
- // This is to avoid unnecessary overwriting and we can reuse old file.
38
- if (!lastHash && fs_extra_1.default.existsSync(filepath)) {
39
- const lastContent = await fs_extra_1.default.readFile(filepath, 'utf8');
40
- lastHash = crypto_1.createHash('md5').update(lastContent).digest('hex');
41
- fileHash.set(filepath, lastHash);
42
- }
43
- const currentHash = crypto_1.createHash('md5').update(content).digest('hex');
44
- if (lastHash !== currentHash) {
45
- await fs_extra_1.default.ensureDir(path_1.default.dirname(filepath));
46
- await fs_extra_1.default.writeFile(filepath, content);
47
- fileHash.set(filepath, currentHash);
48
- }
49
- }
50
- exports.generate = generate;
51
- function objectWithKeySorted(obj) {
52
- // https://github.com/lodash/lodash/issues/1459#issuecomment-460941233
53
- return Object.keys(obj)
54
- .sort()
55
- .reduce((acc, key) => {
56
- acc[key] = obj[key];
57
- return acc;
58
- }, {});
59
- }
60
- exports.objectWithKeySorted = objectWithKeySorted;
61
- const indexRE = /(^|.*\/)index\.(md|mdx|js|jsx|ts|tsx)$/i;
62
- const extRE = /\.(md|mdx|js|jsx|ts|tsx)$/;
63
- /**
64
- * Convert filepath to url path.
65
- * Example: 'index.md' -> '/', 'foo/bar.js' -> '/foo/bar',
66
- */
67
- function fileToPath(file) {
68
- if (indexRE.test(file)) {
69
- return file.replace(indexRE, '/$1');
70
- }
71
- return `/${file.replace(extRE, '').replace(/\\/g, '/')}`;
72
- }
73
- exports.fileToPath = fileToPath;
74
- function encodePath(userpath) {
75
- return userpath
76
- .split('/')
77
- .map((item) => encodeURIComponent(item))
78
- .join('/');
79
- }
80
- exports.encodePath = encodePath;
81
- function simpleHash(str, length) {
82
- return crypto_1.createHash('md5').update(str).digest('hex').substr(0, length);
83
- }
84
- exports.simpleHash = simpleHash;
85
- /**
86
- * Given an input string, convert to kebab-case and append a hash.
87
- * Avoid str collision.
88
- */
89
- function docuHash(str) {
90
- if (str === '/') {
91
- return 'index';
92
- }
93
- const shortHash = simpleHash(str, 3);
94
- return `${lodash_1.kebabCase(str)}-${shortHash}`;
95
- }
96
- exports.docuHash = docuHash;
97
- /**
98
- * Convert first string character to the upper case.
99
- * E.g: docusaurus -> Docusaurus
100
- */
101
- function upperFirst(str) {
102
- return str ? str.charAt(0).toUpperCase() + str.slice(1) : '';
103
- }
104
- exports.upperFirst = upperFirst;
105
- /**
106
- * Generate unique React Component Name.
107
- * E.g: /foo-bar -> FooBar096
108
- */
109
- function genComponentName(pagePath) {
110
- if (pagePath === '/') {
111
- return 'index';
112
- }
113
- const pageHash = docuHash(pagePath);
114
- return upperFirst(lodash_1.camelCase(pageHash));
115
- }
116
- exports.genComponentName = genComponentName;
117
- // When you want to display a path in a message/warning/error,
118
- // it's more convenient to:
119
- // - make it relative to cwd()
120
- // - convert to posix (ie not using windows \ path separator)
121
- // This way, Jest tests can run more reliably on any computer/CI
122
- // on both Unix/Windows
123
- // For Windows users this is not perfect (as they see / instead of \) but it's probably good enough
124
- function toMessageRelativeFilePath(filePath) {
125
- return exports.posixPath(path_1.default.relative(process.cwd(), filePath));
126
- }
127
- exports.toMessageRelativeFilePath = toMessageRelativeFilePath;
128
- const chunkNameCache = new Map();
129
- /**
130
- * Generate unique chunk name given a module path.
131
- */
132
- function genChunkName(modulePath, prefix, preferredName, shortId = process.env.NODE_ENV === 'production') {
133
- let chunkName = chunkNameCache.get(modulePath);
134
- if (!chunkName) {
135
- if (shortId) {
136
- chunkName = simpleHash(modulePath, 8);
137
- }
138
- else {
139
- let str = modulePath;
140
- if (preferredName) {
141
- const shortHash = simpleHash(modulePath, 3);
142
- str = `${preferredName}${shortHash}`;
143
- }
144
- const name = str === '/' ? 'index' : docuHash(str);
145
- chunkName = prefix ? `${prefix}---${name}` : name;
146
- }
147
- chunkNameCache.set(modulePath, chunkName);
148
- }
149
- return chunkName;
150
- }
151
- exports.genChunkName = genChunkName;
152
- // Too dynamic
153
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
154
- function idx(target, keyPaths) {
155
- return (target &&
156
- keyPaths &&
157
- (Array.isArray(keyPaths)
158
- ? keyPaths.reduce((obj, key) => obj && obj[key], target)
159
- : target[keyPaths]));
160
- }
161
- exports.idx = idx;
162
- /**
163
- * Given a filepath and dirpath, get the first directory.
164
- */
165
- function getSubFolder(file, refDir) {
166
- const separator = escape_string_regexp_1.default(path_1.default.sep);
167
- const baseDir = escape_string_regexp_1.default(path_1.default.basename(refDir));
168
- const regexSubFolder = new RegExp(`${baseDir}${separator}(.*?)${separator}.*`);
169
- const match = regexSubFolder.exec(file);
170
- return match && match[1];
171
- }
172
- exports.getSubFolder = getSubFolder;
173
- function normalizeUrl(rawUrls) {
174
- const urls = [...rawUrls];
175
- const resultArray = [];
176
- let hasStartingSlash = false;
177
- let hasEndingSlash = false;
178
- // If the first part is a plain protocol, we combine it with the next part.
179
- if (urls[0].match(/^[^/:]+:\/*$/) && urls.length > 1) {
180
- const first = urls.shift();
181
- urls[0] = first + urls[0];
182
- }
183
- // There must be two or three slashes in the file protocol,
184
- // two slashes in anything else.
185
- const replacement = urls[0].match(/^file:\/\/\//) ? '$1:///' : '$1://';
186
- urls[0] = urls[0].replace(/^([^/:]+):\/*/, replacement);
187
- // eslint-disable-next-line
188
- for (let i = 0; i < urls.length; i++) {
189
- let component = urls[i];
190
- if (typeof component !== 'string') {
191
- throw new TypeError(`Url must be a string. Received ${typeof component}`);
192
- }
193
- if (component === '') {
194
- if (i === urls.length - 1 && hasEndingSlash) {
195
- resultArray.push('/');
196
- }
197
- // eslint-disable-next-line
198
- continue;
199
- }
200
- if (component !== '/') {
201
- if (i > 0) {
202
- // Removing the starting slashes for each component but the first.
203
- component = component.replace(/^[/]+/,
204
- // Special case where the first element of rawUrls is empty ["", "/hello"] => /hello
205
- component[0] === '/' && !hasStartingSlash ? '/' : '');
206
- }
207
- hasEndingSlash = component[component.length - 1] === '/';
208
- // Removing the ending slashes for each component but the last.
209
- // For the last component we will combine multiple slashes to a single one.
210
- component = component.replace(/[/]+$/, i < urls.length - 1 ? '' : '/');
211
- }
212
- hasStartingSlash = true;
213
- resultArray.push(component);
214
- }
215
- let str = resultArray.join('/');
216
- // Each input component is now separated by a single slash
217
- // except the possible first plain protocol part.
218
- // Remove trailing slash before parameters or hash.
219
- str = str.replace(/\/(\?|&|#[^!])/g, '$1');
220
- // Replace ? in parameters with &.
221
- const parts = str.split('?');
222
- str = parts.shift() + (parts.length > 0 ? '?' : '') + parts.join('&');
223
- // Dedupe forward slashes in the entire path, avoiding protocol slashes.
224
- str = str.replace(/([^:]\/)\/+/g, '$1');
225
- // Dedupe forward slashes at the beginning of the path.
226
- str = str.replace(/^\/+/g, '/');
227
- return str;
228
- }
229
- exports.normalizeUrl = normalizeUrl;
230
- /**
231
- * Alias filepath relative to site directory, very useful so that we
232
- * don't expose user's site structure.
233
- * Example: some/path/to/website/docs/foo.md -> @site/docs/foo.md
234
- */
235
- function aliasedSitePath(filePath, siteDir) {
236
- const relativePath = exports.posixPath(path_1.default.relative(siteDir, filePath));
237
- // Cannot use path.join() as it resolves '../' and removes
238
- // the '@site'. Let webpack loader resolve it.
239
- return `@site/${relativePath}`;
240
- }
241
- exports.aliasedSitePath = aliasedSitePath;
242
- function getEditUrl(fileRelativePath, editUrl) {
243
- return editUrl
244
- ? normalizeUrl([editUrl, exports.posixPath(fileRelativePath)])
245
- : undefined;
246
- }
247
- exports.getEditUrl = getEditUrl;
248
- function isValidPathname(str) {
249
- if (!str.startsWith('/')) {
250
- return false;
251
- }
252
- try {
253
- // weird, but is there a better way?
254
- const parsedPathname = new url_1.URL(str, 'https://domain.com').pathname;
255
- return parsedPathname === str || parsedPathname === encodeURI(str);
256
- }
257
- catch (e) {
258
- return false;
259
- }
260
- }
261
- exports.isValidPathname = isValidPathname;
262
- // resolve pathname and fail fast if resolution fails
263
- function resolvePathname(to, from) {
264
- return resolve_pathname_1.default(to, from);
265
- }
266
- exports.resolvePathname = resolvePathname;
267
- function addLeadingSlash(str) {
268
- return str.startsWith('/') ? str : `/${str}`;
269
- }
270
- exports.addLeadingSlash = addLeadingSlash;
271
- function addTrailingSlash(str) {
272
- return str.endsWith('/') ? str : `${str}/`;
273
- }
274
- exports.addTrailingSlash = addTrailingSlash;
275
- function addTrailingPathSeparator(str) {
276
- return str.endsWith(path_1.default.sep) ? str : `${str}${path_1.default.sep}`;
277
- }
278
- exports.addTrailingPathSeparator = addTrailingPathSeparator;
279
- function removeTrailingSlash(str) {
280
- return removeSuffix(str, '/');
281
- }
282
- exports.removeTrailingSlash = removeTrailingSlash;
283
- function removeSuffix(str, suffix) {
284
- if (suffix === '') {
285
- return str; // always returns "" otherwise!
286
- }
287
- return str.endsWith(suffix) ? str.slice(0, -suffix.length) : str;
288
- }
289
- exports.removeSuffix = removeSuffix;
290
- function removePrefix(str, prefix) {
291
- return str.startsWith(prefix) ? str.slice(prefix.length) : str;
292
- }
293
- exports.removePrefix = removePrefix;
294
- function getFilePathForRoutePath(routePath) {
295
- const fileName = path_1.default.basename(routePath);
296
- const filePath = path_1.default.dirname(routePath);
297
- return path_1.default.join(filePath, `${fileName}/index.html`);
298
- }
299
- exports.getFilePathForRoutePath = getFilePathForRoutePath;
300
- function getElementsAround(array, aroundIndex) {
301
- const min = 0;
302
- const max = array.length - 1;
303
- if (aroundIndex < min || aroundIndex > max) {
304
- throw new Error(`Valid aroundIndex for array (of size ${array.length}) are between ${min} and ${max}, but you provided aroundIndex=${aroundIndex}`);
305
- }
306
- const previous = aroundIndex === min ? undefined : array[aroundIndex - 1];
307
- const next = aroundIndex === max ? undefined : array[aroundIndex + 1];
308
- return { previous, next };
309
- }
310
- exports.getElementsAround = getElementsAround;
311
- function getPluginI18nPath({ siteDir, locale, pluginName, pluginId = 'default', // TODO duplicated constant
312
- subPaths = [], }) {
313
- return path_1.default.join(siteDir, 'i18n',
314
- // namespace first by locale: convenient to work in a single folder for a translator
315
- locale,
316
- // Make it convenient to use for single-instance
317
- // ie: return "docs", not "docs-default" nor "docs/default"
318
- `${pluginName}${
319
- // TODO duplicate constant :(
320
- pluginId === 'default' ? '' : `-${pluginId}`}`, ...subPaths);
321
- }
322
- exports.getPluginI18nPath = getPluginI18nPath;
323
- async function mapAsyncSequencial(array, action) {
324
- const results = [];
325
- // eslint-disable-next-line no-restricted-syntax
326
- for (const t of array) {
327
- // eslint-disable-next-line no-await-in-loop
328
- const result = await action(t);
329
- results.push(result);
330
- }
331
- return results;
332
- }
333
- exports.mapAsyncSequencial = mapAsyncSequencial;
334
- async function findAsyncSequential(array, predicate) {
335
- // eslint-disable-next-line no-restricted-syntax
336
- for (const t of array) {
337
- // eslint-disable-next-line no-await-in-loop
338
- if (await predicate(t)) {
339
- return t;
340
- }
341
- }
342
- return undefined;
343
- }
344
- exports.findAsyncSequential = findAsyncSequential;
345
- // return the first folder path in which the file exists in
346
- async function findFolderContainingFile(folderPaths, relativeFilePath) {
347
- return findAsyncSequential(folderPaths, (folderPath) => fs_extra_1.default.pathExists(path_1.default.join(folderPath, relativeFilePath)));
348
- }
349
- exports.findFolderContainingFile = findFolderContainingFile;
350
- async function getFolderContainingFile(folderPaths, relativeFilePath) {
351
- const maybeFolderPath = await findFolderContainingFile(folderPaths, relativeFilePath);
352
- // should never happen, as the source was read from the FS anyway...
353
- if (!maybeFolderPath) {
354
- throw new Error(`relativeFilePath=[${relativeFilePath}] does not exist in any of these folders: \n- ${folderPaths.join('\n- ')}]`);
355
- }
356
- return maybeFolderPath;
357
- }
358
- exports.getFolderContainingFile = getFolderContainingFile;
359
- function reportMessage(message, reportingSeverity) {
360
- switch (reportingSeverity) {
361
- case 'ignore':
362
- break;
363
- case 'log':
364
- console.log(chalk_1.default.bold.blue('info ') + chalk_1.default.blue(message));
365
- break;
366
- case 'warn':
367
- console.warn(chalk_1.default.bold.yellow('warn ') + chalk_1.default.yellow(message));
368
- break;
369
- case 'error':
370
- console.error(chalk_1.default.bold.red('error ') + chalk_1.default.red(message));
371
- break;
372
- case 'throw':
373
- throw new Error(message);
374
- default:
375
- throw new Error(`unexpected reportingSeverity value: ${reportingSeverity}`);
376
- }
377
- }
378
- exports.reportMessage = reportMessage;
379
- function mergeTranslations(contents) {
380
- return contents.reduce((acc, content) => {
381
- return { ...acc, ...content };
382
- }, {});
383
- }
384
- exports.mergeTranslations = mergeTranslations;
385
- function getSwizzledComponent(componentPath) {
386
- const swizzledComponentPath = path_1.default.resolve(process.cwd(), 'src', componentPath);
387
- return fs_extra_1.default.existsSync(swizzledComponentPath)
388
- ? swizzledComponentPath
389
- : undefined;
390
- }
391
- exports.getSwizzledComponent = getSwizzledComponent;
392
- // Useful to update all the messages of a translation file
393
- // Used in tests to simulate translations
394
- function updateTranslationFileMessages(translationFile, updateMessage) {
395
- return {
396
- ...translationFile,
397
- content: lodash_1.mapValues(translationFile.content, (translation) => ({
398
- ...translation,
399
- message: updateMessage(translation.message),
400
- })),
401
- };
402
- }
403
- exports.updateTranslationFileMessages = updateTranslationFileMessages;
404
- // Input: ## Some heading {#some-heading}
405
- // Output: {text: "## Some heading", id: "some-heading"}
406
- function parseMarkdownHeadingId(heading) {
407
- const customHeadingIdRegex = /^(.*?)\s*\{#([\w-]+)\}$/;
408
- const matches = customHeadingIdRegex.exec(heading);
409
- if (matches) {
410
- return {
411
- text: matches[1],
412
- id: matches[2],
413
- };
414
- }
415
- else {
416
- return { text: heading, id: undefined };
417
- }
418
- }
419
- exports.parseMarkdownHeadingId = parseMarkdownHeadingId;
9
+ exports.replaceMarkdownLinks = exports.writeMarkdownHeadingId = exports.parseMarkdownString = exports.parseMarkdownContentTitle = exports.parseFrontMatter = exports.createExcerpt = exports.parseMarkdownHeadingId = exports.groupTaggedItems = exports.normalizeFrontMatterTags = exports.buildSshUrl = exports.buildHttpsUrl = exports.hasSSHProtocol = exports.removeTrailingSlash = exports.addTrailingSlash = exports.addLeadingSlash = exports.resolvePathname = exports.isValidPathname = exports.encodePath = exports.fileToPath = exports.getEditUrl = exports.normalizeUrl = exports.findAsyncSequential = exports.mapAsyncSequential = exports.removePrefix = exports.removeSuffix = exports.localizePath = exports.getPluginI18nPath = exports.updateTranslationFileMessages = exports.mergeTranslations = exports.GitNotFoundError = exports.FileNotTrackedError = exports.getFileCommitDate = exports.readOutputHTMLFile = exports.generate = exports.WEBPACK_URL_LOADER_LIMIT = exports.DEFAULT_PLUGIN_ID = exports.DEFAULT_PORT = exports.CODE_TRANSLATIONS_FILE_NAME = exports.DEFAULT_I18N_DIR_NAME = exports.THEME_PATH = exports.OUTPUT_STATIC_ASSETS_DIR_NAME = exports.DEFAULT_STATIC_DIR_NAME = exports.SRC_DIR_NAME = exports.GENERATED_FILES_DIR_NAME = exports.BABEL_CONFIG_FILE_NAME = exports.DEFAULT_CONFIG_FILE_NAME = exports.DEFAULT_BUILD_DIR_NAME = exports.DOCUSAURUS_VERSION = exports.NODE_MINOR_VERSION = exports.NODE_MAJOR_VERSION = void 0;
10
+ exports.getFolderContainingFile = exports.findFolderContainingFile = exports.getContentPathList = exports.getDataFileData = exports.getDataFilePath = exports.escapeShellArg = exports.getFileLoaderUtils = exports.createAbsoluteFilePathMatcher = exports.createMatcher = exports.GlobExcludeDefault = exports.Globby = exports.docuHash = exports.simpleHash = exports.md5Hash = exports.addTrailingPathSeparator = exports.escapePath = exports.aliasedSitePath = exports.toMessageRelativeFilePath = exports.posixPath = exports.shortName = exports.isNameTooLong = exports.createSlugger = void 0;
11
+ var constants_1 = require("./constants");
12
+ Object.defineProperty(exports, "NODE_MAJOR_VERSION", { enumerable: true, get: function () { return constants_1.NODE_MAJOR_VERSION; } });
13
+ Object.defineProperty(exports, "NODE_MINOR_VERSION", { enumerable: true, get: function () { return constants_1.NODE_MINOR_VERSION; } });
14
+ Object.defineProperty(exports, "DOCUSAURUS_VERSION", { enumerable: true, get: function () { return constants_1.DOCUSAURUS_VERSION; } });
15
+ Object.defineProperty(exports, "DEFAULT_BUILD_DIR_NAME", { enumerable: true, get: function () { return constants_1.DEFAULT_BUILD_DIR_NAME; } });
16
+ Object.defineProperty(exports, "DEFAULT_CONFIG_FILE_NAME", { enumerable: true, get: function () { return constants_1.DEFAULT_CONFIG_FILE_NAME; } });
17
+ Object.defineProperty(exports, "BABEL_CONFIG_FILE_NAME", { enumerable: true, get: function () { return constants_1.BABEL_CONFIG_FILE_NAME; } });
18
+ Object.defineProperty(exports, "GENERATED_FILES_DIR_NAME", { enumerable: true, get: function () { return constants_1.GENERATED_FILES_DIR_NAME; } });
19
+ Object.defineProperty(exports, "SRC_DIR_NAME", { enumerable: true, get: function () { return constants_1.SRC_DIR_NAME; } });
20
+ Object.defineProperty(exports, "DEFAULT_STATIC_DIR_NAME", { enumerable: true, get: function () { return constants_1.DEFAULT_STATIC_DIR_NAME; } });
21
+ Object.defineProperty(exports, "OUTPUT_STATIC_ASSETS_DIR_NAME", { enumerable: true, get: function () { return constants_1.OUTPUT_STATIC_ASSETS_DIR_NAME; } });
22
+ Object.defineProperty(exports, "THEME_PATH", { enumerable: true, get: function () { return constants_1.THEME_PATH; } });
23
+ Object.defineProperty(exports, "DEFAULT_I18N_DIR_NAME", { enumerable: true, get: function () { return constants_1.DEFAULT_I18N_DIR_NAME; } });
24
+ Object.defineProperty(exports, "CODE_TRANSLATIONS_FILE_NAME", { enumerable: true, get: function () { return constants_1.CODE_TRANSLATIONS_FILE_NAME; } });
25
+ Object.defineProperty(exports, "DEFAULT_PORT", { enumerable: true, get: function () { return constants_1.DEFAULT_PORT; } });
26
+ Object.defineProperty(exports, "DEFAULT_PLUGIN_ID", { enumerable: true, get: function () { return constants_1.DEFAULT_PLUGIN_ID; } });
27
+ Object.defineProperty(exports, "WEBPACK_URL_LOADER_LIMIT", { enumerable: true, get: function () { return constants_1.WEBPACK_URL_LOADER_LIMIT; } });
28
+ var emitUtils_1 = require("./emitUtils");
29
+ Object.defineProperty(exports, "generate", { enumerable: true, get: function () { return emitUtils_1.generate; } });
30
+ Object.defineProperty(exports, "readOutputHTMLFile", { enumerable: true, get: function () { return emitUtils_1.readOutputHTMLFile; } });
31
+ var gitUtils_1 = require("./gitUtils");
32
+ Object.defineProperty(exports, "getFileCommitDate", { enumerable: true, get: function () { return gitUtils_1.getFileCommitDate; } });
33
+ Object.defineProperty(exports, "FileNotTrackedError", { enumerable: true, get: function () { return gitUtils_1.FileNotTrackedError; } });
34
+ Object.defineProperty(exports, "GitNotFoundError", { enumerable: true, get: function () { return gitUtils_1.GitNotFoundError; } });
35
+ var i18nUtils_1 = require("./i18nUtils");
36
+ Object.defineProperty(exports, "mergeTranslations", { enumerable: true, get: function () { return i18nUtils_1.mergeTranslations; } });
37
+ Object.defineProperty(exports, "updateTranslationFileMessages", { enumerable: true, get: function () { return i18nUtils_1.updateTranslationFileMessages; } });
38
+ Object.defineProperty(exports, "getPluginI18nPath", { enumerable: true, get: function () { return i18nUtils_1.getPluginI18nPath; } });
39
+ Object.defineProperty(exports, "localizePath", { enumerable: true, get: function () { return i18nUtils_1.localizePath; } });
40
+ var jsUtils_1 = require("./jsUtils");
41
+ Object.defineProperty(exports, "removeSuffix", { enumerable: true, get: function () { return jsUtils_1.removeSuffix; } });
42
+ Object.defineProperty(exports, "removePrefix", { enumerable: true, get: function () { return jsUtils_1.removePrefix; } });
43
+ Object.defineProperty(exports, "mapAsyncSequential", { enumerable: true, get: function () { return jsUtils_1.mapAsyncSequential; } });
44
+ Object.defineProperty(exports, "findAsyncSequential", { enumerable: true, get: function () { return jsUtils_1.findAsyncSequential; } });
45
+ var urlUtils_1 = require("./urlUtils");
46
+ Object.defineProperty(exports, "normalizeUrl", { enumerable: true, get: function () { return urlUtils_1.normalizeUrl; } });
47
+ Object.defineProperty(exports, "getEditUrl", { enumerable: true, get: function () { return urlUtils_1.getEditUrl; } });
48
+ Object.defineProperty(exports, "fileToPath", { enumerable: true, get: function () { return urlUtils_1.fileToPath; } });
49
+ Object.defineProperty(exports, "encodePath", { enumerable: true, get: function () { return urlUtils_1.encodePath; } });
50
+ Object.defineProperty(exports, "isValidPathname", { enumerable: true, get: function () { return urlUtils_1.isValidPathname; } });
51
+ Object.defineProperty(exports, "resolvePathname", { enumerable: true, get: function () { return urlUtils_1.resolvePathname; } });
52
+ Object.defineProperty(exports, "addLeadingSlash", { enumerable: true, get: function () { return urlUtils_1.addLeadingSlash; } });
53
+ Object.defineProperty(exports, "addTrailingSlash", { enumerable: true, get: function () { return urlUtils_1.addTrailingSlash; } });
54
+ Object.defineProperty(exports, "removeTrailingSlash", { enumerable: true, get: function () { return urlUtils_1.removeTrailingSlash; } });
55
+ Object.defineProperty(exports, "hasSSHProtocol", { enumerable: true, get: function () { return urlUtils_1.hasSSHProtocol; } });
56
+ Object.defineProperty(exports, "buildHttpsUrl", { enumerable: true, get: function () { return urlUtils_1.buildHttpsUrl; } });
57
+ Object.defineProperty(exports, "buildSshUrl", { enumerable: true, get: function () { return urlUtils_1.buildSshUrl; } });
58
+ var tags_1 = require("./tags");
59
+ Object.defineProperty(exports, "normalizeFrontMatterTags", { enumerable: true, get: function () { return tags_1.normalizeFrontMatterTags; } });
60
+ Object.defineProperty(exports, "groupTaggedItems", { enumerable: true, get: function () { return tags_1.groupTaggedItems; } });
61
+ var markdownUtils_1 = require("./markdownUtils");
62
+ Object.defineProperty(exports, "parseMarkdownHeadingId", { enumerable: true, get: function () { return markdownUtils_1.parseMarkdownHeadingId; } });
63
+ Object.defineProperty(exports, "createExcerpt", { enumerable: true, get: function () { return markdownUtils_1.createExcerpt; } });
64
+ Object.defineProperty(exports, "parseFrontMatter", { enumerable: true, get: function () { return markdownUtils_1.parseFrontMatter; } });
65
+ Object.defineProperty(exports, "parseMarkdownContentTitle", { enumerable: true, get: function () { return markdownUtils_1.parseMarkdownContentTitle; } });
66
+ Object.defineProperty(exports, "parseMarkdownString", { enumerable: true, get: function () { return markdownUtils_1.parseMarkdownString; } });
67
+ Object.defineProperty(exports, "writeMarkdownHeadingId", { enumerable: true, get: function () { return markdownUtils_1.writeMarkdownHeadingId; } });
68
+ var markdownLinks_1 = require("./markdownLinks");
69
+ Object.defineProperty(exports, "replaceMarkdownLinks", { enumerable: true, get: function () { return markdownLinks_1.replaceMarkdownLinks; } });
70
+ var slugger_1 = require("./slugger");
71
+ Object.defineProperty(exports, "createSlugger", { enumerable: true, get: function () { return slugger_1.createSlugger; } });
72
+ var pathUtils_1 = require("./pathUtils");
73
+ Object.defineProperty(exports, "isNameTooLong", { enumerable: true, get: function () { return pathUtils_1.isNameTooLong; } });
74
+ Object.defineProperty(exports, "shortName", { enumerable: true, get: function () { return pathUtils_1.shortName; } });
75
+ Object.defineProperty(exports, "posixPath", { enumerable: true, get: function () { return pathUtils_1.posixPath; } });
76
+ Object.defineProperty(exports, "toMessageRelativeFilePath", { enumerable: true, get: function () { return pathUtils_1.toMessageRelativeFilePath; } });
77
+ Object.defineProperty(exports, "aliasedSitePath", { enumerable: true, get: function () { return pathUtils_1.aliasedSitePath; } });
78
+ Object.defineProperty(exports, "escapePath", { enumerable: true, get: function () { return pathUtils_1.escapePath; } });
79
+ Object.defineProperty(exports, "addTrailingPathSeparator", { enumerable: true, get: function () { return pathUtils_1.addTrailingPathSeparator; } });
80
+ var hashUtils_1 = require("./hashUtils");
81
+ Object.defineProperty(exports, "md5Hash", { enumerable: true, get: function () { return hashUtils_1.md5Hash; } });
82
+ Object.defineProperty(exports, "simpleHash", { enumerable: true, get: function () { return hashUtils_1.simpleHash; } });
83
+ Object.defineProperty(exports, "docuHash", { enumerable: true, get: function () { return hashUtils_1.docuHash; } });
84
+ var globUtils_1 = require("./globUtils");
85
+ Object.defineProperty(exports, "Globby", { enumerable: true, get: function () { return globUtils_1.Globby; } });
86
+ Object.defineProperty(exports, "GlobExcludeDefault", { enumerable: true, get: function () { return globUtils_1.GlobExcludeDefault; } });
87
+ Object.defineProperty(exports, "createMatcher", { enumerable: true, get: function () { return globUtils_1.createMatcher; } });
88
+ Object.defineProperty(exports, "createAbsoluteFilePathMatcher", { enumerable: true, get: function () { return globUtils_1.createAbsoluteFilePathMatcher; } });
89
+ var webpackUtils_1 = require("./webpackUtils");
90
+ Object.defineProperty(exports, "getFileLoaderUtils", { enumerable: true, get: function () { return webpackUtils_1.getFileLoaderUtils; } });
91
+ var shellUtils_1 = require("./shellUtils");
92
+ Object.defineProperty(exports, "escapeShellArg", { enumerable: true, get: function () { return shellUtils_1.escapeShellArg; } });
93
+ var dataFileUtils_1 = require("./dataFileUtils");
94
+ Object.defineProperty(exports, "getDataFilePath", { enumerable: true, get: function () { return dataFileUtils_1.getDataFilePath; } });
95
+ Object.defineProperty(exports, "getDataFileData", { enumerable: true, get: function () { return dataFileUtils_1.getDataFileData; } });
96
+ Object.defineProperty(exports, "getContentPathList", { enumerable: true, get: function () { return dataFileUtils_1.getContentPathList; } });
97
+ Object.defineProperty(exports, "findFolderContainingFile", { enumerable: true, get: function () { return dataFileUtils_1.findFolderContainingFile; } });
98
+ Object.defineProperty(exports, "getFolderContainingFile", { enumerable: true, get: function () { return dataFileUtils_1.getFolderContainingFile; } });
99
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;AAEH,yCAiBqB;AAhBnB,+GAAA,kBAAkB,OAAA;AAClB,+GAAA,kBAAkB,OAAA;AAClB,+GAAA,kBAAkB,OAAA;AAClB,mHAAA,sBAAsB,OAAA;AACtB,qHAAA,wBAAwB,OAAA;AACxB,mHAAA,sBAAsB,OAAA;AACtB,qHAAA,wBAAwB,OAAA;AACxB,yGAAA,YAAY,OAAA;AACZ,oHAAA,uBAAuB,OAAA;AACvB,0HAAA,6BAA6B,OAAA;AAC7B,uGAAA,UAAU,OAAA;AACV,kHAAA,qBAAqB,OAAA;AACrB,wHAAA,2BAA2B,OAAA;AAC3B,yGAAA,YAAY,OAAA;AACZ,8GAAA,iBAAiB,OAAA;AACjB,qHAAA,wBAAwB,OAAA;AAE1B,yCAAyD;AAAjD,qGAAA,QAAQ,OAAA;AAAE,+GAAA,kBAAkB,OAAA;AACpC,uCAIoB;AAHlB,6GAAA,iBAAiB,OAAA;AACjB,+GAAA,mBAAmB,OAAA;AACnB,4GAAA,gBAAgB,OAAA;AAElB,yCAKqB;AAJnB,8GAAA,iBAAiB,OAAA;AACjB,0HAAA,6BAA6B,OAAA;AAC7B,8GAAA,iBAAiB,OAAA;AACjB,yGAAA,YAAY,OAAA;AAEd,qCAKmB;AAJjB,uGAAA,YAAY,OAAA;AACZ,uGAAA,YAAY,OAAA;AACZ,6GAAA,kBAAkB,OAAA;AAClB,8GAAA,mBAAmB,OAAA;AAErB,uCAaoB;AAZlB,wGAAA,YAAY,OAAA;AACZ,sGAAA,UAAU,OAAA;AACV,sGAAA,UAAU,OAAA;AACV,sGAAA,UAAU,OAAA;AACV,2GAAA,eAAe,OAAA;AACf,2GAAA,eAAe,OAAA;AACf,2GAAA,eAAe,OAAA;AACf,4GAAA,gBAAgB,OAAA;AAChB,+GAAA,mBAAmB,OAAA;AACnB,0GAAA,cAAc,OAAA;AACd,yGAAA,aAAa,OAAA;AACb,uGAAA,WAAW,OAAA;AAEb,+BAOgB;AAFd,gHAAA,wBAAwB,OAAA;AACxB,wGAAA,gBAAgB,OAAA;AAElB,iDAQyB;AAPvB,uHAAA,sBAAsB,OAAA;AACtB,8GAAA,aAAa,OAAA;AACb,iHAAA,gBAAgB,OAAA;AAChB,0HAAA,yBAAyB,OAAA;AACzB,oHAAA,mBAAmB,OAAA;AACnB,uHAAA,sBAAsB,OAAA;AAGxB,iDAIyB;AADvB,qHAAA,oBAAoB,OAAA;AAEtB,qCAA2E;AAAhC,wGAAA,aAAa,OAAA;AACxD,yCAQqB;AAPnB,0GAAA,aAAa,OAAA;AACb,sGAAA,SAAS,OAAA;AACT,sGAAA,SAAS,OAAA;AACT,sHAAA,yBAAyB,OAAA;AACzB,4GAAA,eAAe,OAAA;AACf,uGAAA,UAAU,OAAA;AACV,qHAAA,wBAAwB,OAAA;AAE1B,yCAA0D;AAAlD,oGAAA,OAAO,OAAA;AAAE,uGAAA,UAAU,OAAA;AAAE,qGAAA,QAAQ,OAAA;AACrC,yCAKqB;AAJnB,mGAAA,MAAM,OAAA;AACN,+GAAA,kBAAkB,OAAA;AAClB,0GAAA,aAAa,OAAA;AACb,0HAAA,6BAA6B,OAAA;AAE/B,+CAAkD;AAA1C,kHAAA,kBAAkB,OAAA;AAC1B,2CAA4C;AAApC,4GAAA,cAAc,OAAA;AACtB,iDAMyB;AALvB,gHAAA,eAAe,OAAA;AACf,gHAAA,eAAe,OAAA;AACf,mHAAA,kBAAkB,OAAA;AAClB,yHAAA,wBAAwB,OAAA;AACxB,wHAAA,uBAAuB,OAAA"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ /** Removes a given string suffix from `str`. */
8
+ export declare function removeSuffix(str: string, suffix: string): string;
9
+ /** Removes a given string prefix from `str`. */
10
+ export declare function removePrefix(str: string, prefix: string): string;
11
+ /**
12
+ * `Array#map` for async operations where order matters.
13
+ * @param array The array to traverse.
14
+ * @param action An async action to be performed on every array item. Will be
15
+ * awaited before working on the next.
16
+ * @returns The list of results returned from every `action(item)`
17
+ */
18
+ export declare function mapAsyncSequential<T, R>(array: T[], action: (t: T) => Promise<R>): Promise<R[]>;
19
+ /**
20
+ * `Array#find` for async operations where order matters.
21
+ * @param array The array to traverse.
22
+ * @param predicate An async predicate to be called on every array item. Should
23
+ * return a boolean indicating whether the currently element should be returned.
24
+ * @returns The function immediately returns the first item on which `predicate`
25
+ * returns `true`, or `undefined` if none matches the predicate.
26
+ */
27
+ export declare function findAsyncSequential<T>(array: T[], predicate: (t: T) => Promise<boolean>): Promise<T | undefined>;
28
+ //# sourceMappingURL=jsUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsUtils.d.ts","sourceRoot":"","sources":["../src/jsUtils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,gDAAgD;AAChD,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAMhE;AAED,gDAAgD;AAChD,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAEhE;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CAAC,CAAC,EAAE,CAAC,EAC3C,KAAK,EAAE,CAAC,EAAE,EACV,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,GAC3B,OAAO,CAAC,CAAC,EAAE,CAAC,CAOd;AAED;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CAAC,CAAC,EACzC,KAAK,EAAE,CAAC,EAAE,EACV,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,GACpC,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAOxB"}
package/lib/jsUtils.js ADDED
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) Facebook, Inc. and its affiliates.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.findAsyncSequential = exports.mapAsyncSequential = exports.removePrefix = exports.removeSuffix = void 0;
10
+ /** Removes a given string suffix from `str`. */
11
+ function removeSuffix(str, suffix) {
12
+ if (suffix === '') {
13
+ // str.slice(0, 0) is ""
14
+ return str;
15
+ }
16
+ return str.endsWith(suffix) ? str.slice(0, -suffix.length) : str;
17
+ }
18
+ exports.removeSuffix = removeSuffix;
19
+ /** Removes a given string prefix from `str`. */
20
+ function removePrefix(str, prefix) {
21
+ return str.startsWith(prefix) ? str.slice(prefix.length) : str;
22
+ }
23
+ exports.removePrefix = removePrefix;
24
+ /**
25
+ * `Array#map` for async operations where order matters.
26
+ * @param array The array to traverse.
27
+ * @param action An async action to be performed on every array item. Will be
28
+ * awaited before working on the next.
29
+ * @returns The list of results returned from every `action(item)`
30
+ */
31
+ async function mapAsyncSequential(array, action) {
32
+ const results = [];
33
+ for (const t of array) {
34
+ const result = await action(t);
35
+ results.push(result);
36
+ }
37
+ return results;
38
+ }
39
+ exports.mapAsyncSequential = mapAsyncSequential;
40
+ /**
41
+ * `Array#find` for async operations where order matters.
42
+ * @param array The array to traverse.
43
+ * @param predicate An async predicate to be called on every array item. Should
44
+ * return a boolean indicating whether the currently element should be returned.
45
+ * @returns The function immediately returns the first item on which `predicate`
46
+ * returns `true`, or `undefined` if none matches the predicate.
47
+ */
48
+ async function findAsyncSequential(array, predicate) {
49
+ for (const t of array) {
50
+ if (await predicate(t)) {
51
+ return t;
52
+ }
53
+ }
54
+ return undefined;
55
+ }
56
+ exports.findAsyncSequential = findAsyncSequential;
57
+ //# sourceMappingURL=jsUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsUtils.js","sourceRoot":"","sources":["../src/jsUtils.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,gDAAgD;AAChD,SAAgB,YAAY,CAAC,GAAW,EAAE,MAAc;IACtD,IAAI,MAAM,KAAK,EAAE,EAAE;QACjB,wBAAwB;QACxB,OAAO,GAAG,CAAC;KACZ;IACD,OAAO,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;AACnE,CAAC;AAND,oCAMC;AAED,gDAAgD;AAChD,SAAgB,YAAY,CAAC,GAAW,EAAE,MAAc;IACtD,OAAO,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;AACjE,CAAC;AAFD,oCAEC;AAED;;;;;;GAMG;AACI,KAAK,UAAU,kBAAkB,CACtC,KAAU,EACV,MAA4B;IAE5B,MAAM,OAAO,GAAQ,EAAE,CAAC;IACxB,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE;QACrB,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,CAAC,CAAC,CAAC;QAC/B,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;KACtB;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAVD,gDAUC;AAED;;;;;;;GAOG;AACI,KAAK,UAAU,mBAAmB,CACvC,KAAU,EACV,SAAqC;IAErC,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE;QACrB,IAAI,MAAM,SAAS,CAAC,CAAC,CAAC,EAAE;YACtB,OAAO,CAAC,CAAC;SACV;KACF;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAVD,kDAUC"}