@building-block/track-progress
Advanced tools
Comparing version 1.0.0-alpha.0 to 1.0.0-alpha.1
@@ -14,5 +14,5 @@ export declare const fromXHREvent: (xhrEvent: any) => { | ||
elapsed: number | undefined; | ||
remaining: string | number | undefined; | ||
remaining: number | undefined; | ||
speed: number | undefined; | ||
bitrate: number | undefined; | ||
}) & import("lodash").Cancelable; |
@@ -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=(o=f/n-r).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,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})}; | ||
//# 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 g(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function m(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(g(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=g(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=(o=a/n-r).toFixed(4))))),{total:a,finished:c,percent:e,progress:i,elapsed:r,remaining:o,speed:n,bitrate:u}},n=r,i=!0,o=!0,g(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=m(e)||0,g(n)&&(l=!!n.leading,r=(d="maxWait"in n)?p(m(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.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})}}); | ||
//# sourceMappingURL=trackProgress.umd.js.map |
{ | ||
"name": "@building-block/track-progress", | ||
"version": "1.0.0-alpha.0", | ||
"version": "1.0.0-alpha.1", | ||
"description": "Track progress, bitrate (speed), remaining time from XHR upload & download events", | ||
@@ -27,3 +27,3 @@ "repository": "building-block/blocks", | ||
"build": "microbundle --target web --strict --external none", | ||
"dev": "ts-node src/trackProgress", | ||
"dev": "NODE_ENV=test ts-node src/trackProgress", | ||
"prepublishOnly": "npm run build", | ||
@@ -36,2 +36,3 @@ "test": "jest" | ||
"jest": "^24.8.0", | ||
"jest-date-mock": "^1.0.7", | ||
"microbundle": "^0.11.0", | ||
@@ -66,3 +67,3 @@ "ts-node": "^8.3.0", | ||
}, | ||
"gitHead": "33caf6b092636db27e292b5f00d2a744938d82cc" | ||
"gitHead": "b6f3d5572a4064dff1afeda4816daae20f6f2bd9" | ||
} |
@@ -6,4 +6,18 @@ # track-progress | ||
<a href="https://www.npmjs.com/package/@building-block/track-progress"><img src="https://img.shields.io/npm/v/@building-block/track-progress.svg?style=flat" alt="npm"></a> | ||
<a href="https://unpkg.com/@building-block/track-progress/"><img src="https://img.badgesize.io/https://unpkg.com/@building-block/track-progress/lib/xhrFetch.js?compression=gzip" alt="gzip size"></a> | ||
<a href="https://unpkg.com/@building-block/track-progress/"><img src="https://img.badgesize.io/https://unpkg.com/@building-block/track-progress/dist/trackProgress.js?compression=gzip" alt="gzip size"></a> | ||
### Installation | ||
#### Using npm: | ||
```sh | ||
$ npm install --save @building-block/track-progress | ||
``` | ||
#### Using yarn: | ||
```sh | ||
$ yarn add @building-block/track-progress | ||
``` | ||
## Usage | ||
@@ -10,0 +24,0 @@ |
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
70858
36
7