intor 2.3.18 → 2.3.20

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.
@@ -20,7 +20,7 @@ import { getLogger } from '../../../../../core/logger/get-logger.js';
20
20
  * }, ... ];
21
21
  * ```
22
22
  */
23
- async function collectFileEntries({ readdir = fs.readdir, namespaces, rootDir, limit, exts = ["json"], loggerOptions, }) {
23
+ async function collectFileEntries({ readdir = fs.readdir, namespaces, rootDir, limit, exts = [], loggerOptions, }) {
24
24
  const baseLogger = getLogger(loggerOptions);
25
25
  const logger = baseLogger.child({ scope: "collect-file-entries" });
26
26
  const supportedExts = new Set(["json", ...exts]);
@@ -41,22 +41,23 @@ async function collectFileEntries({ readdir = fs.readdir, namespaces, rootDir, l
41
41
  return;
42
42
  }
43
43
  // -------------------------------------------------------------------------
44
- // Process entries (files & sub-directories)
44
+ // 1. Recurse into sub-directories (control flow, no limit)
45
45
  // -------------------------------------------------------------------------
46
- const tasks = entries.map((entry) => limit(async () => {
46
+ for (const entry of entries) {
47
+ if (!entry.isDirectory())
48
+ continue;
49
+ await walk(path.join(currentDir, entry.name));
50
+ }
51
+ // -------------------------------------------------------------------------
52
+ // 2. Process files (IO-bound, concurrency-limited)
53
+ // -------------------------------------------------------------------------
54
+ const tasks = entries
55
+ .filter((entry) => entry.isFile())
56
+ .map((entry) => limit(async () => {
47
57
  const fullPath = path.join(currentDir, entry.name);
48
- // Recurse into sub-directories
49
- if (entry.isDirectory()) {
50
- await walk(fullPath);
51
- return;
52
- }
53
- // Skip unsupported file extensions
54
- const ext = path.extname(entry.name).slice(1); // "json", "yaml"
58
+ const ext = path.extname(entry.name).slice(1);
55
59
  if (!ext || !supportedExts.has(ext))
56
60
  return;
57
- // ---------------------------------------------------------------------
58
- // Resolve file entry
59
- // ---------------------------------------------------------------------
60
61
  const relativePath = path.relative(rootDir, fullPath);
61
62
  const withoutExt = relativePath.slice(0, relativePath.length - (ext.length + 1));
62
63
  const segments = withoutExt.split(path.sep).filter(Boolean);
@@ -20,7 +20,7 @@ import { getLogger } from '../../../../../core/logger/get-logger.js';
20
20
  * }, ... ];
21
21
  * ```
22
22
  */
