Navigation Menu

Skip to content

Commit

Permalink
Merge pull request #2 from Laoujin/CastToResolve
Browse files Browse the repository at this point in the history
Replaced deprecated Promise.cast to Promise.resolve
  • Loading branch information
matthiasg committed Jul 12, 2016
2 parents 43c10b9 + 3effb96 commit 851af60
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions README.md
Expand Up @@ -23,7 +23,7 @@ javascript:
```javascript
var urls = ['http://www.google.de'];

Promise.cast(urls)
Promise.resolve(urls)
.then( as.sequenceOf(function(url){
return scrapeUrlIntoDatabaseOrSo(url);
}))
Expand All @@ -37,7 +37,7 @@ coffeescript:
```coffeescript
urls = ['http://www.google.de']

Promise.cast(urls)
Promise.resolve(urls)
.then as.sequenceOf (url)->
scrapeUrlIntoDatabaseOrSo(url)
.then ()->
Expand All @@ -55,7 +55,7 @@ javascript:
```javascript
var urls = ['http://www.google.de'];

Promise.cast(urls)
Promise.resolve(urls)
.then( as.sequenceWithParallelism(10,function(url){
return scrapeUrlIntoDatabaseOrSo(url);
}))
Expand All @@ -69,7 +69,7 @@ coffeescript:
```coffeescript
urls = ['http://www.google.de']

Promise.cast(urls)
Promise.resolve(urls)
.then as.sequenceWithParallelism 10, (url)->
scrapeUrlIntoDatabaseOrSo(url)
.then ()->
Expand Down
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -52,7 +52,7 @@ function sequenceWithParallelism(parallelism, functionToCall) {

assert(active<=parallelism, util.format('ERROR->active exceeding parallelism',active,parallelism));

Promise.cast( processTask(task) )
Promise.resolve( processTask(task) )
.finally(function(){
active--;
processNextTask();
Expand Down
10 changes: 5 additions & 5 deletions test/test.coffee
Expand Up @@ -15,7 +15,7 @@ describe 'Higher Level Functions on top of bluebird (Promise Library)', ->
throw new Error("Execution was not in sequence. Expected previous item to be #{item-1} but was #{previousItem}")
previousItem = item

Promise.cast(items)
Promise.resolve(items)
.then as.sequenceOf(workOnItem)
.then ()->
previousItem.should.equal(items.length)
Expand All @@ -38,14 +38,14 @@ describe 'Higher Level Functions on top of bluebird (Promise Library)', ->
throw new Error("Too many concurrent executions ##{concurrent}")

maxConcurrentCalls = Math.max(concurrent,maxConcurrentCalls)

return Promise.delay(Math.random()*10).finally ()->
concurrent--
if concurrent < 0
throw new Error("Something went wrong. Concurrent calls should not be less than 0")
count++

Promise.cast(items)
Promise.resolve(items)
.then as.sequenceWithParallelism(PARALLELISM,workOnItem)
.then ()->
maxConcurrentCalls.should.equal(PARALLELISM)
Expand All @@ -70,14 +70,14 @@ describe 'Higher Level Functions on top of bluebird (Promise Library)', ->
throw new Error("Too many concurrent executions ##{concurrent}")

maxConcurrentCalls = Math.max(concurrent,maxConcurrentCalls)

return Promise.delay(Math.random()*10).finally ()->
concurrent--
if concurrent < 0
throw new Error("Something went wrong. Concurrent calls should not be less than 0")
count++

Promise.cast(items)
Promise.resolve(items)
.then as.sequenceWithParallelism(PARALLELISM,workOnItem)
.then ()->
maxConcurrentCalls.should.equal(items.length)
Expand Down

0 comments on commit 851af60

Please sign in to comment.