Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3afdfaf

Browse files
committed
Require Node.js 18
1 parent22c4b5e commit3afdfaf

File tree

6 files changed

+29
-43
lines changed

6 files changed

+29
-43
lines changed

‎.github/funding.yml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
github:[sindresorhus, fregante]
2-
tidelift:npm/mem

‎.github/workflows/main.yml‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ jobs:
1212
node-version:
1313
#- 20
1414
-18
15-
-16
1615
steps:
17-
-uses:actions/checkout@v3
18-
-uses:actions/setup-node@v3
16+
-uses:actions/checkout@v4
17+
-uses:actions/setup-node@v4
1918
with:
2019
node-version:${{ matrix.node-version }}
2120
-run:npm install

‎index.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
importmimicFnfrom'mimic-fn';
1+
importmimicFunctionfrom'mimic-function';
22
importmapAgeCleanerfrom'map-age-cleaner';
33

4-
typeAnyFunction=(...arguments_:any)=>any;
4+
typeAnyFunction=(...arguments_:readonlyany[])=>any;
55

66
constcacheStore=newWeakMap<AnyFunction,CacheStorage<any,any>>();
77

@@ -68,7 +68,7 @@ export type Options<
6868
/**
6969
[Memoize](https://en.wikipedia.org/wiki/Memoization) functions - An optimization used to speed up consecutive function calls by caching the result of calls with identical input.
7070
71-
@param fn -Function to be memoized.
71+
@param fn -The function to be memoized.
7272
7373
@example
7474
```
@@ -113,7 +113,7 @@ export default function mem<
113113

114114
constcacheItem=cache.get(key);
115115
if(cacheItem){
116-
returncacheItem.data;// eslint-disable-line @typescript-eslint/no-unsafe-return
116+
returncacheItem.data;
117117
}
118118

119119
constresult=fn.apply(this,arguments_)asReturnType<FunctionToMemoize>;
@@ -123,10 +123,10 @@ export default function mem<
123123
maxAge:maxAge ?Date.now()+maxAge :Number.POSITIVE_INFINITY,
124124
});
125125

126-
returnresult;// eslint-disable-line @typescript-eslint/no-unsafe-return
126+
returnresult;
127127
}asFunctionToMemoize;
128128

129-
mimicFn(memoized,fn,{
129+
mimicFunction(memoized,fn,{
130130
ignoreNonConfigurable:true,
131131
});
132132

‎package.json‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,19 @@
1111
"url":"https://sindresorhus.com"
1212
},
1313
"type":"module",
14-
"exports":"./dist/index.js",
14+
"exports": {
15+
"types":"./dist/index.d.ts",
16+
"default":"./dist/index.js"
17+
},
18+
"sideEffects":false,
1519
"engines": {
16-
"node":">=16"
20+
"node":">=18"
1721
},
1822
"scripts": {
19-
"test":"xo && ava && npm run build && tsd",
23+
"test":"xo && ava && npm run build && tsd --typings dist/index.d.ts",
2024
"build":"del-cli dist && tsc",
2125
"prepack":"npm run build"
2226
},
23-
"types":"dist/index.d.ts",
2427
"files": [
2528
"dist"
2629
],
@@ -39,19 +42,18 @@
3942
],
4043
"dependencies": {
4144
"map-age-cleaner":"^0.2.0",
42-
"mimic-fn":"^4.0.0"
45+
"mimic-function":"^5.0.0"
4346
},
4447
"devDependencies": {
45-
"@sindresorhus/tsconfig":"^3.0.1",
46-
"@types/serialize-javascript":"^5.0.2",
47-
"ava":"^5.2.0",
48-
"del-cli":"^5.0.0",
49-
"delay":"^5.0.0",
48+
"@sindresorhus/tsconfig":"^5.0.0",
49+
"@types/serialize-javascript":"^5.0.4",
50+
"ava":"^5.3.1",
51+
"del-cli":"^5.1.0",
52+
"delay":"^6.0.0",
5053
"serialize-javascript":"^6.0.1",
5154
"ts-node":"^10.9.1",
52-
"tsd":"^0.28.1",
53-
"typescript":"^5.0.4",
54-
"xo":"^0.54.2"
55+
"tsd":"^0.29.0",
56+
"xo":"^0.56.0"
5557
},
5658
"ava": {
5759
"timeout":"1m",
@@ -64,9 +66,7 @@
6466
},
6567
"xo": {
6668
"rules": {
67-
"@typescript-eslint/member-ordering":"off",
68-
"@typescript-eslint/no-var-requires":"off",
69-
"@typescript-eslint/no-empty-function":"off"
69+
"@typescript-eslint/no-unsafe-return":"off"
7070
}
7171
}
7272
}

‎readme.md‎

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ If you want to memoize Promise-returning functions (like `async` functions), you
1212

1313
##Install
1414

15-
```
16-
$npm install mem
15+
```sh
16+
npm install mem
1717
```
1818

1919
##Usage
@@ -164,7 +164,7 @@ Better yet, if your function’s arguments are compatible with `WeakMap`, you sh
164164

165165
Type:`Function`
166166

167-
Function to be memoized.
167+
The function to be memoized.
168168

169169
####options
170170

@@ -273,15 +273,3 @@ console.log(cache.stats);
273273
##Related
274274

275275
-[p-memoize](https://github.com/sindresorhus/p-memoize) - Memoize promise-returning & async functions
276-
277-
---
278-
279-
<divalign="center">
280-
<b>
281-
<a href="https://tidelift.com/subscription/pkg/npm-mem?utm_source=npm-mem&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
282-
</b>
283-
<br>
284-
<sub>
285-
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
286-
</sub>
287-
</div>

‎test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ test('promise support', async t => {
162162
});
163163

164164
test('preserves the original function name',t=>{
165-
t.is(mem(functionfoo(){}).name,'foo');// eslint-disable-line func-names
165+
t.is(mem(functionfoo(){}).name,'foo');// eslint-disable-line func-names, @typescript-eslint/no-empty-function
166166
});
167167

168168
test('.clear()',t=>{
@@ -220,7 +220,7 @@ test('.decorator()', t => {
220220

221221
test('memClear() throws when called with a plain function',t=>{
222222
t.throws(()=>{
223-
memClear(()=>{});
223+
memClear(()=>{});// eslint-disable-line @typescript-eslint/no-empty-function
224224
},{
225225
message:'Can\'t clear a function that was not memoized!',
226226
instanceOf:TypeError,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp