Skip to content

Commit

Permalink
Merge 947898a into 1d17b6d
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharmath committed Mar 14, 2016
2 parents 1d17b6d + 947898a commit 3094700
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Expand Up @@ -13,7 +13,6 @@ before_script:
- npm prune
- npm run lint
after_success:
- nyc npm test && nyc report --reporter=text-lcov | coveralls
- npm run semantic-release
branches:
except:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -13,7 +13,7 @@
"url": "https://github.com/tusharmath/Multi-threaded-downloader.git"
},
"scripts": {
"test": "./node_modules/ava/cli.js",
"test": "nyc ava && nyc report --reporter=text-lcov | coveralls",
"lint": "standard --verbose | snazzy",
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
},
Expand Down
6 changes: 3 additions & 3 deletions src/initMeta.js
Expand Up @@ -7,8 +7,8 @@ const PROPS = [
]
module.exports = (ob, options) => ob
.requestContentLength(options)
.map((x) => {
const threads = splitRange(x, options.range)
return _.assign({}, options, {totalBytes: x, threads, offsets: threads.map((x) => x[0])})
.map((totalBytes) => {
const threads = splitRange(totalBytes, options.range)
return _.assign({}, options, {totalBytes, threads, offsets: threads.map((x) => x[0])})
})
.map((x) => _.pick(x, PROPS))
10 changes: 5 additions & 5 deletions src/splitRange.js
Expand Up @@ -5,11 +5,11 @@
'use strict'
const _ = require('lodash')

module.exports = (range, count) => {
const delta = Math.round(range / count)
const start = _.times(count, (x) => x * delta)
const end = _.times(count, (x) => (x + 1) * delta - 1)
end[count - 1] = range
module.exports = (totalBytes, range) => {
const delta = Math.round(totalBytes / range)
const start = _.times(range, (x) => x * delta)
const end = _.times(range, (x) => (x + 1) * delta - 1)
end[range - 1] = totalBytes
return _.zip(start, end)
}

0 comments on commit 3094700

Please sign in to comment.