UNPKG

1.19 kBSource Map (JSON)View Raw
1{"version":3,"file":"once.js","sourceRoot":"","sources":["src/once.ts"],"names":[],"mappings":";;AAAA,kCAAqC;AAErC,qCAAgF;AAChF,6CAAmD;AAEnD;;;;;;;;;;;;;;;;;GAiBG;AACU,QAAA,IAAI,GAAG,0BAAgB,CAAC,uBAAuB,CAC1D,IAAI,yBAAe,CAAC,IAAI,EAAE,IAAI,gCAAkB,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,CACxE,CAAC;AACL,eAHJ,YAAI,CAGI;AACrB,kBAAe,YAAI,CAAC","sourcesContent":["import once = require('lodash/once');\n\nimport { DecoratorConfig, DecoratorFactory, BiTypedDecorator } from './factory';\nimport { PreValueApplicator } from './applicators';\n\n/**\n * Creates a function that is restricted to invoking func once. Repeat calls to the function return the value of the first invocation.\n * @example\n * class MyClass {\n * value: number = 0;\n *\n * @Once()\n * fn(): number {\n * return ++this.value;\n * }\n * }\n *\n * const myClass = new MyClass();\n *\n * myClass.fn(); //=> 1\n * myClass.fn(); //=> 1\n * myClass.fn(); //=> 1\n */\nexport const Once = DecoratorFactory.createInstanceDecorator(\n new DecoratorConfig(once, new PreValueApplicator(), { setter: true, optionalParams: true })\n) as BiTypedDecorator;\nexport { Once as once };\nexport default Once;\n"]}
\No newline at end of file