Skip to content

Commit

Permalink
Fix for broken 'initialValue' handling in Deft.Promise::reduce()
Browse files Browse the repository at this point in the history
This functionality was broken when issue #6 was resolved.

Fixes #48
  • Loading branch information
John Yanarella committed Aug 14, 2012
1 parent 014140a commit ed6ce38
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/coffee/Deft/promise/Promise.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ Ext.define( 'Deft.promise.Promise',
Traditional reduce function, similar to `Array.reduce()`, that allows input to contain promises and/or values.
###
reduce: ( promisesOrValues, reduceFunction, initialValue ) ->
initialValueSpecified = arguments.length is 3
return @when( promisesOrValues ).then(
success: ( promisesOrValues ) ->
# Wrap the reduce function with one that handles promises and then delegates to it.
Expand All @@ -188,7 +189,7 @@ Ext.define( 'Deft.promise.Promise',
)
]

if ( arguments.length is 3 )
if initialValueSpecified
reduceArguments.push( initialValue )

return @when( @reduceArray.apply( promisesOrValues, reduceArguments ) )
Expand Down
4 changes: 3 additions & 1 deletion src/js/Deft/promise/Promise.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ed6ce38

Please sign in to comment.