Skip to content

Commit

Permalink
refactor: update all node:* imports
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Feb 22, 2024
1 parent b87a202 commit c71a526
Show file tree
Hide file tree
Showing 59 changed files with 88 additions and 96 deletions.
6 changes: 3 additions & 3 deletions examples/commit-heatmap/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import {
sortedKeys,
transduce,
} from "@thi.ng/transducers";
import { execFileSync } from "child_process";
import { writeFileSync } from "fs";
import { resolve } from "path";
import { execFileSync } from "node:child_process";
import { writeFileSync } from "node:fs";
import { resolve } from "node:path";

interface Commit {
date?: string;
Expand Down
4 changes: 2 additions & 2 deletions examples/commit-table-ssr/src/server/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
transduce,
zip,
} from "@thi.ng/transducers";
import { execSync } from "child_process";
import { resolve } from "path";
import { execSync } from "node:child_process";
import { resolve } from "node:path";
import type { Commit } from "../common/api";

/**
Expand Down
2 changes: 1 addition & 1 deletion examples/commit-table-ssr/src/server/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { TLRUCache } from "@thi.ng/cache";
import express from "express";
import * as fs from "fs";
import * as fs from "node:fs";
// @ts-ignore fixme
import * as Bundler from "parcel-bundler";
import type { Commit } from "../common/api";
Expand Down
2 changes: 1 addition & 1 deletion examples/package-stats/src/dep-chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
transduce,
zip,
} from "@thi.ng/transducers";
import * as fs from "fs";
import * as fs from "node:fs";
import { barChart, labeledTickX, labeledTickY } from "./viz.js";

const BASE_DIR = "../../packages/";
Expand Down
2 changes: 1 addition & 1 deletion examples/package-stats/src/size-chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
push,
transduce,
} from "@thi.ng/transducers";
import { existsSync, readdirSync, readFileSync, writeFileSync } from "fs";
import { existsSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
import { barChart, labeledTickX, labeledTickY } from "./viz.js";

const BASE_DIR = "../../packages/";
Expand Down
2 changes: 1 addition & 1 deletion examples/pointfree-svg/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { serialize } from "@thi.ng/hiccup";
import * as svg from "@thi.ng/hiccup-svg";
import { ensureStack, maptos } from "@thi.ng/pointfree";
import { ffi, run } from "@thi.ng/pointfree-lang";
import { writeFileSync } from "fs";
import { writeFileSync } from "node:fs";

// rudimentary generic graphics lib & helper words
const libsrc = `
Expand Down
2 changes: 1 addition & 1 deletion examples/rdom-web-components/build-mcss.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { files } from "@thi.ng/file-io";
import { spawn, execFileSync } from "child_process";
import { spawn, execFileSync } from "node:child_process";

// this build script is used to invoke the thi.ng/meta-css toolchain
// for both dev mode (incl. file watching of .mcss files) and for
Expand Down
4 changes: 2 additions & 2 deletions examples/xml-converter/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { readFileSync } from "fs";
import { resolve } from "path";
import { readFileSync } from "node:fs";
import { resolve } from "node:path";
import { strings, string, flag, parse } from "@thi.ng/args";
import { convertXML } from "./convert.js";
import { COMPACT_FORMAT, DEFAULT_FORMAT } from "./format.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/csp/test/file.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as tx from "@thi.ng/transducers";
import * as fs from "fs";
import * as fs from "node:fs";
import { Channel, Mult } from "../src/index.js";

// compose transducer to split source file into words
Expand Down
4 changes: 2 additions & 2 deletions packages/egf/src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { unsupported } from "@thi.ng/errors/unsupported";
import { NULL_LOGGER } from "@thi.ng/logger/null";
import * as $prefixes from "@thi.ng/prefixes";
import { unescape } from "@thi.ng/strings/escape";
import { readFileSync } from "fs";
import { dirname, resolve as resolvePath } from "path";
import { readFileSync } from "node:fs";
import { dirname, resolve as resolvePath } from "node:path";
import {
IS_NODE,
type Node,
Expand Down
6 changes: 3 additions & 3 deletions packages/egf/src/tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import type { IObjectOf } from "@thi.ng/api";
import { unescape } from "@thi.ng/strings/escape";
import { maybeParseFloat, maybeParseInt } from "@thi.ng/strings/parse";
import { base64Decode } from "@thi.ng/transducers-binary/base64";
import { execFileSync } from "child_process";
import { readFileSync } from "fs";
import { resolve as resolvePath } from "path";
import { execFileSync } from "node:child_process";
import { readFileSync } from "node:fs";
import { resolve as resolvePath } from "node:path";
import { IS_NODE, NODE_ONLY, type TagParser } from "./api.js";

export const BUILTINS: IObjectOf<TagParser> = {
Expand Down
2 changes: 1 addition & 1 deletion packages/egf/test/serialize.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { rdf, schema } from "@thi.ng/prefixes";
import { expect, test } from "bun:test";
// import { writeFileSync } from "fs";
// import { writeFileSync } from "node:fs";
import { toEGF } from "../src/index.js";

test("basics", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/file-io/src/delete.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ILogger } from "@thi.ng/logger";
import { unlinkSync } from "fs";
import { unlinkSync } from "node:fs";

/**
* Deletes file at given path. If `dryRun` is true (default: false), the file
Expand Down
4 changes: 2 additions & 2 deletions packages/file-io/src/dir.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { existsSync, mkdirSync, statSync } from "fs";
import { dirname } from "path";
import { existsSync, mkdirSync, statSync } from "node:fs";
import { dirname } from "node:path";

/**
* Assumes given path is to a directory. Checks if the dir exists and if not
Expand Down
2 changes: 1 addition & 1 deletion packages/file-io/src/file-chunks.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Nullable } from "@thi.ng/api";
import { U32 } from "@thi.ng/hex";
import type { ILogger } from "@thi.ng/logger";
import { open, type FileHandle } from "fs/promises";
import { open, type FileHandle } from "node:fs/promises";

export interface FileChunkOpts {
/**
Expand Down
4 changes: 2 additions & 2 deletions packages/file-io/src/files.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Predicate } from "@thi.ng/api";
import type { ILogger } from "@thi.ng/logger";
import { readdirSync, statSync } from "fs";
import { sep } from "path";
import { readdirSync, statSync } from "node:fs";
import { sep } from "node:path";
import { isDirectory } from "./dir.js";
import { __ensurePred } from "./internal/ensure.js";

Expand Down
4 changes: 2 additions & 2 deletions packages/file-io/src/hash.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ILogger } from "@thi.ng/logger";
import { createHash } from "crypto";
import { readFileSync } from "fs";
import { createHash } from "node:crypto";
import { readFileSync } from "node:fs";

export type HashAlgo =
| "gost-mac"
Expand Down
2 changes: 1 addition & 1 deletion packages/file-io/src/read.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ILogger } from "@thi.ng/logger";
import { readFileSync } from "fs";
import { readFileSync } from "node:fs";

/**
* Reads given file `path` into a byte array.
Expand Down
6 changes: 3 additions & 3 deletions packages/file-io/src/temp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import type { TypedArray } from "@thi.ng/api";
import { isString } from "@thi.ng/checks/is-string";
import type { ILogger } from "@thi.ng/logger";
import { randomID } from "@thi.ng/random/random-id";
import { realpathSync, writeFileSync } from "fs";
import { tmpdir } from "os";
import { sep } from "path";
import { realpathSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { sep } from "node:path";
import { ensureDirForFile } from "./dir.js";

export const createTempFile = (
Expand Down
2 changes: 1 addition & 1 deletion packages/file-io/src/text.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { isArray } from "@thi.ng/checks/is-array";
import type { ILogger } from "@thi.ng/logger";
import { readFileSync } from "fs";
import { readFileSync } from "node:fs";
import { writeFile } from "./write.js";

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/file-io/src/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import {
import { isString } from "@thi.ng/checks/is-string";
import type { ILogger } from "@thi.ng/logger";
import { NULL_LOGGER } from "@thi.ng/logger/null";
import { watch as $watch, existsSync, type FSWatcher } from "fs";
import { join } from "path";
import { watch as $watch, existsSync, type FSWatcher } from "node:fs";
import { join } from "node:path";
import { isDirectory } from "./dir.js";
import { __ensurePred } from "./internal/ensure.js";

Expand Down
2 changes: 1 addition & 1 deletion packages/file-io/src/write.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { TypedArray } from "@thi.ng/api";
import { isString } from "@thi.ng/checks/is-string";
import type { ILogger } from "@thi.ng/logger";
import { writeFileSync, type WriteFileOptions } from "fs";
import { writeFileSync, type WriteFileOptions } from "node:fs";
import { ensureDirForFile } from "./dir.js";
/**
* Writes `body` as to given `path` (using optional `opts` to define encoding).
Expand Down
4 changes: 2 additions & 2 deletions packages/hdiff/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// thing:no-export
import { readFileSync } from "fs";
import { execSync } from "child_process";
import { readFileSync } from "node:fs";
import { execSync } from "node:child_process";
import { computeDiff } from "./diff.js";
import { generateHtml } from "./html.js";

Expand Down
12 changes: 2 additions & 10 deletions packages/imago/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,33 +244,25 @@ Auto-rotate, rotate and/or mirror image
yarn add @thi.ng/imago
```

ES module import:

```html
<script type="module" src="https://cdn.skypack.dev/@thi.ng/imago"></script>
```

[Skypack documentation](https://docs.skypack.dev/)

For Node.js REPL:

```js
const imago = await import("@thi.ng/imago");
```

Package sizes (brotli'd, pre-treeshake): ESM: 4.42 KB
Package sizes (brotli'd, pre-treeshake): ESM: 3.14 KB

## Dependencies

- [@thi.ng/api](https://github.com/thi-ng/umbrella/tree/develop/packages/api)
- [@thi.ng/checks](https://github.com/thi-ng/umbrella/tree/develop/packages/checks)
- [@thi.ng/date](https://github.com/thi-ng/umbrella/tree/develop/packages/date)
- [@thi.ng/defmulti](https://github.com/thi-ng/umbrella/tree/develop/packages/defmulti)
- [@thi.ng/errors](https://github.com/thi-ng/umbrella/tree/develop/packages/errors)
- [@thi.ng/file-io](https://github.com/thi-ng/umbrella/tree/develop/packages/file-io)
- [@thi.ng/logger](https://github.com/thi-ng/umbrella/tree/develop/packages/logger)
- [@thi.ng/pixel](https://github.com/thi-ng/umbrella/tree/develop/packages/pixel)
- [@thi.ng/pixel-dither](https://github.com/thi-ng/umbrella/tree/develop/packages/pixel-dither)
- [sharp](https://sharp.pixelplumbing.com)

## API

Expand Down
4 changes: 2 additions & 2 deletions packages/imago/src/path.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { TypedArray } from "@thi.ng/api";
import { FMT_HHmmss_ALT, FMT_yyyyMMdd_ALT } from "@thi.ng/date";
import { illegalArgs as unsupported } from "@thi.ng/errors";
import { createHash } from "crypto";
import { basename } from "path";
import { createHash } from "node:crypto";
import { basename } from "node:path";
import type { ImgProcCtx } from "./api.js";

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/imago/src/proc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
orderedDither,
type DitherKernel,
} from "@thi.ng/pixel-dither";
import { join, resolve } from "path";
import { join, resolve } from "node:path";
import sharp, { type OverlayOptions, type Sharp } from "sharp";
import {
GRAVITY_POSITION,
Expand Down
2 changes: 1 addition & 1 deletion packages/lsys/test/examples.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as g from "@thi.ng/geom";
import * as lsys from "@thi.ng/lsys";
import * as fs from "fs";
import * as fs from "node:fs";

// example L-Systems shown above
interface Example {
Expand Down
2 changes: 1 addition & 1 deletion packages/lsys/test/tree.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as g from "@thi.ng/geom";
import { PI } from "@thi.ng/math";
import { XsAdd } from "@thi.ng/random";
import * as fs from "fs";
import * as fs from "node:fs";
import * as lsys from "../src/index.js";

const impl = lsys.TURTLE_IMPL_2D;
Expand Down
4 changes: 2 additions & 2 deletions packages/meta-css/src/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import { type ILogger } from "@thi.ng/logger";
import { sync } from "@thi.ng/rstream";
import { split } from "@thi.ng/strings";
import { filter, map } from "@thi.ng/transducers";
import { watch } from "fs";
import { resolve } from "path";
import { watch } from "node:fs";
import { resolve } from "node:path";
import {
ARG_BUNDLE,
ARG_EVAL,
Expand Down
2 changes: 1 addition & 1 deletion packages/meta-css/src/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { Command } from "@thi.ng/args";
import { readJSON, readText } from "@thi.ng/file-io";
import { COMPACT, PRETTY, QUOTED_FNS, at_media, css } from "@thi.ng/hiccup-css";
import type { ILogger } from "@thi.ng/logger";
import { resolve } from "path";
import { resolve } from "node:path";
import {
ARG_INCLUDE,
ARG_MEDIA_QUERIES,
Expand Down
4 changes: 2 additions & 2 deletions packages/meta-css/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import type { ILogger } from "@thi.ng/logger";
import { Stream, reactive, sync } from "@thi.ng/rstream";
import { Z4 } from "@thi.ng/strings";
import { assocObj, map } from "@thi.ng/transducers";
import { watch } from "fs";
import { resolve } from "path";
import { watch } from "node:fs";
import { resolve } from "node:path";
import type { CompiledSpecs } from "./api.js";

export const maybeWriteText = (
Expand Down
4 changes: 2 additions & 2 deletions packages/pointfree-lang/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { timedResult } from "@thi.ng/bench";
import { readJSON, readText, writeFile } from "@thi.ng/file-io";
import { LogLevel } from "@thi.ng/logger";
import { ensureStack, type StackContext } from "@thi.ng/pointfree";
import { readFileSync, readdirSync } from "fs";
import { resolve } from "path";
import { readFileSync, readdirSync } from "node:fs";
import { resolve } from "node:path";
import { ffi, run, runU } from "./runtime.js";

interface CLIOpts {
Expand Down
2 changes: 1 addition & 1 deletion packages/rstream-log-file/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ISubscriber } from "@thi.ng/rstream";
import { appendFile } from "fs";
import { appendFile } from "node:fs";

export const writeFile = (path: string): ISubscriber<string> => ({
next(msg) {
Expand Down
4 changes: 2 additions & 2 deletions packages/rstream/src/nodejs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { rechunk } from "@thi.ng/transducers/rechunk";
import type { Readable } from "stream";
import type { Readable } from "node:stream";
import { stream, type Stream } from "./stream.js";
import type { Subscription } from "./subscription.js";

Expand Down Expand Up @@ -36,7 +36,7 @@ export const fromNodeJS = <T>(
*
* @example
* ```ts
* import { spawn } from "child_process"
* import { spawn } from "node:child_process"
* import { linesFromNodeJS, trace } from "@thi.ng/rstream";
*
* const cmd = spawn("ls", ["-la"]);
Expand Down
2 changes: 1 addition & 1 deletion packages/tangle/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from "@thi.ng/args";
import { readJSON, writeText } from "@thi.ng/file-io";
import { ConsoleLogger } from "@thi.ng/logger";
import { resolve } from "path";
import { resolve } from "node:path";
import type { TangleCtx } from "./api.js";
import { tangleFile } from "./tangle.js";

Expand Down
2 changes: 1 addition & 1 deletion packages/tangle/src/tangle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { illegalArgs } from "@thi.ng/errors/illegal-arguments";
import { readText } from "@thi.ng/file-io";
import { split } from "@thi.ng/strings";
import { assocObj, map, transduce } from "@thi.ng/transducers";
import { extname, isAbsolute, resolve, sep } from "path";
import { extname, isAbsolute, resolve, sep } from "node:path";
import {
BLOCK_FORMATS,
COMMENT_FORMATS,
Expand Down
2 changes: 1 addition & 1 deletion packages/tangle/test/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { fileFixture, fixturePath, group } from "@thi.ng/testament";
import * as assert from "assert";
import { readFileSync } from "fs";
import { readFileSync } from "node:fs";
import { tangleFile, tangleString } from "../src/index.js";

group("tangle", {
Expand Down
4 changes: 2 additions & 2 deletions packages/testament/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// thing:no-export
import { watch } from "chokidar";
import { readdirSync, statSync, writeFileSync } from "fs";
import { normalize, resolve } from "path";
import { readdirSync, statSync, writeFileSync } from "node:fs";
import { normalize, resolve } from "node:path";
import { GLOBAL_OPTS, type TestResult } from "./api.js";
import { execute } from "./exec.js";
import { isString } from "./utils.js";
Expand Down
4 changes: 2 additions & 2 deletions packages/testament/src/fixtures.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ILogger } from "@thi.ng/logger";
import { readFileSync } from "fs";
import { join, resolve } from "path";
import { readFileSync } from "node:fs";
import { join, resolve } from "node:path";

/**
* Only available for NodeJS. Returns path for given local fixture path, i.e.
Expand Down
Loading

0 comments on commit c71a526

Please sign in to comment.