From d0e0d4115a44df69a5c6976e342754944f5dabb2 Mon Sep 17 00:00:00 2001 From: Jay Phelps Date: Thu, 17 Mar 2016 18:44:18 -0700 Subject: [PATCH] v0.11.1 --- bower.json | 2 +- core-decorators.js | 40 +++++++++-------- core-decorators.min.js | 9 +++- lib/autobind.spec.js | 53 ----------------------- lib/core-decorators.js | 7 +++ lib/debounce.spec.js | 84 ------------------------------------ lib/deprecate.spec.js | 98 ------------------------------------------ lib/mixin.spec.js | 72 ------------------------------- lib/time.js | 35 ++++++++------- src/core-decorators.js | 7 +++ src/time.js | 30 ++++++------- 11 files changed, 78 insertions(+), 359 deletions(-) delete mode 100644 lib/autobind.spec.js delete mode 100644 lib/debounce.spec.js delete mode 100644 lib/deprecate.spec.js delete mode 100644 lib/mixin.spec.js diff --git a/bower.json b/bower.json index 7686d34..2fd0467 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "core-decorators.js", "description": "Library of ES2016 (ES7) JavaScript decorators inspired by languages that come with built-ins like @​override, @​deprecate, @​autobind, @​mixin and more! Works great with React/Angular/more!", - "version": "0.11.0", + "version": "0.11.1", "homepage": "https://github.com/jayphelps/core-decorators.js", "authors": [ "Jay Phelps " diff --git a/core-decorators.js b/core-decorators.js index 2ac4d97..9ce7afa 100644 --- a/core-decorators.js +++ b/core-decorators.js @@ -1,3 +1,10 @@ +/** + * core-decorators.js + * (c) 2016 Jay Phelps + * MIT Licensed + * https://github.com/jayphelps/core-decorators.js + * @license + */ (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;oc;c++)b[c]=arguments[c];return 0===b.length?function(){return l(arguments)}:l(b)}Object.defineProperty(c,"__esModule",{value:!0}),c["default"]=m;var e=a("./private/utils"),f=Object.defineProperty,h=void 0;b.exports=c["default"]},{"./private/utils":13}],2:[function(a,b,c){"use strict";function d(a){return a&&a.__esModule?a["default"]:a}Object.defineProperty(c,"__esModule",{value:!0});var e=a("./override");c.override=d(e);var f=a("./deprecate");c.deprecate=d(f),c.deprecated=d(f);var g=a("./suppress-warnings");c.suppressWarnings=d(g);var h=a("./memoize");c.memoize=d(h);var i=a("./autobind");c.autobind=d(i);var j=a("./readonly");c.readonly=d(j);var k=a("./enumerable");c.enumerable=d(k);var l=a("./nonenumerable");c.nonenumerable=d(l);var m=a("./nonconfigurable");c.nonconfigurable=d(m);var n=a("./debounce");c.debounce=d(n);var o=a("./throttle");c.throttle=d(o);var p=a("./decorate");c.decorate=d(p);var q=a("./mixin");c.mixin=d(q),c.mixins=d(q);var r=a("./lazy-initialize");c.lazyInitialize=d(r);var s=a("./time");c.time=d(s)},{"./autobind":1,"./debounce":3,"./decorate":4,"./deprecate":5,"./enumerable":6,"./lazy-initialize":7,"./memoize":8,"./mixin":9,"./nonconfigurable":10,"./nonenumerable":11,"./override":12,"./readonly":14,"./suppress-warnings":15,"./throttle":16,"./time":17}],3:[function(a,b,c){"use strict";function e(a,b){if(Array.isArray(a))return a;if(Symbol.iterator in Object(a)){var c=[],d=!0,e=!1,f=void 0;try{for(var h,g=a[Symbol.iterator]();!(d=(h=g.next()).done)&&(c.push(h.value),!b||c.length!==b);d=!0);}catch(i){e=!0,f=i}finally{try{!d&&g["return"]&&g["return"]()}finally{if(e)throw f}}return c}throw new TypeError("Invalid attempt to destructure non-iterable instance")}function h(a,b,c,h){var i=e(h,2),j=i[0],k=void 0===j?g:j,l=i[1],m=void 0===l?!1:l,n=c.value;if("function"!=typeof n)throw new SyntaxError("Only functions can be debounced");return d({},c,{value:function(){var a=this,c=f.metaFor(this),d=c.debounceTimeoutIds,e=d[b],g=m&&!e,h=arguments;clearTimeout(e),d[b]=setTimeout(function(){delete d[b],m||n.apply(a,h)},k),g&&n.apply(this,h)}})}function i(){for(var a=arguments.length,b=Array(a),c=0;a>c;c++)b[c]=arguments[c];return f.decorate(h,b)}Object.defineProperty(c,"__esModule",{value:!0});var d=Object.assign||function(a){for(var b=1;bc;c++)b[c]=arguments[c];return f.decorate(g,b)}Object.defineProperty(c,"__esModule",{value:!0}),c["default"]=h;var f=a("./private/utils");b.exports=c["default"]},{"./private/utils":13}],5:[function(a,b,c){"use strict";function e(a,b){if(Array.isArray(a))return a;if(Symbol.iterator in Object(a)){var c=[],d=!0,e=!1,f=void 0;try{for(var h,g=a[Symbol.iterator]();!(d=(h=g.next()).done)&&(c.push(h.value),!b||c.length!==b);d=!0);}catch(i){e=!0,f=i}finally{try{!d&&g["return"]&&g["return"]()}finally{if(e)throw f}}return c}throw new TypeError("Invalid attempt to destructure non-iterable instance")}function h(a,b,c,f){var h=e(f,2),i=h[0],j=void 0===i?g:i,k=h[1],l=void 0===k?{}:k;if("function"!=typeof c.value)throw new SyntaxError("Only functions can be marked as deprecated");var m=""+a.constructor.name+"#"+b;return l.url&&(j+="\n\n See "+l.url+" for more details.\n\n"),d({},c,{value:function(){return console.warn("DEPRECATION "+m+": "+j),c.value.apply(this,arguments)}})}function i(){for(var a=arguments.length,b=Array(a),c=0;a>c;c++)b[c]=arguments[c];return f.decorate(h,b)}Object.defineProperty(c,"__esModule",{value:!0});var d=Object.assign||function(a){for(var b=1;bc;c++)b[c]=arguments[c];return d.decorate(e,b)}Object.defineProperty(c,"__esModule",{value:!0}),c["default"]=f;var d=a("./private/utils");b.exports=c["default"]},{"./private/utils":13}],7:[function(a,b,c){"use strict";function e(a,b,c){var e=c.configurable,f=c.enumerable,g=c.initializer,h=c.value;return{configurable:e,enumerable:f,get:function(){if(this!==a){var c=g?g.call(this):h;return Object.defineProperty(this,b,{configurable:e,enumerable:f,writable:!0,value:c}),c}},set:d.createDefaultSetter(b)}}function f(){for(var a=arguments.length,b=Array(a),c=0;a>c;c++)b[c]=arguments[c];return d.decorate(e,b)}Object.defineProperty(c,"__esModule",{value:!0}),c["default"]=f;var d=a("./private/utils");b.exports=c["default"]},{"./private/utils":13}],8:[function(a,b,c){"use strict";function e(a,b,c){return Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0})}function g(a,b){return b===Object(b)?b:a[b]||(a[b]={})}function h(a,b,c,d,e){var f=b.apply(a,c);return d[e]=f,f}function i(a){var b=void 0,c=void 0;return a.value?(b=a.value,c="value"):a.get?(b=a.get,c="get"):a.set&&(b=a.set,c="set"),{fn:b,wrapKey:c}}function j(a,b,c){console.warn("DEPRECATION: @memoize is deprecated and will be removed shortly. Use @decorate with lodash's memoize helper.\n\n https://github.com/jayphelps/core-decorators.js#decorate");var f=i(c),j=f.fn,k=f.wrapKey,l=new WeakMap,m=Object.create(null),n=Object.create(null),o=0;return d({},c,e({},k,function(){for(var a=arguments.length,b=Array(a),c=0;a>c;c++)b[c]=arguments[c];for(var d="0",e=0,f=b.length;f>e;e++){var i=b[e],k=g(n,i),p=l.get(k);void 0===p&&(p=++o,l.set(k,p)),d+=p}return m[d]||h(this,j,arguments,m,d)}))}function k(){for(var a=arguments.length,b=Array(a),c=0;a>c;c++)b[c]=arguments[c];return f.decorate(j,b)}Object.defineProperty(c,"__esModule",{value:!0});var d=Object.assign||function(a){for(var b=1;bc;c++){var g=d.getOwnPropertyDescriptors(b[c]);for(var h in g)h in a.prototype||e(a.prototype,h,g[h])}}function g(){for(var a=arguments.length,b=Array(a),c=0;a>c;c++)b[c]=arguments[c];return"function"==typeof b[0]?f(b[0],[]):function(a){return f(a,b)}}Object.defineProperty(c,"__esModule",{value:!0}),c["default"]=g;var d=a("./private/utils"),e=Object.defineProperty;b.exports=c["default"]},{"./private/utils":13}],10:[function(a,b,c){"use strict";function e(a,b,c){return c.configurable=!1,c}function f(){for(var a=arguments.length,b=Array(a),c=0;a>c;c++)b[c]=arguments[c];return d.decorate(e,b)}Object.defineProperty(c,"__esModule",{value:!0}),c["default"]=f;var d=a("./private/utils");b.exports=c["default"]},{"./private/utils":13}],11:[function(a,b,c){"use strict";function e(a,b,c){return c.enumerable=!1,c}function f(){for(var a=arguments.length,b=Array(a),c=0;a>c;c++)b[c]=arguments[c];return d.decorate(e,b)}Object.defineProperty(c,"__esModule",{value:!0}),c["default"]=f;var d=a("./private/utils");b.exports=c["default"]},{"./private/utils":13}],12:[function(a,b,c){"use strict";function e(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function j(a){return a.hasOwnProperty("value")?"data":a.hasOwnProperty("get")||a.hasOwnProperty("set")?"accessor":"data"}function k(a,b,c){c.assert(a.length===b.length)}function l(a,b,c){var d=typeof a.value,e=typeof b.value;if("undefined"===d&&"undefined"===e&&c.error("descriptor values are both undefined. (class properties are are not currently supported)'"),d!==e){var f="function"===e&&void 0===d;(f||void 0!==d)&&c.error('value types do not match. {parent} is "'+d+'", {child} is "'+e+'"')}switch(e){case"function":k(a.value,b.value,c);break;default:c.error('Unexpected error. Please file a bug with: {parent} is "'+d+'", {child} is "'+e+'"')}}function m(a,b,c){var d="function"==typeof a.get,e="function"==typeof b.get,f="function"==typeof a.set,g="function"==typeof b.set;(d||e)&&(!d&&f&&c.error("{parent} is setter but {child} is getter"),!e&&g&&c.error("{parent} is getter but {child} is setter"),k(a.get,b.get,c)),(f||g)&&(!f&&d&&c.error("{parent} is getter but {child} is setter"),!g&&e&&c.error("{parent} is setter but {child} is getter"),k(a.set,b.set,c))}function n(a,b,c){var d=j(a),e=j(b);switch(d!==e&&c.error('descriptor types do not match. {parent} is "'+d+'", {child} is "'+e+'"'),e){case"data":l(a,b,c);break;case"accessor":m(a,b,c)}}function p(a,b){var c=!0,d=!1,e=void 0;try{for(var g,f=o[Symbol.iterator]();!(c=(g=f.next()).done);c=!0){var h=g.value,i=h(b);if(i in a)return i}}catch(j){d=!0,e=j}finally{try{!c&&f["return"]&&f["return"]()}finally{if(d)throw e}}return null}function q(a,b,c){c.key=b;var d=Object.getPrototypeOf(a),e=Object.getOwnPropertyDescriptor(d,b),f=new i(d,a,e,c);if(void 0===e){var g=p(d,b),h=g?'\n\n Did you mean "'+g+'"?':"";f.error("No descriptor matching {child} was found on the prototype chain."+h)}return n(e,c,f),c}function r(){for(var a=arguments.length,b=Array(a),c=0;a>c;c++)b[c]=arguments[c];return f.decorate(q,b)}Object.defineProperty(c,"__esModule",{value:!0});var d=function(){function a(a,b){for(var c=0;cc;c++)if(a.hasOwnProperty(b[c]))return!0;return!1}function q(a,b){return p(b[b.length-1])?a.apply(void 0,i(b).concat([[]])):function(){return a.apply(void 0,e.call(arguments).concat([b]))}}function t(a){return a.hasOwnProperty(s)===!1&&l(a,s,{value:new r}),a[s]}function v(a){var b={};return u(a).forEach(function(c){return b[c]=m(a,c)}),b}function w(a){return function(b){return Object.defineProperty(this,a,{configurable:!0,writable:!0,enumerable:!0,value:b}),b}}Object.defineProperty(c,"__esModule",{value:!0});var d=function(){function a(a,b,c){for(var d=0;dc;c++)b[c]=arguments[c];return d.decorate(e,b)}Object.defineProperty(c,"__esModule",{value:!0}),c["default"]=f;var d=a("./private/utils");b.exports=c["default"]},{"./private/utils":13}],15:[function(a,b,c){"use strict";function f(){}function g(a,b,c){var d=console.warn;console.warn=f;var e=b.apply(a,c);return console.warn=d,e}function h(a,b,c){return d({},c,{value:function(){return g(this,c.value,arguments)}})}function i(){for(var a=arguments.length,b=Array(a),c=0;a>c;c++)b[c]=arguments[c];return e.decorate(h,b)}Object.defineProperty(c,"__esModule",{value:!0});var d=Object.assign||function(a){for(var b=1;b=l?(clearTimeout(g),delete d[b],e[b]=i,n.apply(this,j)):g||m.trailing===!1||(d[b]=setTimeout(function(){e[b]=m.leading===!1?0:Date.now(),delete d[b],n.apply(a,j)},l))}})}function i(){for(var a=arguments.length,b=Array(a),c=0;a>c;c++)b[c]=arguments[c];return f.decorate(h,b)}Object.defineProperty(c,"__esModule",{value:!0});var d=Object.assign||function(a){for(var b=1;bc;c++)b[c]=arguments[c];return f.decorate(l,b)}Object.defineProperty(c,"__esModule",{value:!0});var d=Object.assign||function(a){for(var b=1;bt;t++)r[t]=arguments[t];return 0===r.length?function(){return s(arguments)}:s(r)}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=c;var l=e("./private/utils"),f=Object.defineProperty,p=void 0;r.exports=t["default"]},{"./private/utils":13}],2:[function(e,r,t){"use strict";function n(e){return e&&e.__esModule?e["default"]:e}Object.defineProperty(t,"__esModule",{value:!0});var a=e("./override");t.override=n(a);var o=e("./deprecate");t.deprecate=n(o),t.deprecated=n(o);var i=e("./suppress-warnings");t.suppressWarnings=n(i);var u=e("./memoize");t.memoize=n(u);var s=e("./autobind");t.autobind=n(s);var c=e("./readonly");t.readonly=n(c);var l=e("./enumerable");t.enumerable=n(l);var f=e("./nonenumerable");t.nonenumerable=n(f);var p=e("./nonconfigurable");t.nonconfigurable=n(p);var v=e("./debounce");t.debounce=n(v);var d=e("./throttle");t.throttle=n(d);var y=e("./decorate");t.decorate=n(y);var h=e("./mixin");t.mixin=n(h),t.mixins=n(h);var g=e("./lazy-initialize");t.lazyInitialize=n(g);var m=e("./time");t.time=n(m)},{"./autobind":1,"./debounce":3,"./decorate":4,"./deprecate":5,"./enumerable":6,"./lazy-initialize":7,"./memoize":8,"./mixin":9,"./nonconfigurable":10,"./nonenumerable":11,"./override":12,"./readonly":14,"./suppress-warnings":15,"./throttle":16,"./time":17}],3:[function(e,r,t){"use strict";function n(e,r){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e)){var t=[],n=!0,a=!1,o=void 0;try{for(var i,u=e[Symbol.iterator]();!(n=(i=u.next()).done)&&(t.push(i.value),!r||t.length!==r);n=!0);}catch(s){a=!0,o=s}finally{try{!n&&u["return"]&&u["return"]()}finally{if(a)throw o}}return t}throw new TypeError("Invalid attempt to destructure non-iterable instance")}function a(e,r,t,a){var o=n(a,2),c=o[0],l=void 0===c?s:c,f=o[1],p=void 0===f?!1:f,v=t.value;if("function"!=typeof v)throw new SyntaxError("Only functions can be debounced");return i({},t,{value:function(){var e=this,t=u.metaFor(this),n=t.debounceTimeoutIds,a=n[r],o=p&&!a,i=arguments;clearTimeout(a),n[r]=setTimeout(function(){delete n[r],p||v.apply(e,i)},l),o&&v.apply(this,i)}})}function o(){for(var e=arguments.length,r=Array(e),t=0;e>t;t++)r[t]=arguments[t];return u.decorate(a,r)}Object.defineProperty(t,"__esModule",{value:!0});var i=Object.assign||function(e){for(var r=1;rt;t++)r[t]=arguments[t];return u.decorate(o,r)}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=i;var u=e("./private/utils");r.exports=t["default"]},{"./private/utils":13}],5:[function(e,r,t){"use strict";function n(e,r){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e)){var t=[],n=!0,a=!1,o=void 0;try{for(var i,u=e[Symbol.iterator]();!(n=(i=u.next()).done)&&(t.push(i.value),!r||t.length!==r);n=!0);}catch(s){a=!0,o=s}finally{try{!n&&u["return"]&&u["return"]()}finally{if(a)throw o}}return t}throw new TypeError("Invalid attempt to destructure non-iterable instance")}function a(e,r,t,a){var o=n(a,2),u=o[0],c=void 0===u?s:u,l=o[1],f=void 0===l?{}:l;if("function"!=typeof t.value)throw new SyntaxError("Only functions can be marked as deprecated");var p=""+e.constructor.name+"#"+r;return f.url&&(c+="\n\n See "+f.url+" for more details.\n\n"),i({},t,{value:function(){return console.warn("DEPRECATION "+p+": "+c),t.value.apply(this,arguments)}})}function o(){for(var e=arguments.length,r=Array(e),t=0;e>t;t++)r[t]=arguments[t];return u.decorate(a,r)}Object.defineProperty(t,"__esModule",{value:!0});var i=Object.assign||function(e){for(var r=1;rt;t++)r[t]=arguments[t];return o.decorate(n,r)}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=a;var o=e("./private/utils");r.exports=t["default"]},{"./private/utils":13}],7:[function(e,r,t){"use strict";function n(e,r,t){var n=t.configurable,a=t.enumerable,i=t.initializer,u=t.value;return{configurable:n,enumerable:a,get:function(){if(this!==e){var t=i?i.call(this):u;return Object.defineProperty(this,r,{configurable:n,enumerable:a,writable:!0,value:t}),t}},set:o.createDefaultSetter(r)}}function a(){for(var e=arguments.length,r=Array(e),t=0;e>t;t++)r[t]=arguments[t];return o.decorate(n,r)}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=a;var o=e("./private/utils");r.exports=t["default"]},{"./private/utils":13}],8:[function(e,r,t){"use strict";function n(e,r,t){return Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0})}function a(e,r){return r===Object(r)?r:e[r]||(e[r]={})}function o(e,r,t,n,a){var o=r.apply(e,t);return n[a]=o,o}function i(e){var r=void 0,t=void 0;return e.value?(r=e.value,t="value"):e.get?(r=e.get,t="get"):e.set&&(r=e.set,t="set"),{fn:r,wrapKey:t}}function u(e,r,t){console.warn("DEPRECATION: @memoize is deprecated and will be removed shortly. Use @decorate with lodash's memoize helper.\n\n https://github.com/jayphelps/core-decorators.js#decorate");var u=i(t),s=u.fn,l=u.wrapKey,f=new WeakMap,p=Object.create(null),v=Object.create(null),d=0;return c({},t,n({},l,function(){for(var e=arguments.length,r=Array(e),t=0;e>t;t++)r[t]=arguments[t];for(var n="0",i=0,u=r.length;u>i;i++){var c=r[i],l=a(v,c),y=f.get(l);void 0===y&&(y=++d,f.set(l,y)),n+=y}return p[n]||o(this,s,arguments,p,n)}))}function s(){for(var e=arguments.length,r=Array(e),t=0;e>t;t++)r[t]=arguments[t];return l.decorate(u,r)}Object.defineProperty(t,"__esModule",{value:!0});var c=Object.assign||function(e){for(var r=1;rt;t++){var a=o.getOwnPropertyDescriptors(r[t]);for(var u in a)u in e.prototype||i(e.prototype,u,a[u])}}function a(){for(var e=arguments.length,r=Array(e),t=0;e>t;t++)r[t]=arguments[t];return"function"==typeof r[0]?n(r[0],[]):function(e){return n(e,r)}}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=a;var o=e("./private/utils"),i=Object.defineProperty;r.exports=t["default"]},{"./private/utils":13}],10:[function(e,r,t){"use strict";function n(e,r,t){return t.configurable=!1,t}function a(){for(var e=arguments.length,r=Array(e),t=0;e>t;t++)r[t]=arguments[t];return o.decorate(n,r)}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=a;var o=e("./private/utils");r.exports=t["default"]},{"./private/utils":13}],11:[function(e,r,t){"use strict";function n(e,r,t){return t.enumerable=!1,t}function a(){for(var e=arguments.length,r=Array(e),t=0;e>t;t++)r[t]=arguments[t];return o.decorate(n,r)}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=a;var o=e("./private/utils");r.exports=t["default"]},{"./private/utils":13}],12:[function(e,r,t){"use strict";function n(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function a(e){return e.hasOwnProperty("value")?"data":e.hasOwnProperty("get")||e.hasOwnProperty("set")?"accessor":"data"}function o(e,r,t){t.assert(e.length===r.length)}function i(e,r,t){var n=typeof e.value,a=typeof r.value;if("undefined"===n&&"undefined"===a&&t.error("descriptor values are both undefined. (class properties are are not currently supported)'"),n!==a){var i="function"===a&&void 0===n;(i||void 0!==n)&&t.error('value types do not match. {parent} is "'+n+'", {child} is "'+a+'"')}switch(a){case"function":o(e.value,r.value,t);break;default:t.error('Unexpected error. Please file a bug with: {parent} is "'+n+'", {child} is "'+a+'"')}}function u(e,r,t){var n="function"==typeof e.get,a="function"==typeof r.get,i="function"==typeof e.set,u="function"==typeof r.set;(n||a)&&(!n&&i&&t.error("{parent} is setter but {child} is getter"),!a&&u&&t.error("{parent} is getter but {child} is setter"),o(e.get,r.get,t)),(i||u)&&(!i&&n&&t.error("{parent} is getter but {child} is setter"),!u&&a&&t.error("{parent} is setter but {child} is getter"),o(e.set,r.set,t))}function s(e,r,t){var n=a(e),o=a(r);switch(n!==o&&t.error('descriptor types do not match. {parent} is "'+n+'", {child} is "'+o+'"'),o){case"data":i(e,r,t);break;case"accessor":u(e,r,t)}}function c(e,r){var t=!0,n=!1,a=void 0;try{for(var o,i=g[Symbol.iterator]();!(t=(o=i.next()).done);t=!0){var u=o.value,s=u(r);if(s in e)return s}}catch(c){n=!0,a=c}finally{try{!t&&i["return"]&&i["return"]()}finally{if(n)throw a}}return null}function l(e,r,t){t.key=r;var n=Object.getPrototypeOf(e),a=Object.getOwnPropertyDescriptor(n,r),o=new h(n,e,a,t);if(void 0===a){var i=c(n,r),u=i?'\n\n Did you mean "'+i+'"?':"";o.error("No descriptor matching {child} was found on the prototype chain."+u)}return s(a,t,o),t}function f(){for(var e=arguments.length,r=Array(e),t=0;e>t;t++)r[t]=arguments[t];return v.decorate(l,r)}Object.defineProperty(t,"__esModule",{value:!0});var p=function(){function e(e,r){for(var t=0;tt;t++)if(e.hasOwnProperty(r[t]))return!0;return!1}function s(e,r){return u(r[r.length-1])?e.apply(void 0,i(r).concat([[]])):function(){return e.apply(void 0,v.call(arguments).concat([r]))}}function c(e){return e.hasOwnProperty(O)===!1&&h(e,O,{value:new w}),e[O]}function l(e){var r={};return j(e).forEach(function(t){return r[t]=g(e,t)}),r}function f(e){return function(r){return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:r}),r}}Object.defineProperty(t,"__esModule",{value:!0});var p=function(){function e(e,r,t){for(var n=0;nt;t++)r[t]=arguments[t];return o.decorate(n,r)}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=a;var o=e("./private/utils");r.exports=t["default"]},{"./private/utils":13}],15:[function(e,r,t){"use strict";function n(){}function a(e,r,t){var a=console.warn;console.warn=n;var o=r.apply(e,t);return console.warn=a,o}function o(e,r,t){return u({},t,{value:function(){return a(this,t.value,arguments)}})}function i(){for(var e=arguments.length,r=Array(e),t=0;e>t;t++)r[t]=arguments[t];return s.decorate(o,r)}Object.defineProperty(t,"__esModule",{value:!0});var u=Object.assign||function(e){for(var r=1;r0?o||p.trailing===!1||(n[r]=setTimeout(function(){a[r]=p.leading===!1?0:Date.now(),delete n[r],v.apply(e,c)},f)):(clearTimeout(o),delete n[r],a[r]=s,v.apply(this,c))}})}function o(){for(var e=arguments.length,r=Array(e),t=0;e>t;t++)r[t]=arguments[t];return u.decorate(a,r)}Object.defineProperty(t,"__esModule",{value:!0});var i=Object.assign||function(e){for(var r=1;rt;t++)r[t]=arguments[t];return u.decorate(a,r)}Object.defineProperty(t,"__esModule",{value:!0});var i=Object.assign||function(e){for(var r=1;r { - labels[label] = new Date(); -}; -const CONSOLE_TIMEEND = console.timeEnd ? console.timeEnd.bind(console) : label => { - const timeNow = new Date(); - const timeTaken = timeNow - labels[label]; - console.log(`${label}: ${timeTaken}ms`); + +// Exported for mocking in tests +export const defaultConsole = { + time: console.time ? console.time.bind(console) : label => { + labels[label] = new Date(); + }, + timeEnd: console.timeEnd ? console.timeEnd.bind(console) : label => { + const timeNow = new Date(); + const timeTaken = timeNow - labels[label]; + delete labels[label]; + console.log(`${label}: ${timeTaken}ms`); + } }; let count = 0; -function handleDescriptor(target, key, descriptor, [prefix = null, konsole = null]) { +function handleDescriptor(target, key, descriptor, [prefix = null, console = defaultConsole]) { const fn = descriptor.value; - const CONSOLE = konsole || CONSOLE_NATIVE; if (prefix === null) { prefix = `${target.constructor.name}.${key}`; @@ -29,16 +31,14 @@ function handleDescriptor(target, key, descriptor, [prefix = null, konsole = nul return { ...descriptor, value() { - const time = CONSOLE.time || CONSOLE_TIME; - const timeEnd = CONSOLE.timeEnd || CONSOLE_TIMEEND; const label = `${prefix}-${count}`; count++; - time(label); + console.time(label); try { return fn.apply(this, arguments); } finally { - timeEnd(label); + console.timeEnd(label); } } }