@building-block/track-progress
Advanced tools
Comparing version 1.0.0-alpha.3 to 1.0.0-alpha.4
@@ -1,17 +0,22 @@ | ||
export declare const fromXHREvent: (xhrEvent: any) => { | ||
interface ProgressTrackerConfig { | ||
throttleWait: number; | ||
[key: string]: any; | ||
} | ||
interface CurrentProgress { | ||
total?: number; | ||
finished?: number; | ||
percent?: number; | ||
progress?: number; | ||
elapsed: number; | ||
remaining?: number; | ||
speed?: number; | ||
bitrate?: number; | ||
} | ||
interface TransferEvent { | ||
total: number; | ||
finished: number; | ||
computable: boolean; | ||
finished: number; | ||
total: number; | ||
}; | ||
export declare const createProgressTracker: ({ throttleWait, }?: { | ||
throttleWait: number; | ||
}) => (({ total, finished, computable, }: any) => { | ||
total: any; | ||
finished: any; | ||
percent: number | undefined; | ||
progress: number | undefined; | ||
elapsed: number | undefined; | ||
remaining: number | undefined; | ||
speed: number | undefined; | ||
bitrate: number | undefined; | ||
}) & import("lodash").Cancelable; | ||
} | ||
export declare const fromXHREvent: (xhrEvent: ProgressEvent) => TransferEvent; | ||
export declare const createProgressTracker: ({ throttleWait, }?: ProgressTrackerConfig) => (({ total, finished, computable, }: TransferEvent) => CurrentProgress) & import("lodash").Cancelable; | ||
export {}; |
@@ -1,2 +0,2 @@ | ||
"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},e=NaN,n="[object Symbol]",i=/^\s+|\s+$/g,o=/^[-+]0x[0-9a-f]+$/i,r=/^0b[01]+$/i,a=/^0o[0-7]+$/i,u=parseInt,f="object"==typeof t&&t&&t.Object===Object&&t,l="object"==typeof self&&self&&self.Object===Object&&self,c=f||l||Function("return this")(),d=Object.prototype.toString,s=Math.max,p=Math.min,v=function(){return c.Date.now()};function b(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function g(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&d.call(t)==n}(t))return e;if(b(t)){var f="function"==typeof t.valueOf?t.valueOf():t;t=b(f)?f+"":f}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(i,"");var l=r.test(t);return l||a.test(t)?u(t.slice(2),l?2:8):o.test(t)?e:+t}exports.fromXHREvent=function(t){return{computable:t.lengthComputable,finished:t.position||t.loaded,total:t.totalSize||t.total}},exports.createProgressTracker=function(t){void 0===t&&(t={throttleWait:250});var e,n,i,o,r=t.throttleWait,a=Date.now();return e=function(t){var e,n,i,o,r,u,f=t.total,l=t.finished,c=t.computable;return void 0===c&&(c=!0),c&&(e=Math.round(100*l/f),(r=(Date.now()-a)/1e3)>=1&&(n=l/r),f&&(i=Math.min(l,f)/f,n&&(u=n/8,o=0,e<100&&(o=f/n-r,o=Number(o.toFixed(4)))))),{total:f,finished:l,percent:e,progress:i,elapsed:r,remaining:o,speed:n,bitrate:u}},n=r,i=!0,o=!0,b(void 0)&&(i="leading"in void 0?!!(void 0).leading:i,o="trailing"in void 0?!!(void 0).trailing:o),function(t,e,n){var i,o,r,a,u,f,l=0,c=!1,d=!1,m=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function y(e){var n=i,r=o;return i=o=void 0,l=e,a=t.apply(r,n)}function h(t){var n=t-f;return void 0===f||n>=e||n<0||d&&t-l>=r}function j(){var t=v();if(h(t))return w(t);u=setTimeout(j,function(t){var n=e-(t-f);return d?p(n,r-(t-l)):n}(t))}function w(t){return u=void 0,m&&i?y(t):(i=o=void 0,a)}function x(){var t=v(),n=h(t);if(i=arguments,o=this,f=t,n){if(void 0===u)return function(t){return l=t,u=setTimeout(j,e),c?y(t):a}(f);if(d)return u=setTimeout(j,e),y(f)}return void 0===u&&(u=setTimeout(j,e)),a}return e=g(e)||0,b(n)&&(c=!!n.leading,r=(d="maxWait"in n)?s(g(n.maxWait)||0,e):r,m="trailing"in n?!!n.trailing:m),x.cancel=function(){void 0!==u&&clearTimeout(u),l=0,i=f=o=u=void 0},x.flush=function(){return void 0===u?a:w(v())},x}(e,n,{leading:i,maxWait:n,trailing:o})}; | ||
"use strict";var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},e=NaN,n="[object Symbol]",i=/^\s+|\s+$/g,o=/^[-+]0x[0-9a-f]+$/i,r=/^0b[01]+$/i,a=/^0o[0-7]+$/i,u=parseInt,f="object"==typeof t&&t&&t.Object===Object&&t,l="object"==typeof self&&self&&self.Object===Object&&self,c=f||l||Function("return this")(),d=Object.prototype.toString,s=Math.max,v=Math.min,p=function(){return c.Date.now()};function b(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function g(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&d.call(t)==n}(t))return e;if(b(t)){var f="function"==typeof t.valueOf?t.valueOf():t;t=b(f)?f+"":f}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(i,"");var l=r.test(t);return l||a.test(t)?u(t.slice(2),l?2:8):o.test(t)?e:+t}exports.fromXHREvent=function(t){return{computable:t.lengthComputable,finished:t.loaded,total:t.total}},exports.createProgressTracker=function(t){void 0===t&&(t={throttleWait:250});var e,n,i,o,r=t.throttleWait,a=Date.now();return e=function(t){var e,n,i,o,r,u,f=t.total,l=t.finished,c=t.computable;return void 0===c&&(c=f>0&&l>=0),e=(Date.now()-a)/1e3,c&&(n=Math.round(100*l/f),e>=1&&(i=l/e),f&&(o=Math.min(l,f)/f,i&&(u=i/8,r=0,n<100&&(r=f/i-e,r=Number(r.toFixed(4)))))),{total:f,finished:l,percent:n,progress:o,elapsed:e,remaining:r,speed:i,bitrate:u}},n=r,i=!0,o=!0,b(void 0)&&(i="leading"in void 0?!!(void 0).leading:i,o="trailing"in void 0?!!(void 0).trailing:o),function(t,e,n){var i,o,r,a,u,f,l=0,c=!1,d=!1,m=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function y(e){var n=i,r=o;return i=o=void 0,l=e,a=t.apply(r,n)}function h(t){var n=t-f;return void 0===f||n>=e||n<0||d&&t-l>=r}function j(){var t=p();if(h(t))return w(t);u=setTimeout(j,function(t){var n=e-(t-f);return d?v(n,r-(t-l)):n}(t))}function w(t){return u=void 0,m&&i?y(t):(i=o=void 0,a)}function x(){var t=p(),n=h(t);if(i=arguments,o=this,f=t,n){if(void 0===u)return function(t){return l=t,u=setTimeout(j,e),c?y(t):a}(f);if(d)return u=setTimeout(j,e),y(f)}return void 0===u&&(u=setTimeout(j,e)),a}return e=g(e)||0,b(n)&&(c=!!n.leading,r=(d="maxWait"in n)?s(g(n.maxWait)||0,e):r,m="trailing"in n?!!n.trailing:m),x.cancel=function(){void 0!==u&&clearTimeout(u),l=0,i=f=o=u=void 0},x.flush=function(){return void 0===u?a:w(p())},x}(e,n,{leading:i,maxWait:n,trailing:o})}; | ||
//# sourceMappingURL=trackProgress.js.map |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.trackProgress={})}(this,function(t){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=NaN,i="[object Symbol]",o=/^\s+|\s+$/g,r=/^[-+]0x[0-9a-f]+$/i,f=/^0b[01]+$/i,u=/^0o[0-7]+$/i,a=parseInt,c="object"==typeof e&&e&&e.Object===Object&&e,l="object"==typeof self&&self&&self.Object===Object&&self,d=c||l||Function("return this")(),s=Object.prototype.toString,p=Math.max,v=Math.min,b=function(){return d.Date.now()};function m(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function g(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&s.call(t)==i}(t))return n;if(m(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=m(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(o,"");var c=f.test(t);return c||u.test(t)?a(t.slice(2),c?2:8):r.test(t)?n:+t}t.fromXHREvent=function(t){return{computable:t.lengthComputable,finished:t.position||t.loaded,total:t.totalSize||t.total}},t.createProgressTracker=function(t){void 0===t&&(t={throttleWait:250});var e,n,i,o,r=t.throttleWait,f=Date.now();return e=function(t){var e,n,i,o,r,u,a=t.total,c=t.finished,l=t.computable;return void 0===l&&(l=!0),l&&(e=Math.round(100*c/a),(r=(Date.now()-f)/1e3)>=1&&(n=c/r),a&&(i=Math.min(c,a)/a,n&&(u=n/8,o=0,e<100&&(o=a/n-r,o=Number(o.toFixed(4)))))),{total:a,finished:c,percent:e,progress:i,elapsed:r,remaining:o,speed:n,bitrate:u}},n=r,i=!0,o=!0,m(void 0)&&(i="leading"in void 0?!!(void 0).leading:i,o="trailing"in void 0?!!(void 0).trailing:o),function(t,e,n){var i,o,r,f,u,a,c=0,l=!1,d=!1,s=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function y(e){var n=i,r=o;return i=o=void 0,c=e,f=t.apply(r,n)}function h(t){var n=t-a;return void 0===a||n>=e||n<0||d&&t-c>=r}function j(){var t=b();if(h(t))return x(t);u=setTimeout(j,function(t){var n=e-(t-a);return d?v(n,r-(t-c)):n}(t))}function x(t){return u=void 0,s&&i?y(t):(i=o=void 0,f)}function w(){var t=b(),n=h(t);if(i=arguments,o=this,a=t,n){if(void 0===u)return function(t){return c=t,u=setTimeout(j,e),l?y(t):f}(a);if(d)return u=setTimeout(j,e),y(a)}return void 0===u&&(u=setTimeout(j,e)),f}return e=g(e)||0,m(n)&&(l=!!n.leading,r=(d="maxWait"in n)?p(g(n.maxWait)||0,e):r,s="trailing"in n?!!n.trailing:s),w.cancel=function(){void 0!==u&&clearTimeout(u),c=0,i=a=o=u=void 0},w.flush=function(){return void 0===u?f:x(b())},w}(e,n,{leading:i,maxWait:n,trailing:o})}}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.trackProgress={})}(this,function(t){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=NaN,i="[object Symbol]",o=/^\s+|\s+$/g,r=/^[-+]0x[0-9a-f]+$/i,f=/^0b[01]+$/i,u=/^0o[0-7]+$/i,a=parseInt,c="object"==typeof e&&e&&e.Object===Object&&e,l="object"==typeof self&&self&&self.Object===Object&&self,d=c||l||Function("return this")(),s=Object.prototype.toString,p=Math.max,v=Math.min,b=function(){return d.Date.now()};function m(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function g(t){if("number"==typeof t)return t;if(function(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&s.call(t)==i}(t))return n;if(m(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=m(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=t.replace(o,"");var c=f.test(t);return c||u.test(t)?a(t.slice(2),c?2:8):r.test(t)?n:+t}t.fromXHREvent=function(t){return{computable:t.lengthComputable,finished:t.loaded,total:t.total}},t.createProgressTracker=function(t){void 0===t&&(t={throttleWait:250});var e,n,i,o,r=t.throttleWait,f=Date.now();return e=function(t){var e,n,i,o,r,u,a=t.total,c=t.finished,l=t.computable;return void 0===l&&(l=a>0&&c>=0),e=(Date.now()-f)/1e3,l&&(n=Math.round(100*c/a),e>=1&&(i=c/e),a&&(o=Math.min(c,a)/a,i&&(u=i/8,r=0,n<100&&(r=a/i-e,r=Number(r.toFixed(4)))))),{total:a,finished:c,percent:n,progress:o,elapsed:e,remaining:r,speed:i,bitrate:u}},n=r,i=!0,o=!0,m(void 0)&&(i="leading"in void 0?!!(void 0).leading:i,o="trailing"in void 0?!!(void 0).trailing:o),function(t,e,n){var i,o,r,f,u,a,c=0,l=!1,d=!1,s=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function y(e){var n=i,r=o;return i=o=void 0,c=e,f=t.apply(r,n)}function h(t){var n=t-a;return void 0===a||n>=e||n<0||d&&t-c>=r}function j(){var t=b();if(h(t))return x(t);u=setTimeout(j,function(t){var n=e-(t-a);return d?v(n,r-(t-c)):n}(t))}function x(t){return u=void 0,s&&i?y(t):(i=o=void 0,f)}function w(){var t=b(),n=h(t);if(i=arguments,o=this,a=t,n){if(void 0===u)return function(t){return c=t,u=setTimeout(j,e),l?y(t):f}(a);if(d)return u=setTimeout(j,e),y(a)}return void 0===u&&(u=setTimeout(j,e)),f}return e=g(e)||0,m(n)&&(l=!!n.leading,r=(d="maxWait"in n)?p(g(n.maxWait)||0,e):r,s="trailing"in n?!!n.trailing:s),w.cancel=function(){void 0!==u&&clearTimeout(u),c=0,i=a=o=u=void 0},w.flush=function(){return void 0===u?f:x(b())},w}(e,n,{leading:i,maxWait:n,trailing:o})}}); | ||
//# sourceMappingURL=trackProgress.umd.js.map |
{ | ||
"name": "@building-block/track-progress", | ||
"version": "1.0.0-alpha.3", | ||
"version": "1.0.0-alpha.4", | ||
"description": "Track progress, bitrate (speed), remaining time from XHR upload & download events", | ||
@@ -65,3 +65,3 @@ "repository": "building-block/blocks", | ||
}, | ||
"gitHead": "97154a79549e4e36a2b4526dc7912f892d4c633f" | ||
"gitHead": "8951c3f20cd08ec4259c15e113f177114d1d9391" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
72806
56