UNPKG

1.5 kBSource Map (JSON)View Raw
1{"version":3,"file":"before.js","sourceRoot":"","sources":["src/before.ts"],"names":[],"mappings":";;AAAA,sCAAyC;AAEzC,qCAA+E;AAC/E,6CAAoD;AAEpD,IAAM,SAAS,GAAG,0BAAgB,CAAC,uBAAuB,CACxD,IAAI,yBAAe,CAAC,MAAM,EAAE,IAAI,iCAAmB,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CACzE,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,gBAAuB,CAAS;IAC9B,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AACtB,CAAC;AAFD,wBAEC;AACkB,wBAAM;AACzB,kBAAe,SAAS,CAAC","sourcesContent":["import before = require('lodash/before');\n\nimport { DecoratorConfig, DecoratorFactory, LodashDecorator } from './factory';\nimport { PostValueApplicator } from './applicators';\n\nconst decorator = DecoratorFactory.createInstanceDecorator(\n new DecoratorConfig(before, new PostValueApplicator(), { setter: true })\n);\n\n/**\n * Creates a function that invokes func, with the this binding and arguments of the created function, while it's called less than n times.\n * Subsequent calls to the created function return the result of the last func invocation.\n * @param {number} n The number of calls at whichc func is no longer invoked.\n * @example\n *\n * let calls = 0;\n *\n * class MyClass {\n * @Before(3)\n * fn() {\n * calls++;\n * }\n * }\n *\n * const myClass = new MyClass();\n *\n * myClass.fn();\n * myClass.fn();\n * myClass.fn();\n * myClass.fn();\n *\n * calls === 2; // => true\n */\nexport function Before(n: number): LodashDecorator {\n return decorator(n);\n}\nexport { Before as before };\nexport default decorator;\n"]}
\No newline at end of file