Skip to content

Commit

Permalink
chore: replace memoize dependency with own implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
czosel committed Feb 3, 2024
1 parent 838a019 commit 9c7ce6c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node-version: [18.x, 20.x, 21.x]
node-version: [16.x, 18.x, 20.x]

env:
ENABLE_COVERAGE: true
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
],
"dependencies": {
"linguist-languages": "^7.27.0",
"memoize": "^10.0.0",
"php-parser": "^3.1.5"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/pragma.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import memoize from "memoize";
import { memoize } from "./util.mjs";
import parse from "./parser.mjs";

const reHasPragma = /@prettier|@format/;
Expand Down
11 changes: 11 additions & 0 deletions src/util.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,16 @@ function isSimpleCallArgument(node, depth = 2) {
return false;
}

function memoize(fn) {
const cache = new Map();
return (key) => {
if (!cache.has(key)) {
cache.set(key, fn(key));
}
return cache.get(key);
};
}

export {
printNumber,
getPrecedence,
Expand Down Expand Up @@ -715,4 +725,5 @@ export {
getAncestorNode,
normalizeMagicMethodName,
isSimpleCallArgument,
memoize,
};
12 changes: 0 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4704,13 +4704,6 @@ [email protected]:
dependencies:
tmpl "1.0.5"

memoize@^10.0.0:
version "10.0.0"
resolved "https://registry.yarnpkg.com/memoize/-/memoize-10.0.0.tgz#43fa66b2022363c7c50cf5dfab732a808a3d7147"
integrity sha512-H6cBLgsi6vMWOcCpvVCdFFnl3kerEXbrYh9q+lY6VXvQSmM6CkmV08VOwT+WE2tzIEqRPFfAq3fm4v/UIW6mSA==
dependencies:
mimic-function "^5.0.0"

merge-stream@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/merge-stream/-/merge-stream-2.0.0.tgz#52823629a14dd00c9770fb6ad47dc6310f2c1f60"
Expand Down Expand Up @@ -4751,11 +4744,6 @@ mimic-fn@^4.0.0:
resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-4.0.0.tgz#60a90550d5cb0b239cca65d893b1a53b29871ecc"
integrity sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==

mimic-function@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/mimic-function/-/mimic-function-5.0.0.tgz#6cb5a922d17923ee58cf2f7d904f3eb350e0c87a"
integrity sha512-RBfQ+9X9DpXdEoK7Bu+KeEU6vFhumEIiXKWECPzRBmDserEq4uR2b/VCm0LwpMSosoq2k+Zuxj/GzOr0Fn6h/g==

minimatch@^3.0.4, minimatch@^3.0.5, minimatch@^3.1.2:
version "3.1.2"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b"
Expand Down

0 comments on commit 9c7ce6c

Please sign in to comment.