File tree Expand file tree Collapse file tree 8 files changed +29
-27
lines changed Expand file tree Collapse file tree 8 files changed +29
-27
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @emotion/weak-memoize ' : minor
3
+ ---
4
+
5
+ Source code has been migrated to TypeScript. From now on type declarations will be emitted based on that, instead of being hand-written.
Original file line number Diff line number Diff line change 18
18
},
19
19
"files" : [
20
20
" src" ,
21
- " dist" ,
22
- " types/*.d.ts"
21
+ " dist"
23
22
],
24
23
"browser" : {
25
24
"./dist/emotion-memoize.cjs.js" : " ./dist/emotion-memoize.browser.cjs.js" ,
Original file line number Diff line number Diff line change 4
4
"description" : " A memoization function that uses a WeakMap" ,
5
5
"main" : " dist/emotion-weak-memoize.cjs.js" ,
6
6
"module" : " dist/emotion-weak-memoize.esm.js" ,
7
- "types" : " types /index.d.ts" ,
7
+ "types" : " dist/declarations/src /index.d.ts" ,
8
8
"license" : " MIT" ,
9
9
"repository" : " https://github.com/emotion-js/emotion/tree/main/packages/weak-memoize" ,
10
10
"scripts" : {
18
18
},
19
19
"files" : [
20
20
" src" ,
21
- " dist" ,
22
- " types/*.d.ts"
21
+ " dist"
23
22
],
24
23
"browser" : {
25
24
"./dist/emotion-weak-memoize.cjs.js" : " ./dist/emotion-weak-memoize.browser.cjs.js" ,
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ let weakMemoize = function < Arg extends object , Return > (
2
+ func : ( arg : Arg ) => Return
3
+ ) : ( arg : Arg ) => Return {
4
+ let cache = new WeakMap < Arg , Return > ( )
5
+ return ( arg : Arg ) => {
6
+ if ( cache . has ( arg ) ) {
7
+ // Use non-null assertion because we just checked that the cache `has` it
8
+ // This allows us to remove `undefined` from the return value
9
+ return cache . get ( arg ) !
10
+ }
11
+ let ret = func ( arg )
12
+ cache . set ( arg , ret )
13
+ return ret
14
+ }
15
+ }
16
+
17
+ export default weakMemoize
Original file line number Diff line number Diff line change 1
1
// TypeScript Version: 2.2
2
2
3
- type UnaryFn < Arg , Return > = ( arg : Arg ) => Return
4
-
5
- export default function weakMemoize < Arg extends object , Return > (
6
- func : UnaryFn < Arg , Return >
7
- ) : UnaryFn < Arg , Return >
3
+ export { default } from '../src'
Original file line number Diff line number Diff line change 1
- import weakMemoize from '@emotion/weak-memoize '
1
+ import weakMemoize from '../src '
2
2
3
3
interface Foo {
4
4
bar : 'xyz'
Original file line number Diff line number Diff line change 18
18
],
19
19
20
20
"no-unnecessary-generics" : false ,
21
- "strict-export-declare-modifiers" : false
21
+ "strict-export-declare-modifiers" : false ,
22
+ "no-default-import" : false
22
23
}
23
24
}
You can’t perform that action at this time.
0 commit comments