angular-evaporate
Advanced tools
Comparing version 2.2.0 to 2.2.1
@@ -140,2 +140,3 @@ ;(function () { | ||
var now = Date.now(); | ||
var duration; | ||
@@ -147,11 +148,7 @@ // save timestamp | ||
if (name === 'progress') { | ||
duration = (now - that.$started) / 1000; | ||
that.$percent = Math.round(arg * 10000) / 100; | ||
if (that.$percent) { | ||
that.$seconds = Math.round( | ||
(100 - that.$percent) / that.$percent * | ||
(now - that.$started) / 1000 | ||
); | ||
that.$speed = (that.$percent * that.file.size * 10) / | ||
(now - that.$started); | ||
that.$speedStr = ae.$speedStr(that.$speed); | ||
that.$seconds = Math.round((100 - that.$percent) / that.$percent * duration); | ||
that.$speed = ae.$speeder(that.file.size * arg / duration); | ||
} | ||
@@ -240,15 +237,13 @@ } | ||
}; | ||
/** | ||
* Default upload upload speed function. | ||
* @params {size in bytes} | ||
* @returns {String} - speed of the upload in human readable format | ||
* Default upload speed function. | ||
* @params {Number} - speed in bytes per second | ||
* @returns {String} - speed in human readable format | ||
*/ | ||
AngularEvaporate.prototype.$speedStr = function (size) { | ||
var units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; | ||
var i = 0; | ||
while(size >= 1024) { | ||
size /= 1024; | ||
++i; | ||
} | ||
return size.toFixed(2).replace('.00', '') + ' ' + units[i] + '/s'; | ||
AngularEvaporate.prototype.$speeder = function (speed) { | ||
var prefix = ['', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y']; | ||
var pow = Math.floor(Math.log(speed) / Math.log(1024)); | ||
var val = speed / Math.pow(1024, pow); | ||
return val.toFixed(2).replace('.00', '') + ' ' + prefix[pow] + 'B/s'; | ||
}; | ||
@@ -255,0 +250,0 @@ |
{ | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"name": "angular-evaporate", | ||
@@ -46,7 +46,7 @@ "description": "AngularJS module for the EvaporateJS library", | ||
"scripts": { | ||
"start": "npm run-script example.compile && node ./example/server.js", | ||
"test": "karma start ./test/karma.conf.js", | ||
"example.compile": "cd example && browserify -o bundle.js index.js", | ||
"lib.minify": "cd lib && uglifyjs --compress --mangle --screw-ie8 -o angular-evaporate.min.js --source-map angular-evaporate.min.js.map -- angular-evaporate.js", | ||
"start.env": "foreman run npm start" | ||
"browserify": "cd example && browserify -o bundle.js index.js", | ||
"uglify": "cd lib && uglifyjs --compress --mangle --screw-ie8 -o angular-evaporate.min.js --source-map angular-evaporate.min.js.map -- angular-evaporate.js", | ||
"start": "npm run browserify && node ./example/server.js", | ||
"start:dev": "foreman run npm start", | ||
"test": "karma start ./test/karma.conf.js" | ||
}, | ||
@@ -65,4 +65,8 @@ "author": { | ||
"url": "https://github.com/adastreamer" | ||
}, | ||
{ | ||
"name": "Dmytro Riazanov", | ||
"url": "https://github.com/ryaz" | ||
} | ||
] | ||
} |
@@ -122,2 +122,3 @@ ## angular-evaporate | ||
| `$namer` | `Function` | optional | custom upload naming function (instance of `AngularEvaporateUpload` as an input argument, instance of `AngularEvaporate` as *this*), default one just returns a filename | ||
| `$speeder` | `Function` | optional | custom speedometer function (input: current speed in bytes/second, output: string in readable format, like '1.23 MB/s') | ||
| `$url` | `String` | cautious | custom url of the bucket's root directory | ||
@@ -160,4 +161,3 @@ | `$slothmode` | `Boolean` | optional | (directive) lazy mode option - explicit uploading start | ||
| `$seconds` | `Number` | optional | estimated elapsed time | ||
| `$speed` | `Number` | optional | upload speed | ||
| `$speedStr` | `String` | optional | upload speed in human readable format | ||
| `$speed` | `String` | optional | average upload speed | ||
@@ -164,0 +164,0 @@ ### API |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
0
44283
18
800