Skip to content

Commit

Permalink
Meta tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Oct 10, 2020
1 parent 3d5698e commit 1b7b5a5
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
language: node_js
node_js:
- '14'
- '12'
- '10'
6 changes: 3 additions & 3 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import mimicFn = require('mimic-fn');
import mapAgeCleaner = require('map-age-cleaner');

type AnyFunction = (...args: any) => any;
type AnyFunction = (...arguments_: any) => any;

const cacheStore = new WeakMap<AnyFunction>();

Expand Down Expand Up @@ -55,7 +55,7 @@ interface Options<
@default arguments_ => arguments_[0]
@example arguments_ => JSON.stringify(arguments_)
*/
readonly cacheKey?: (args: Parameters<FunctionToMemoize>) => CacheKeyType;
readonly cacheKey?: (arguments_: Parameters<FunctionToMemoize>) => CacheKeyType;

/**
Use a different cache storage. Must implement the following methods: `.has(key)`, `.get(key)`, `.set(key, value)`, `.delete(key)`, and optionally `.clear()`. You could for example use a `WeakMap` instead or [`quick-lru`](https://github.com/sindresorhus/quick-lru) for a LRU cache.
Expand Down Expand Up @@ -106,7 +106,7 @@ const mem = <
}: Options<FunctionToMemoize, CacheKeyType> = {}
): FunctionToMemoize => {
if (typeof maxAge === 'number') {
// TODO: drop after https://github.com/SamVerschueren/map-age-cleaner/issues/5
// TODO: Drop after https://github.com/SamVerschueren/map-age-cleaner/issues/5
// @ts-expect-error
mapAgeCleaner(cache);
}
Expand Down
2 changes: 1 addition & 1 deletion license
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@
],
"dependencies": {
"map-age-cleaner": "^0.1.3",
"mimic-fn": "^3.0.0"
"mimic-fn": "^3.1.0"
},
"devDependencies": {
"@ava/typescript": "^1.1.1",
"@sindresorhus/tsconfig": "^0.7.0",
"@types/serialize-javascript": "^4.0.0",
"ava": "^3.13.0",
"del-cli": "^3.0.1",
"delay": "^4.1.0",
"delay": "^4.4.0",
"serialize-javascript": "^5.0.1",
"tsd": "^0.13.1",
"typescript": "^4.0.3",
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# mem [![Build Status](https://travis-ci.org/sindresorhus/mem.svg?branch=master)](https://travis-ci.org/sindresorhus/mem)
# mem [![Build Status](https://travis-ci.com/sindresorhus/mem.svg?branch=master)](https://travis-ci.com/github/sindresorhus/mem)

> [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
Expand Down
6 changes: 3 additions & 3 deletions test-d/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ expectType<false>(mem(overloadedFn)(false));

mem.clear(fn);

// CacheKey tests.
// `cacheKey` tests.
// The argument should match the memoized function’s parameters
mem((text: string) => Boolean(text), {
cacheKey: arguments_ => {
Expand All @@ -45,8 +45,8 @@ mem(() => 1, {
}
});

// Ensures that the various cache functions infer their arguments type from the return type of cacheKey()
mem((_args: {key: string}) => 1, {
// Ensures that the various cache functions infer their arguments type from the return type of `cacheKey`
mem((_arguments: {key: string}) => 1, {
cacheKey: (arguments_: [{key: string}]) => {
expectType<[{key: string}]>(arguments_);
return new Date();
Expand Down

0 comments on commit 1b7b5a5

Please sign in to comment.