proposal-function-memo icon indicating copy to clipboard operation
proposal-function-memo copied to clipboard

Prototype method, static method, decorator

Open js-choi opened this issue 3 years ago • 3 comments

Should memo be a prototype method, a static function, a function decorator, or multiple?

This depends most on whether memo will be mostly used on anonymous functions, named function declarations, and/or class methods.

.bind is a prototype method.

Underscore and Lodash (necessarily) use static functions.

Python’s lru_cache is a decorator, although we don’t have function decorators yet.

js-choi avatar Mar 30 '22 16:03 js-choi

I'm strictly for a prototype method for .bind consistency and simplicity of usage.

zloirock avatar Mar 30 '22 16:03 zloirock

I would also prefer a prototype method

nektro avatar May 04 '24 06:05 nektro