Appearance
memDecorator
▸ memDecorator(options?): (target: any, propertyKey: any, descriptor: any) => void
参数
| Name | Type |
|---|---|
options | Object |
返回值
fn
A decorator to memoize class methods or static class methods.
▸ (target, propertyKey, descriptor): void
参数
| Name | Type |
|---|---|
target | any |
propertyKey | any |
descriptor | any |
返回值
void
示例
import {memDecorator} from 'mem';
class Example {
index = 0
@memDecorator()
counter() {
return ++this.index;
}
}
class ExampleWithOptions {
index = 0
@memDecorator({maxAge: 1000})
counter() {
return ++this.index;
}
}