UNPKG
@cran/vue.use
Version:
latest (0.0.2)
0.0.2
0.0.1
Cranberry Vue Use Utilities
c6s.gitlab.io/lib/vue/use/modules.html
@cran/vue.use
/
mjs
/
utility
/
createUseFactory.js
11 lines
(10 loc)
•
336 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
/* eslint-disable @typescript-eslint/no-explicit-any */
export
function
createUseFactory
(
name, factory, cacheKey
) {
const
cache = {};
return
({ [name](key, ...rest) {
const
str = cacheKey?.(key) || (
`
${key}
`
);
return
cache[str] || (cache[str] =
factory
(key, ...rest)); }, })[name]; }