@simplysm/core-node 13.0.41 → 13.0.43
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.
- package/README.md +22 -20
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -25,10 +25,10 @@ Provides path conversion, normalization, comparison, and filtering functions.
|
|
|
25
25
|
| `NormPath` | A branded type created by `pathNorm()`. Represents a normalized absolute path. |
|
|
26
26
|
| `pathPosix(...args)` | Converts to POSIX-style path (replaces backslashes with slashes). |
|
|
27
27
|
| `pathNorm(...paths)` | Normalizes paths and returns as `NormPath`. Converts to absolute path and normalizes with platform-specific separators. |
|
|
28
|
-
| `pathIsChildPath(childPath, parentPath)` | Checks if `childPath` is a child path of `parentPath`. Returns `false` for identical paths. |
|
|
28
|
+
| `pathIsChildPath(childPath, parentPath)` | Checks if `childPath` is a child path of `parentPath`. Returns `false` for identical paths. Paths are normalized internally before comparison. |
|
|
29
29
|
| `pathChangeFileDirectory(filePath, fromDir, toDir)` | Changes the directory of a file path. Throws an error if the file is not within `fromDir`. |
|
|
30
30
|
| `pathBasenameWithoutExt(filePath)` | Returns the filename (basename) without extension. |
|
|
31
|
-
| `pathFilterByTargets(files, targets, cwd)` | Filters files based on target path list. Returns `files` as-is if `targets` is an empty array. |
|
|
31
|
+
| `pathFilterByTargets(files, targets, cwd)` | Filters files based on target path list. `files` must be absolute paths under `cwd`. `targets` are POSIX-style paths relative to `cwd`. Returns `files` as-is if `targets` is an empty array. |
|
|
32
32
|
|
|
33
33
|
```typescript
|
|
34
34
|
import {
|
|
@@ -105,8 +105,8 @@ Provides functions for reading, writing, deleting, copying, and searching files
|
|
|
105
105
|
| `fsReadSync(targetPath)` | Synchronously reads a file as a UTF-8 string. |
|
|
106
106
|
| `fsReadBuffer(targetPath)` | Asynchronously reads a file as a Buffer. |
|
|
107
107
|
| `fsReadBufferSync(targetPath)` | Synchronously reads a file as a Buffer. |
|
|
108
|
-
| `fsReadJson<
|
|
109
|
-
| `fsReadJsonSync<
|
|
108
|
+
| `fsReadJson<TData>(targetPath)` | Asynchronously reads a JSON file (uses `jsonParse`). |
|
|
109
|
+
| `fsReadJsonSync<TData>(targetPath)` | Synchronously reads a JSON file (uses `jsonParse`). |
|
|
110
110
|
|
|
111
111
|
#### File Writing
|
|
112
112
|
|
|
@@ -121,8 +121,8 @@ Provides functions for reading, writing, deleting, copying, and searching files
|
|
|
121
121
|
|
|
122
122
|
| Function | Description |
|
|
123
123
|
|----------|-------------|
|
|
124
|
-
| `fsReaddir(targetPath)` | Asynchronously reads directory contents. |
|
|
125
|
-
| `fsReaddirSync(targetPath)` | Synchronously reads directory contents. |
|
|
124
|
+
| `fsReaddir(targetPath)` | Asynchronously reads directory contents. Returns an array of entry names. |
|
|
125
|
+
| `fsReaddirSync(targetPath)` | Synchronously reads directory contents. Returns an array of entry names. |
|
|
126
126
|
|
|
127
127
|
#### File Information
|
|
128
128
|
|
|
@@ -130,8 +130,8 @@ Provides functions for reading, writing, deleting, copying, and searching files
|
|
|
130
130
|
|----------|-------------|
|
|
131
131
|
| `fsStat(targetPath)` | Asynchronously retrieves file/directory information (follows symbolic links). |
|
|
132
132
|
| `fsStatSync(targetPath)` | Synchronously retrieves file/directory information (follows symbolic links). |
|
|
133
|
-
| `fsLstat(targetPath)` | Asynchronously retrieves file/directory information (symbolic link itself). |
|
|
134
|
-
| `fsLstatSync(targetPath)` | Synchronously retrieves file/directory information (symbolic link itself). |
|
|
133
|
+
| `fsLstat(targetPath)` | Asynchronously retrieves file/directory information (symbolic link itself, does not follow). |
|
|
134
|
+
| `fsLstatSync(targetPath)` | Synchronously retrieves file/directory information (symbolic link itself, does not follow). |
|
|
135
135
|
|
|
136
136
|
#### Glob Search
|
|
137
137
|
|
|
@@ -144,9 +144,9 @@ Provides functions for reading, writing, deleting, copying, and searching files
|
|
|
144
144
|
|
|
145
145
|
| Function | Description |
|
|
146
146
|
|----------|-------------|
|
|
147
|
-
| `fsClearEmptyDirectory(dirPath)` | Recursively deletes empty directories under the specified directory. |
|
|
148
|
-
| `fsFindAllParentChildPaths(childGlob, fromPath, rootPath?)` | Traverses parent directories from
|
|
149
|
-
| `fsFindAllParentChildPathsSync(childGlob, fromPath, rootPath?)` | Synchronous version of
|
|
147
|
+
| `fsClearEmptyDirectory(dirPath)` | Recursively deletes empty directories under the specified directory. If all children of a directory are deleted, that directory is also deleted. |
|
|
148
|
+
| `fsFindAllParentChildPaths(childGlob, fromPath, rootPath?)` | Traverses parent directories from `fromPath` toward the root (or `rootPath`), asynchronously searching with a glob pattern at each level. Collects all matched paths. **Note**: `fromPath` must be a child of `rootPath`; otherwise, the search continues to the filesystem root. |
|
|
149
|
+
| `fsFindAllParentChildPathsSync(childGlob, fromPath, rootPath?)` | Synchronous version of `fsFindAllParentChildPaths`. Same parameters and behavior, but runs synchronously. |
|
|
150
150
|
|
|
151
151
|
```typescript
|
|
152
152
|
import {
|
|
@@ -220,8 +220,8 @@ A chokidar-based file system change detection wrapper with glob pattern support.
|
|
|
220
220
|
|
|
221
221
|
| API | Description |
|
|
222
222
|
|-----|-------------|
|
|
223
|
-
| `FsWatcher.watch(paths, options?)` | Starts file watching (static, async). `paths` can be file paths or glob patterns (e.g., `"src/**/*.ts"`). Waits until chokidar's `ready` event and returns an `FsWatcher` instance. |
|
|
224
|
-
| `watcher.onChange(opt, cb)` | Registers a file change event handler. Set event merge wait time (ms) with `opt.delay`. Supports chaining. |
|
|
223
|
+
| `FsWatcher.watch(paths, options?)` | Starts file watching (static, async). `paths` can be file paths or glob patterns (e.g., `"src/**/*.ts"`). Waits until chokidar's `ready` event and returns an `FsWatcher` instance. `options` accepts `chokidar.ChokidarOptions`. |
|
|
224
|
+
| `watcher.onChange(opt, cb)` | Registers a file change event handler. `opt` is `{ delay?: number }` (required object, `delay` is optional). Set event merge wait time (ms) with `opt.delay`. Supports chaining. |
|
|
225
225
|
| `watcher.close()` | Stops file watching. |
|
|
226
226
|
| `FsWatcherEvent` | Event type: `"add"` \| `"addDir"` \| `"change"` \| `"unlink"` \| `"unlinkDir"` |
|
|
227
227
|
| `FsWatcherChangeInfo` | Change information interface. Has `event: FsWatcherEvent` and `path: NormPath` fields. |
|
|
@@ -234,6 +234,7 @@ When multiple events occur for the same file within a short time, only the final
|
|
|
234
234
|
|----------------|-----------|--------|
|
|
235
235
|
| `add` | `change` | `add` (modification right after creation is treated as creation) |
|
|
236
236
|
| `add` | `unlink` | Deleted (immediate deletion after creation is treated as no change) |
|
|
237
|
+
| `addDir` | `unlinkDir` | Deleted (same as above, for directories) |
|
|
237
238
|
| `unlink` | `add` / `change` | `add` (recreation after deletion) |
|
|
238
239
|
| `unlinkDir` | `addDir` | `addDir` (directory recreation) |
|
|
239
240
|
| Others | - | Overwritten with the latest event |
|
|
@@ -262,13 +263,13 @@ Provides a type-safe Worker wrapper based on Node.js `worker_threads`. Using Pro
|
|
|
262
263
|
|
|
263
264
|
| API | Description |
|
|
264
265
|
|-----|-------------|
|
|
265
|
-
| `Worker.create<TModule>(filePath, opt?)` | Creates a type-safe Worker Proxy. `filePath` is a `file://` URL or absolute path. |
|
|
266
|
-
| `createWorker<TMethods, TEvents>(methods)` | Worker factory used inside worker threads. Registers method objects and returns a sender
|
|
266
|
+
| `Worker.create<TModule>(filePath, opt?)` | Creates a type-safe Worker Proxy. `filePath` is a `file://` URL or absolute path. `opt` accepts `Omit<WorkerOptions, "stdout" \| "stderr">` from `worker_threads`. |
|
|
267
|
+
| `createWorker<TMethods, TEvents>(methods)` | Worker factory used inside worker threads. Registers method objects and returns a sender object with a `send(event, data?)` method for emitting events to the main thread. |
|
|
267
268
|
| `WorkerModule` | Module type interface used for type inference in `Worker.create<typeof import("./worker")>()`. |
|
|
268
|
-
| `WorkerProxy<TModule>` | Proxy type returned by `Worker.create()`. Provides promisified methods, `on()`, `off()`, `terminate()`. |
|
|
269
|
-
| `PromisifyMethods<
|
|
270
|
-
| `WorkerRequest` | Worker internal request message interface. |
|
|
271
|
-
| `WorkerResponse` | Worker internal response message type
|
|
269
|
+
| `WorkerProxy<TModule>` | Proxy type returned by `Worker.create()`. Provides promisified methods, `on(event, listener)`, `off(event, listener)`, and `terminate()`. |
|
|
270
|
+
| `PromisifyMethods<TMethods>` | Utility type that wraps method return values in `Promise<Awaited<R>>`. Used internally by `WorkerProxy`. |
|
|
271
|
+
| `WorkerRequest` | Worker internal request message interface. Has `id`, `method`, and `params` fields. |
|
|
272
|
+
| `WorkerResponse` | Worker internal response message type. Union of `"return"`, `"error"`, `"event"`, and `"log"` response shapes. |
|
|
272
273
|
|
|
273
274
|
**Basic Usage (without events):**
|
|
274
275
|
|
|
@@ -350,7 +351,8 @@ await worker.terminate();
|
|
|
350
351
|
- In `fsCopy`/`fsCopySync`, the `filter` function is not applied to the top-level `sourcePath`, and returning `false` for a directory skips that directory and all its children.
|
|
351
352
|
- `FsWatcher` supports glob patterns (e.g., `"src/**/*.ts"`) by extracting the base directory and filtering matched files. The glob matching is performed using minimatch pattern matching.
|
|
352
353
|
- `FsWatcher` internally enforces `ignoreInitial: true`. If you pass `ignoreInitial: false`, the callback will be called with an empty array on the first `onChange` call, but the actual initial file list will not be included.
|
|
353
|
-
- Worker automatically runs TypeScript worker files through `tsx` in development environment (`.ts` files). In production environment (`.js`), it creates Workers directly.
|
|
354
|
+
- `Worker` automatically runs TypeScript worker files through `tsx` in development environment (`.ts` files). In production environment (`.js`), it creates Workers directly.
|
|
355
|
+
- `Worker.create` forwards `stdout`/`stderr` from the worker thread to the main process automatically; these options cannot be overridden.
|
|
354
356
|
- This package depends on `@simplysm/core-common` and uses `jsonParse`/`jsonStringify` for JSON processing.
|
|
355
357
|
|
|
356
358
|
## Dependencies
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simplysm/core-node",
|
|
3
|
-
"version": "13.0.
|
|
3
|
+
"version": "13.0.43",
|
|
4
4
|
"description": "심플리즘 패키지 - 코어 모듈 (node)",
|
|
5
5
|
"author": "김석래",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -23,6 +23,6 @@
|
|
|
23
23
|
"glob": "^13.0.6",
|
|
24
24
|
"minimatch": "^10.2.2",
|
|
25
25
|
"tsx": "^4.21.0",
|
|
26
|
-
"@simplysm/core-common": "13.0.
|
|
26
|
+
"@simplysm/core-common": "13.0.43"
|
|
27
27
|
}
|
|
28
28
|
}
|