UNPKG

1.26 kBSource Map (JSON)View Raw
1{"version":3,"file":"onceAll.js","sourceRoot":"","sources":["src/onceAll.ts"],"names":[],"mappings":";;AAAA,kCAAqC;AAErC,qCAAgF;AAChF,6CAAmD;AAEnD;;;;;;;;;;;;;;;;;;GAkBG;AACU,QAAA,OAAO,GAAG,0BAAgB,CAAC,eAAe,CACrD,IAAI,yBAAe,CAAC,IAAI,EAAE,IAAI,gCAAkB,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,CAAC,CACxE,CAAC;AACF,kBAHP,eAAO,CAGO;AAC3B,kBAAe,eAAO,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 * This is shared across all instances of the class.\n * @example\n * const value = 0;\n *\n * class MyClass {\n * @Once()\n * fn(): number {\n * return ++value;\n * }\n * }\n *\n * const myClass = new MyClass();\n * const myClass2 = new MyClass();\n *\n * myClass.fn(); //=> 1\n * myClass2.fn(); //=> 1\n */\nexport const OnceAll = DecoratorFactory.createDecorator(\n new DecoratorConfig(once, new PreValueApplicator(), { setter: true, optionalParams: true })\n) as BiTypedDecorator;\nexport { OnceAll as onceAll };\nexport default OnceAll;\n"]}
\No newline at end of file