Skip to content

Commit

Permalink
Replaced internal once function with "function-once"
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiospampinato committed Apr 15, 2024
1 parent 8f2cd60 commit 6cb91c5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"atomically": "^2.0.3",
"fast-ignore": "^1.1.3",
"find-up-json": "^2.0.4",
"function-once": "^3.0.0",
"import-meta-resolve": "^4.0.0",
"is-binary-path": "^2.1.0",
"js-yaml": "^4.1.0",
Expand Down
14 changes: 1 addition & 13 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import findUp from "find-up-json";
import once from "function-once";
import { moduleResolve } from "import-meta-resolve";
import memoize from "lomemo";
import crypto from "node:crypto";
Expand Down Expand Up @@ -570,19 +571,6 @@ function omit<T extends object, K extends keyof T>(object: T, keys: K[]): Omit<T
return clone;
}

function once<T>(fn: () => T): () => T {
let inited = false;
let result: T;

return (): T => {
if (!inited) {
inited = true;
result = fn();
}
return result;
};
}

function pluralize(value: string, length: number): string {
return `${value}${length === 1 ? "" : "s"}`;
}
Expand Down

0 comments on commit 6cb91c5

Please sign in to comment.