@thi.ng/file-io 1.3.1 → 1.3.3

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/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2024-02-19T16:07:07Z
3
+ - **Last updated**: 2024-02-22T23:15:26Z
4
4
  - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
5
 
6
6
  All notable changes to this project will be documented in this file.
@@ -9,6 +9,18 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
9
9
  **Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
10
10
  and/or version bumps of transitive dependencies.
11
11
 
12
+ ### [1.3.3](https://github.com/thi-ng/umbrella/tree/@thi.ng/file-io@1.3.3) (2024-02-22)
13
+
14
+ #### ♻️ Refactoring
15
+
16
+ - update object destructuring in all pkgs & examples ([f36aeb0](https://github.com/thi-ng/umbrella/commit/f36aeb0))
17
+
18
+ ### [1.3.2](https://github.com/thi-ng/umbrella/tree/@thi.ng/file-io@1.3.2) (2024-02-22)
19
+
20
+ #### ♻️ Refactoring
21
+
22
+ - update all `node:*` imports ([c71a526](https://github.com/thi-ng/umbrella/commit/c71a526))
23
+
12
24
  ## [1.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/file-io@1.3.0) (2024-02-19)
13
25
 
14
26
  #### 🚀 Features
package/README.md CHANGED
@@ -18,7 +18,7 @@
18
18
  [![Mastodon Follow](https://img.shields.io/mastodon/follow/109331703950160316?domain=https%3A%2F%2Fmastodon.thi.ng&style=social)](https://mastodon.thi.ng/@toxi)
19
19
 
20
20
  > [!NOTE]
21
- > This is one of 189 standalone projects, maintained as part
21
+ > This is one of 190 standalone projects, maintained as part
22
22
  > of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
23
23
  > and anti-framework.
24
24
  >
@@ -59,7 +59,7 @@ For Node.js REPL:
59
59
  const fileIo = await import("@thi.ng/file-io");
60
60
  ```
61
61
 
62
- Package sizes (brotli'd, pre-treeshake): ESM: 1.98 KB
62
+ Package sizes (brotli'd, pre-treeshake): ESM: 1.99 KB
63
63
 
64
64
  ## Dependencies
65
65
 
package/delete.js CHANGED
@@ -1,4 +1,4 @@
1
- import { unlinkSync } from "fs";
1
+ import { unlinkSync } from "node:fs";
2
2
  const deleteFile = (path, logger, dryRun = false) => {
3
3
  logger && logger.info(`${dryRun ? "[dryrun] " : ""}deleting file: ${path}`);
4
4
  if (dryRun)
package/dir.js CHANGED
@@ -1,5 +1,5 @@
1
- import { existsSync, mkdirSync, statSync } from "fs";
2
- import { dirname } from "path";
1
+ import { existsSync, mkdirSync, statSync } from "node:fs";
2
+ import { dirname } from "node:path";
3
3
  const ensureDir = (dir) => dir.length > 0 && !existsSync(dir) ? (mkdirSync(dir, { recursive: true }), true) : false;
4
4
  const ensureDirForFile = (path) => ensureDir(dirname(path));
5
5
  const isDirectory = (path) => statSync(path).isDirectory();
package/file-chunks.js CHANGED
@@ -1,12 +1,7 @@
1
1
  import { U32 } from "@thi.ng/hex";
2
- import { open } from "fs/promises";
3
- async function* fileChunks(path, opts) {
4
- let { logger, size, start, end } = {
5
- size: 1024,
6
- start: 0,
7
- end: Infinity,
8
- ...opts
9
- };
2
+ import { open } from "node:fs/promises";
3
+ async function* fileChunks(path, opts = {}) {
4
+ let { size = 1024, start = 0, end = Infinity, logger } = opts;
10
5
  logger && logger.debug(`start reading file chunks (size: 0x${size}): ${path}`);
11
6
  let fd = void 0;
12
7
  try {
package/files.js CHANGED
@@ -1,5 +1,5 @@
1
- import { readdirSync, statSync } from "fs";
2
- import { sep } from "path";
1
+ import { readdirSync, statSync } from "node:fs";
2
+ import { sep } from "node:path";
3
3
  import { isDirectory } from "./dir.js";
4
4
  import { __ensurePred } from "./internal/ensure.js";
5
5
  const files = (dir, match = "", maxDepth = Infinity, logger) => __files(dir, match, logger, maxDepth, 0);
package/hash.js CHANGED
@@ -1,5 +1,5 @@
1
- import { createHash } from "crypto";
2
- import { readFileSync } from "fs";
1
+ import { createHash } from "node:crypto";
2
+ import { readFileSync } from "node:fs";
3
3
  const fileHash = (path, logger, algo = "sha256") => {
4
4
  const sum = createHash(algo);
5
5
  sum.update(readFileSync(path));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/file-io",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
4
4
  "description": "Assorted file I/O utils (with logging support) for NodeJS",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -35,11 +35,11 @@
35
35
  "test": "bun test"
36
36
  },
37
37
  "dependencies": {
38
- "@thi.ng/api": "^8.9.24",
39
- "@thi.ng/checks": "^3.4.24",
40
- "@thi.ng/hex": "^2.3.36",
41
- "@thi.ng/logger": "^3.0.1",
42
- "@thi.ng/random": "^3.6.31"
38
+ "@thi.ng/api": "^8.9.25",
39
+ "@thi.ng/checks": "^3.5.0",
40
+ "@thi.ng/hex": "^2.3.37",
41
+ "@thi.ng/logger": "^3.0.2",
42
+ "@thi.ng/random": "^3.6.32"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@microsoft/api-extractor": "^7.40.1",
@@ -120,5 +120,5 @@
120
120
  "status": "stable",
121
121
  "year": 2022
122
122
  },
123
- "gitHead": "2724c87ca41810f2112f9d8c3d6b90dfaeea876b\n"
123
+ "gitHead": "16f2b92b5410bd35dcde6c2971c8e62783ebc472\n"
124
124
  }
package/read.js CHANGED
@@ -1,4 +1,4 @@
1
- import { readFileSync } from "fs";
1
+ import { readFileSync } from "node:fs";
2
2
  const readBinary = (path, logger) => {
3
3
  logger && logger.debug("reading file:", path);
4
4
  const buf = readFileSync(path);
package/temp.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { isString } from "@thi.ng/checks/is-string";
2
2
  import { randomID } from "@thi.ng/random/random-id";
3
- import { realpathSync, writeFileSync } from "fs";
4
- import { tmpdir } from "os";
5
- import { sep } from "path";
3
+ import { realpathSync, writeFileSync } from "node:fs";
4
+ import { tmpdir } from "node:os";
5
+ import { sep } from "node:path";
6
6
  import { ensureDirForFile } from "./dir.js";
7
7
  const createTempFile = (body, logger, name) => {
8
8
  const path = tempFilePath(name);
package/text.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { isArray } from "@thi.ng/checks/is-array";
2
- import { readFileSync } from "fs";
2
+ import { readFileSync } from "node:fs";
3
3
  import { writeFile } from "./write.js";
4
4
  const readText = (path, logger, encoding = "utf-8") => {
5
5
  logger && logger.debug("reading file:", path);
package/watch.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import { type Event, type IClear, type INotify, type IObjectOf, type Listener, type Predicate } from "@thi.ng/api";
3
3
  import type { ILogger } from "@thi.ng/logger";
4
- import { type FSWatcher } from "fs";
4
+ import { type FSWatcher } from "node:fs";
5
5
  export interface WatcherOpts {
6
6
  /**
7
7
  * Number of milliseconds between observing a file change and notifying
package/watch.js CHANGED
@@ -14,8 +14,8 @@ import {
14
14
  } from "@thi.ng/api";
15
15
  import { isString } from "@thi.ng/checks/is-string";
16
16
  import { NULL_LOGGER } from "@thi.ng/logger/null";
17
- import { watch as $watch, existsSync } from "fs";
18
- import { join } from "path";
17
+ import { watch as $watch, existsSync } from "node:fs";
18
+ import { join } from "node:path";
19
19
  import { isDirectory } from "./dir.js";
20
20
  import { __ensurePred } from "./internal/ensure.js";
21
21
  const EVENT_ADDED = "added";
package/write.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import type { TypedArray } from "@thi.ng/api";
3
3
  import type { ILogger } from "@thi.ng/logger";
4
- import { type WriteFileOptions } from "fs";
4
+ import { type WriteFileOptions } from "node:fs";
5
5
  /**
6
6
  * Writes `body` as to given `path` (using optional `opts` to define encoding).
7
7
  * If `dryRun` is true (default: false), the file WON'T be written, however if a
package/write.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { isString } from "@thi.ng/checks/is-string";
2
- import { writeFileSync } from "fs";
2
+ import { writeFileSync } from "node:fs";
3
3
  import { ensureDirForFile } from "./dir.js";
4
4
  const writeFile = (path, body, opts, logger, dryRun = false) => {
5
5
  logger && logger.info(`${dryRun ? "[dryrun] " : ""}writing file: ${path}`);