@frsource/frs-replace 5.1.9 → 5.1.11

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 CHANGED
@@ -239,21 +239,21 @@ const result = sync({
239
239
 
240
240
  ## :chart_with_upwards_trend: Benchmarks
241
241
 
242
- > Tested on Node v20.18.1.
242
+ > Tested on Node v20.18.2.
243
243
 
244
244
  ### input as glob pattern [40 files]
245
245
 
246
246
  | Rank | Library | Average latency [ms] | Difference percentage (comparing to best average latency) |
247
247
  | ---- | ----------------------------- | -------------------- | ----------------------------------------------------------------------------- |
248
- | 1 | @frsource/frs-replace (sync) | 0.46 ± 1.12% | +0.00% |
249
- | 2 | replace-in-file (sync) | 0.85 ± 1.57% | +85.76% |
250
- | 3 | @frsource/frs-replace (async) | 1.81 ± 1.33% | +295.54% |
251
- | 4 | replace-in-file (async) | 3.12 ± 1.29% | +580.17% |
248
+ | 1 | @frsource/frs-replace (sync) | 0.45 ± 1.16% | +0.00% |
249
+ | 2 | replace-in-file (sync) | 0.80 ± 1.27% | +76.77% |
250
+ | 3 | @frsource/frs-replace (async) | 1.82 ± 1.40% | +301.01% |
251
+ | 4 | replace-in-file (async) | 3.09 ± 1.22% | +579.84% |
252
252
 
253
253
  ### input & replacement as strings
254
254
 
255
255
  | Rank | Library | Average latency [ms] | Difference percentage (comparing to best average latency) |
256
256
  | ---- | ----------------------------- | -------------------- | ----------------------------------------------------------------------------- |
257
- | 1 | @frsource/frs-replace (sync) | 0.01 ± 0.54% | +0.00% |
258
- | 2 | @frsource/frs-replace (async) | 0.01 ± 0.36% | +12.34% |
259
- | 3 | replaceString | 0.18 ± 1.01% | +2179.82% |
257
+ | 1 | @frsource/frs-replace (sync) | 0.01 ± 0.27% | +0.00% |
258
+ | 2 | @frsource/frs-replace (async) | 0.01 ± 0.31% | +12.10% |
259
+ | 3 | replaceString | 0.18 ± 1.08% | +2155.02% |
@@ -0,0 +1,7 @@
1
+ declare function _default({ strategy, needle, replacement, ...args }: Args): Promise<import("./types.mjs").FileResult[]>;
2
+ export default _default;
3
+ export type Strategy = import("./types.mjs").Strategy;
4
+ export type InputStrategyFn = import("./types.mjs").InputStrategyFn;
5
+ export type OutputStrategyFn = import("./types.mjs").OutputStrategyFn;
6
+ export type Args = import("./types.mjs").Args;
7
+ export type FileResult = import("./types.mjs").FileResult;
@@ -0,0 +1,3 @@
1
+ export * from "./types.mjs";
2
+ export { default as sync } from "./sync.mjs";
3
+ export { default as async } from "./async.mjs";
@@ -0,0 +1,7 @@
1
+ declare function _default({ strategy, needle, replacement, ...args }: Args): import("./types.mjs").FileResult[];
2
+ export default _default;
3
+ export type Strategy = import("./types.mjs").Strategy;
4
+ export type InputStrategyFnSync = import("./types.mjs").InputStrategyFnSync;
5
+ export type OutputStrategyFnSync = import("./types.mjs").OutputStrategyFnSync;
6
+ export type Args = import("./types.mjs").Args;
7
+ export type FileResult = import("./types.mjs").FileResult;
@@ -0,0 +1,24 @@
1
+ export type Strategy = "join" | "flatten" | "preserve-structure";
2
+ export type CommonArgs = {
3
+ strategy?: Strategy;
4
+ needle: string | RegExp;
5
+ replacement: string;
6
+ };
7
+ export type InputArgs = {
8
+ input: Parameters<typeof import("fast-glob").sync>[0];
9
+ inputReadOptions?: Parameters<typeof import("fs").readFileSync>[1];
10
+ inputGlobOptions?: Parameters<typeof import("fast-glob").sync>[1];
11
+ } | {
12
+ content: string;
13
+ };
14
+ export type OutputArgs = {
15
+ output?: string;
16
+ outputWriteOptions?: Parameters<typeof import("fs").writeFileSync>[2];
17
+ outputJoinString?: string;
18
+ } | object;
19
+ export type Args = CommonArgs & InputArgs & OutputArgs;
20
+ export type FileResult = [string, string];
21
+ export type InputStrategyFnSync = (results: FileResult[], outputJoinString: string) => [FileResult[]] | [FileResult[], string];
22
+ export type OutputStrategyFnSync = (results: FileResult[], output: string, outputWriteOptions: Parameters<typeof import("fs").writeFileSync>[2]) => FileResult[];
23
+ export type InputStrategyFn = (results: Promise<Promise<FileResult>[]> | FileResult[], outputJoinString: string) => Promise<FileResult[]> | FileResult[];
24
+ export type OutputStrategyFn = (results: Promise<FileResult[]> | FileResult[], output: string, outputWriteOptions: Parameters<typeof import("fs").writeFileSync>[2]) => Promise<FileResult[]>;
@@ -0,0 +1,3 @@
1
+ export function writeError(msg: string): never;
2
+ export function getReplaceFn(needle: Args["needle"], replacement: string): (content: string) => string;
3
+ export type Args = import("./types.mjs").Args;
package/package.json CHANGED
@@ -1,16 +1,26 @@
1
1
  {
2
2
  "name": "@frsource/frs-replace",
3
- "version": "5.1.9",
3
+ "version": "5.1.11",
4
4
  "description": "Simple wrapper around javascript replace with CLI usage support!",
5
5
  "bin": {
6
6
  "frs-replace": "bin/cli.mjs"
7
7
  },
8
8
  "type": "module",
9
- "main": "dist/index.mjs",
9
+ "main": "src/index.mjs",
10
+ "types": "dist/index.d.mts",
10
11
  "exports": {
11
- ".": "./src/index.mjs",
12
- "./sync": "./src/sync.mjs",
13
- "./async": "./src/async.mjs",
12
+ ".": {
13
+ "default": "./src/index.mjs",
14
+ "types": "./dist/index.d.mts"
15
+ },
16
+ "./sync": {
17
+ "default": "./src/sync.mjs",
18
+ "types": "./dist/sync.d.mts"
19
+ },
20
+ "./async": {
21
+ "default": "./src/async.mjs",
22
+ "types": "./dist/async.d.mts"
23
+ },
14
24
  "./*": "./*.mjs"
15
25
  },
16
26
  "repository": {
@@ -25,6 +35,7 @@
25
35
  },
26
36
  "homepage": "https://github.com/FRSOURCE/frs-replace#readme",
27
37
  "files": [
38
+ "dist",
28
39
  "bin/cli.mjs",
29
40
  "src/*.mjs",
30
41
  "package.json"
@@ -45,9 +56,10 @@
45
56
  "javascript"
46
57
  ],
47
58
  "scripts": {
48
- "typecheck": "tsc --project tsconfig.json",
59
+ "typecheck": "tsc --project tsconfig.json --noEmit",
49
60
  "release": "semantic-release",
50
61
  "release:ci": "pnpm release --yes",
62
+ "build": "tsc --project tsconfig.json --declaration --emitDeclarationOnly",
51
63
  "test": "vitest",
52
64
  "coverage": "vitest --coverage",
53
65
  "test:ci": "vitest run --coverage && vitest bench --run && TEST_TYPE=bench vitest run --allowOnly",