23
- async function collectFileEntries({ readdir = fs.readdir, namespaces, rootDir, limit, exts = ["json"], loggerOptions, }) {
23
+ async function collectFileEntries({ readdir = fs.readdir, namespaces, rootDir, limit, exts = [], loggerOptions, }) {
24
24
  const baseLogger = getLogger(loggerOptions);
25
25
  const logger = baseLogger.child({ scope: "collect-file-entries" });
26
26
  const supportedExts = new Set(["json", ...exts]);
@@ -41,22 +41,23 @@ async function collectFileEntries({ readdir = fs.readdir, namespaces, rootDir, l
41
41
  return;
42
42
  }
43
43
  // -------------------------------------------------------------------------
44
- // Process entries (files & sub-directories)
44
+ // 1. Recurse into sub-directories (control flow, no limit)
45
45
  // -------------------------------------------------------------------------
46
- const tasks = entries.map((entry) => limit(async () => {
46
+ for (const entry of entries) {
47
+ if (!entry.isDirectory())
48
+ continue;
49
+ await walk(path.join(currentDir, entry.name));
50
+ }
51
+ // -------------------------------------------------------------------------
52
+ // 2. Process files (IO-bound, concurrency-limited)
53
+ // -------------------------------------------------------------------------
54
+ const tasks = entries
55
+ .filter((entry) => entry.isFile())
56
+ .map((entry) => limit(async () => {
47
57
  const fullPath = path.join(currentDir, entry.name);
48
- // Recurse into sub-directories
49
- if (entry.isDirectory()) {
50
- await walk(fullPath);
51
- return;
52
- }
53
- // Skip unsupported file extensions
54
- const ext = path.extname(entry.name).slice(1); // "json", "yaml"
58
+ const ext = path.extname(entry.name).slice(1);
55
59
  if (!ext || !supportedExts.has(ext))
56
60
  return;
57
- // ---------------------------------------------------------------------
58
- // Resolve file entry
59
- // ---------------------------------------------------------------------
60
61
  const relativePath = path.relative(rootDir, fullPath);
61
62
  const withoutExt = relativePath.slice(0, relativePath.length - (ext.length + 1));
62
63
  const segments = withoutExt.split(path.sep).filter(Boolean);
@@ -20,7 +20,7 @@ import { getLogger } from '../../../../../core/logger/get-logger.js';
20
20
  * }, ... ];
21
21
  * ```
22
22
  */
23
- async function collectFileEntries({ readdir = fs.readdir, namespaces, rootDir, limit, exts = ["json"], loggerOptions, }) {
23
+ async function collectFileEntries({ readdir = fs.readdir, namespaces, rootDir, limit, exts = [], loggerOptions, }) {
24
24
  const baseLogger = getLogger(loggerOptions);
25
25
  const logger = baseLogger.child({ scope: "collect-file-entries" });
26
26
  const supportedExts = new Set(["json", ...exts]);
@@ -41,22 +41,23 @@ async function collectFileEntries({ readdir = fs.readdir, namespaces, rootDir, l
41
41
  return;
42
42
  }
43
43
  // -------------------------------------------------------------------------
44
- // Process entries (files & sub-directories)
44
+ // 1. Recurse into sub-directories (control flow, no limit)
45
45
  // -------------------------------------------------------------------------
46
- const tasks = entries.map((entry) => limit(async () => {
46
+ for (const entry of entries) {
47
+ if (!entry.isDirectory())
48
+ continue;
49
+ await walk(path.join(currentDir, entry.name));
50
+ }
51
+ // -------------------------------------------------------------------------
52
+ // 2. Process files (IO-bound, concurrency-limited)
53
+ // -------------------------------------------------------------------------
54
+ const tasks = entries
55
+ .filter((entry) => entry.isFile())
56
+ .map((entry) => limit(async () => {
47
57
  const fullPath = path.join(currentDir, entry.name);
48
- // Recurse into sub-directories
49
- if (entry.isDirectory()) {
50
- await walk(fullPath);
51
- return;
52
- }
53
- // Skip unsupported file extensions
54
- const ext = path.extname(entry.name).slice(1); // "json", "yaml"
58
+ const ext = path.extname(entry.name).slice(1);
55
59
  if (!ext || !supportedExts.has(ext))
56
60
  return;
57
- // ---------------------------------------------------------------------
58
- // Resolve file entry
59
- // ---------------------------------------------------------------------
60
61
  const relativePath = path.relative(rootDir, fullPath);
61
62
  const withoutExt = relativePath.slice(0, relativePath.length - (ext.length + 1));
62
63
  const segments = withoutExt.split(path.sep).filter(Boolean);
@@ -1,4 +1,4 @@
1
- export { PREFIX_PLACEHOLDER, IntorError, IntorErrorCode, deepMerge, resolveLoaderOptions, clearLoggerPool, clearMessagesPool, mergeMessages, isValidMessages, type MessagesReader, type MessagesReaders, } from "../src/core";
1
+ export { PREFIX_PLACEHOLDER, IntorError, IntorErrorCode, deepMerge, type DeepMergeOverrideEvent, resolveLoaderOptions, clearLoggerPool, clearMessagesPool, mergeMessages, isValidMessages, type MessagesReader, type MessagesReaders, } from "../src/core";
2
2
  export { defineIntorConfig, type IntorRawConfig, type IntorResolvedConfig, } from "../src/config";
3
3
  export { localizePathname } from "../src/routing";
4
4
  export { Translator, type TranslatorPlugin, type TranslateContext, type TranslateHook, type TranslateHandlers, type HandlerContext, type FormatHandler, type LoadingHandler, type MissingHandler, type LocaleMessages, type MessageObject, type MessageValue, tokenize, type Token, } from "intor-translator";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "intor",
3
- "version": "2.3.18",
3
+ "version": "2.3.20",
4
4
  "description": "The i18n library for modern JavaScript",
5
5
  "author": "Yiming Liao",
6
6
  "homepage": "https://github.com/yiming-liao/intor#readme",