gpt4 book ai didi

javascript - 哪些内存库可用于 Javascript?

转载 作者:行者123 更新时间:2023-12-04 16:27:10 31 4
gpt4 key购买 nike

关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。












我们不允许提出有关书籍、工具、软件库等建议的问题。您可以编辑问题,以便可以用事实和引用来回答它。


2年前关闭。







Improve this question




有许多 Javascript 库用于内存函数。

对于各种用例,哪些是最好的(高质量、灵活、快速等)?

最佳答案

我发现有有许多不同的 JavaScript 内存库,它们的运行方式都略有不同。
我将尝试在这里列出和比较“最佳”的。 (大致按照我估计它们的有效性/通用性来排序;或者更确切地说,这就是我有时间进一步查看它们的计划!)
核心功能 :(标有✔️yes、❌no、⚙️partial、❔unknown)

npm) Install from NPM: The package is available on npm. (for easy integration/updating)
m-arg) Multiple arguments: Can memoize functions that are passed multiple arguments.
o-arg) Object arguments: Can memoize functions that are passed object arguments.
o-hash) Object hashing: Can memoize using the internal JS hashing for object arguments, through use of Map/WeakMap. (better perf than serialization or cache-entry iteration)
m-slot) Multiple slots: Can store cached results for more than just the last set of arguments. (without requiring manual creation of new "cache slots" / "instantiations")
auto) Auto-memoize: Can memoize based on the regular passed arguments; does not require function-specific setup/wrapping for basic memoization. (may still require a generic wrapping)


对于同步函数
moize (基于 micro-memoize )

Core features) npm: ✔️, m-arg: ✔️, o-arg: ✔️, o-hash: ❌, m-slot: ✔️, auto: ✔️
Popularity) GitHub stars: ~550; NPM weekly downloads: ~76k (2020-04-24)


memoizee

Core features) npm: ✔️, m-arg: ✔️, o-arg: ✔️, o-hash: ⚙️, m-slot: ✔️, auto: ✔️
Popularity) GitHub stars: ~1.1k; NPM weekly downloads: ~1.9m (2020-04-24)


mobx-utils:computedFn

Core features) npm: ✔️, m-arg: ✔️, o-arg: ✔️, o-hash: ✔️, m-slot: ✔️, auto: ✔️
Popularity) GitHub stars: ~850; NPM weekly downloads: ~60k (2020-04-24)


fast-memoize

Core features) npm: ✔️, m-arg: ✔️, o-arg: ✔️, o-hash: ❌, m-slot: ✔️, auto: ✔️
Popularity) GitHub stars: ~2.2k; NPM weekly downloads: ~381k (2020-04-24)


map-memo

Core features) npm: ✔️, m-arg: ✔️, o-arg: ✔️, o-hash: ✔️, m-slot: ✔️, auto: ✔️


lodash.memoize ( code)

Core features) npm: ✔️, m-arg: ❌, o-arg: ✔️, o-hash: ✔️, m-slot: ✔️, auto: ✔️


memoize-weak

Core features) npm: ✔️, m-arg: ✔️, o-arg: ✔️, o-hash: ✔️, m-slot: ✔️, auto: ✔️


memoize-immutable

Core features) npm: ✔️, m-arg: ✔️, o-arg: ✔️, o-hash: ✔️, m-slot: ✔️, auto: ✔️


underscore.memoize ( code)

Core features) npm: ✔️, m-arg: ❌, o-arg: ✔️, o-hash: ❌, m-slot: ✔️, auto: ✔️


memoize-state

Core features) npm: ❔, m-arg: ❔, o-arg: ❔, o-hash: ❔, m-slot: ❔, auto: ❔


kashe

Core features) npm: ❔, m-arg: ❔, o-arg: ❔, o-hash: ❔, m-slot: ❔, auto: ❔


nano-memoize

Core features) npm: ❔, m-arg: ❔, o-arg: ❔, o-hash: ❔, m-slot: ❔, auto: ❔


memoizerific

Core features) npm: ❔, m-arg: ❔, o-arg: ❔, o-hash: ❔, m-slot: ❔, auto: ❔


memoize-fn

