Skip to content

Commit 2c42f16

Browse files
committed
fix: mark wrapped functions as pure for optimization
1 parent dbb7b8b commit 2c42f16

8 files changed

Lines changed: 15 additions & 15 deletions

File tree

src/fs/safe/append.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { mkdir, mkdirSync } from "./mkdir";
99

1010
import type { AppendFileOptions, PathLike } from "../types";
1111

12-
const safeAppendFile = Result.wrap(fsp.appendFile, Error);
12+
const safeAppendFile = /* #__PURE__ */ Result.wrap(fsp.appendFile, Error);
1313
export const appendFile = async (
1414
path: PathLike,
1515
data: string,
@@ -29,7 +29,7 @@ export const appendFile = async (
2929
return result.context(`Failed to append file: ${path}`);
3030
});
3131

32-
const safeAppendFileSync = Result.wrap(fs.appendFileSync, Error);
32+
const safeAppendFileSync = /* #__PURE__ */ Result.wrap(fs.appendFileSync, Error);
3333
export const appendFileSync = (
3434
path: PathLike,
3535
data: string,

src/fs/safe/cp.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Result } from "@/result";
44

55
import type { CpOptions, PathLike } from "../types";
66

7-
const safeCp = Result.wrap(fsp.cp, Error);
7+
const safeCp = /* #__PURE__ */ Result.wrap(fsp.cp, Error);
88
export const cp = async (
99
source: PathLike,
1010
destination: PathLike,
@@ -17,7 +17,7 @@ export const cp = async (
1717
return result.context(`Failed to copy path: ${source} to ${destination}`);
1818
};
1919

20-
const safeCpSync = Result.wrap(fs.cpSync, Error);
20+
const safeCpSync = /* #__PURE__ */ Result.wrap(fs.cpSync, Error);
2121
export const cpSync = (
2222
source: PathLike,
2323
destination: PathLike,

src/fs/safe/mkdir.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { exists, existsSync } from "./exists";
66

77
import type { MkdirOptions, PathLike } from "../types";
88

9-
const safeMkdir = Result.wrap(fsp.mkdir, Error);
9+
const safeMkdir = /* #__PURE__ */ Result.wrap(fsp.mkdir, Error);
1010
export const mkdir = async (
1111
path: PathLike,
1212
options?: MkdirOptions,
@@ -20,7 +20,7 @@ export const mkdir = async (
2020
return result.and(ok()).context(`Failed to create directory: ${path}`);
2121
};
2222

23-
const safeMkdirSync = Result.wrap(fs.mkdirSync, Error);
23+
const safeMkdirSync = /* #__PURE__ */ Result.wrap(fs.mkdirSync, Error);
2424
export const mkdirSync = (path: PathLike, options?: MkdirOptions): Result<void, Error> => {
2525
const { recursive = true } = options || {};
2626

src/fs/safe/read.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { exists, existsSync } from "./exists";
99

1010
import type { BufferEncodingOptions, PathLike, StringEncodingOptions } from "../types";
1111

12-
const safeReadFile = Result.wrap(fsp.readFile, Error);
12+
const safeReadFile = /* #__PURE__ */ Result.wrap(fsp.readFile, Error);
1313
export async function readFile(
1414
path: PathLike,
1515
options: BufferEncodingOptions,
@@ -28,7 +28,7 @@ export async function readFile(path: any, options?: any): Promise<Result<any, Er
2828
return result.context(`Failed to read file: ${path}`);
2929
}
3030

31-
const safeReadFileSync = Result.wrap(fs.readFileSync, Error);
31+
const safeReadFileSync = /* #__PURE__ */ Result.wrap(fs.readFileSync, Error);
3232
export function readFileSync(path: PathLike, options: BufferEncodingOptions): Result<Buffer, Error>;
3333
export function readFileSync(
3434
path: PathLike,

src/fs/safe/rm.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Result } from "@/result";
44

55
import type { PathLike, RmOptions } from "../types";
66

7-
const safeRm = Result.wrap(fsp.rm, Error);
7+
const safeRm = /* #__PURE__ */ Result.wrap(fsp.rm, Error);
88
export const rm = async (path: PathLike, options?: RmOptions): Promise<Result<void, Error>> => {
99
const { force = true, recursive = true } = options || {};
1010

@@ -13,7 +13,7 @@ export const rm = async (path: PathLike, options?: RmOptions): Promise<Result<vo
1313
return result.context(`Failed to remove path: ${path}`);
1414
};
1515

16-
const safeRmSync = Result.wrap(fs.rmSync, Error);
16+
const safeRmSync = /* #__PURE__ */ Result.wrap(fs.rmSync, Error);
1717
export const rmSync = (path: PathLike, options?: RmOptions): Result<void, Error> => {
1818
const { force = true, recursive = true } = options || {};
1919

src/fs/safe/write.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { mkdir, mkdirSync } from "./mkdir";
1010

1111
import type { PathLike, StringEncodingOptions, WriteJsonOptions } from "../types";
1212

13-
const safeWriteFile = Result.wrap(fsp.writeFile, Error);
13+
const safeWriteFile = /* #__PURE__ */ Result.wrap(fsp.writeFile, Error);
1414
export const writeFile = async (
1515
path: PathLike,
1616
data: string,
@@ -24,7 +24,7 @@ export const writeFile = async (
2424
return result.context(`Failed to write file: ${path}`);
2525
});
2626

27-
const safeWriteFileSync = Result.wrap(fs.writeFileSync, Error);
27+
const safeWriteFileSync = /* #__PURE__ */ Result.wrap(fs.writeFileSync, Error);
2828
export const writeFileSync = (
2929
path: PathLike,
3030
data: string,

src/json/safe.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import { err, Result } from "@/result";
44

5-
const safeStringify = Result.wrap(JSON.stringify);
5+
const safeStringify = /* #__PURE__ */ Result.wrap(JSON.stringify);
66
export const stringify: {
77
(
88
value: any,
@@ -26,7 +26,7 @@ export const stringify: {
2626
return text;
2727
});
2828

29-
const safeParse = Result.wrap(JSON.parse);
29+
const safeParse = /* #__PURE__ */ Result.wrap(JSON.parse);
3030
export const parse = <T = any>(
3131
text: string,
3232
reviver?: (this: any, key: string, value: any) => any,

src/json/stable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { configure } from "safe-stable-stringify";
22

3-
export const stableStringify = configure({
3+
export const stableStringify = /* #__PURE__ */ configure({
44
bigint: true,
55
});

0 commit comments

Comments
 (0)