Core features) npm: ❔, m-arg: ❔, o-arg: ❔, o-hash: ❔, m-slot: ❔, auto: ❔


memoize-cache

Core features) npm: ❔, m-arg: ❔, o-arg: ❔, o-hash: ❔, m-slot: ❔, auto: ❔


memoize-one

Core features) npm: ✔️, m-arg: ❔, o-arg: ❔, o-hash: ❔, m-slot: ❌, auto: ❔


use-memo-one

Core features) npm: ❔, m-arg: ❔, o-arg: ❔, o-hash: ❔, m-slot: ❌, auto: ❔


@emotion/weak-memoize

Core features) npm: ❔, m-arg: ❔, o-arg: ❔, o-hash: ❔, m-slot: ❔, auto: ❔


lru-memoizer

Core features) npm: ❔, m-arg: ❔, o-arg: ❔, o-hash: ❔, m-slot: ❔, auto: ❔


mem

Core features) npm: ❔, m-arg: ❔, o-arg: ❔, o-hash: ❔, m-slot: ❔, auto: ❔


memoizejs

Core features) npm: ❔, m-arg: ❔, o-arg: ❔, o-hash: ❔, m-slot: ❔, auto: ❔


memize

Core features) npm: ❔, m-arg: ❔, o-arg: ❔, o-hash: ❔, m-slot: ❔, auto: ❔


reselect

Core features) npm: ❔, m-arg: ❔, o-arg: ❔, o-hash: ❔, m-slot: ❔, auto: ❌


rememo

Core features) npm: ❔, m-arg: ❔, o-arg: ❔, o-hash: ❔, m-slot: ❔, auto: ❌


memoize-bind

Core features) npm: ❔, m-arg: ❔, o-arg: ❔, o-hash: ❔, m-slot: ❔, auto: ❔


memoizesync

Core features) npm: ❔, m-arg: ❔, o-arg: ❔, o-hash: ❔, m-slot: ❔, auto: ❔


@thi.ng/memoize

Core features) npm: ❔, m-arg: ❔, o-arg: ❔, o-hash: ❔, m-slot: ❔, auto: ❔


trie-memoize

Core features) npm: ❔, m-arg: ❔, o-arg: ❔, o-hash: ❔, m-slot: ❔, auto: ❔


memobind

Core features) npm: ❔, m-arg: ❔, o-arg: ❔, o-hash: ❔, m-slot: ❔, auto: ❔


memoize-id

Core features) npm: ❔, m-arg: ❔, o-arg: ❔, o-hash: ❔, m-slot: ❔, auto: ❔


@bigcommerce/memoize

Core features) npm: ❔, m-arg: ❔, o-arg: ❔, o-hash: ❔, m-slot: ❔, auto: ❔


对于异步函数
mobx-utils:computedFn

[see entry above in synchronous category]


p-memoize

Core features) npm: ❔, m-arg: ❔, o-arg: ❔, o-hash: ❔, m-slot: ❔, auto: ❔


node-memoizeasync

Core features) npm: ❔, m-arg: ❔, o-arg: ❔, o-hash: ❔, m-slot: ❔, auto: ❔


promise-memoize

Core features) npm: ❔, m-arg: ❔, o-arg: ❔, o-hash: ❔, m-slot: ❔, auto: ❔


use-async-memo

Core features) npm: ❔, m-arg: ❔, o-arg: ❔, o-hash: ❔, m-slot: ❔, auto: ❔


async-memo-ize

Core features) npm: ❔, m-arg: ❔, o-arg: ❔, o-hash: ❔, m-slot: ❔, auto: ❔


memoize-async

Core features) npm: ❔, m-arg: ❔, o-arg: ❔, o-hash: ❔, m-slot: ❔, auto: ❔


讨论
实际上有比这更多的 JS memoization 库(我知道......),但我忽略了库中的那些:
  • 无法在内存中内存。 (例如,仅基于文件的缓存)
  • 无法内存独立功能。 (例如,仅限类方法)
  • 不是开源的,或者托管在某个疯狂的地方like this XD。
  • 超出了结果的前几页。 (一个人只能在这上面投入这么多时间......)
  • 关于javascript - 哪些内存库可用于 Javascript?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61402804/

    31 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com