Skip to content
This repository has been archived by the owner on Aug 17, 2023. It is now read-only.

Commit

Permalink
yielding array or object should be deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
zensh committed Mar 11, 2016
1 parent 0f78053 commit d3c3bda
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 22 deletions.
10 changes: 5 additions & 5 deletions README.md
Expand Up @@ -86,11 +86,11 @@ thunk(function *() {

})(function *(error, res) {
//parallel
console.log(yield [
console.log(yield thunk.all([
size('.gitignore'),
size('thunks.js'),
size('package.json')
])
]))
})()
```

Expand Down Expand Up @@ -239,13 +239,13 @@ The parameter `thunkable` value could be:
})(function *(error, res) {
console.log(error, res) // null, 20

return yield [1, 2, thunk(3)]
return yield thunk.all([1, 2, thunk(3)])
})(function *(error, res) {
console.log(error, res) // null, [1, 2, 3]
return yield {
return yield thunk.all({
name: 'test',
value: thunk(1)
}
})
})(function (error, res) {
console.log(error, res) // null, {name: 'test', value: 1}
})
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Expand Up @@ -2,7 +2,7 @@
"name": "thunks",
"description": "A small and magical composer for all JavaScript asynchronous.",
"main": "thunks.js",
"version": "4.1.3",
"version": "4.1.4",
"homepage": "https://github.com/thunks/thunks",
"authors": [
"Yan Qing <admin@zensh.com>"
Expand Down
2 changes: 1 addition & 1 deletion component.json
Expand Up @@ -2,7 +2,7 @@
"name": "thunks",
"description": "A small and magical composer for all JavaScript asynchronous.",
"main": "thunks.js",
"version": "4.1.3",
"version": "4.1.4",
"homepage": "https://github.com/thunks/thunks",
"authors": [
"Yan Qing <admin@zensh.com>"
Expand Down
10 changes: 5 additions & 5 deletions examples/generator-array1.js
Expand Up @@ -8,9 +8,9 @@ var size = thunk.thunkify(fs.stat)

thunk(function *() {
// 3 concurrent stat()s at a time
var a = yield [size('.gitignore'), size('thunks.js'), size('package.json')]
var b = yield [size('.gitignore'), size('thunks.js'), size('package.json')]
var c = yield [size('.gitignore'), size('thunks.js'), size('package.json')]
var a = yield thunk.all([size('.gitignore'), size('thunks.js'), size('package.json')])
var b = yield thunk.all([size('.gitignore'), size('thunks.js'), size('package.json')])
var c = yield thunk.all([size('.gitignore'), size('thunks.js'), size('package.json')])
console.log(a)
console.log(b)
console.log(c)
Expand All @@ -19,12 +19,12 @@ thunk(function *() {
var a = [size('.gitignore'), size('thunks.js'), size('package.json')]
var b = [size('.gitignore'), size('thunks.js'), size('package.json')]
var c = [size('.gitignore'), size('thunks.js'), size('package.json')]
var d = yield [a, b, c]
var d = yield thunk.all([a, b, c])
console.log(d)
})(function *() {
var a = size('.gitignore')
var b = size('thunks.js')
var c = size('package.json')
var res = yield [a, b, c]
var res = yield thunk.all([a, b, c])
console.log(res)
})()
2 changes: 1 addition & 1 deletion examples/generator-array2.js
Expand Up @@ -34,7 +34,7 @@ thunk(function *() {
var b = latency('http://github.com', 5)
var c = latency('http://weibo.com', 5)

return yield [a, b, c]
return yield thunk.all(a, b, c)
})(function (error, res) {
console.log(error, res)
})
2 changes: 1 addition & 1 deletion examples/generator-nested.js
Expand Up @@ -20,7 +20,7 @@ var bar = thunk(function *() {
})

thunk(function *() {
return yield [foo, bar]
return yield thunk.all([foo, bar])
})(function (error, res) {
console.log(error, res)
})
4 changes: 2 additions & 2 deletions examples/generator-requests.js
Expand Up @@ -21,9 +21,9 @@ thunk(function *() {
}
})(function *() {
// parallel
var res = yield urls.map(function (url) {
var res = yield thunk.all(urls.map(function (url) {
return get(url)
})
}))

return res.map(function (r) {
return r[0].statusCode
Expand Down
8 changes: 8 additions & 0 deletions examples/thunk-throw-error.js
@@ -0,0 +1,8 @@
'use strict'

var thunks = require('..')
var thunk = thunks()

thunk()(function () {
throw new Error('111111')
})
10 changes: 5 additions & 5 deletions package.json
Expand Up @@ -4,7 +4,7 @@
"authors": [
"Yan Qing <admin@zensh.com>"
],
"version": "4.1.3",
"version": "4.1.4",
"main": "thunks.js",
"typings": "./thunks.d.ts",
"jsnext:main": "thunks.es6.js",
Expand All @@ -31,14 +31,14 @@
"dependencies": {},
"devDependencies": {
"async": ">=1.5.2",
"bluebird": ">=3.2.0",
"bluebird": ">=3.3.4",
"co": ">=4.6.0",
"istanbul": "^0.4.2",
"jsbench": "^1.0.0",
"mocha": "^2.4.5",
"rsvp": ">=3.1.0",
"should": "^8.2.1",
"standard": "^5.4.1",
"rsvp": ">=3.2.1",
"should": "^8.2.2",
"standard": "^6.0.8",
"thenjs": ">=2.0.2",
"when": ">=3.7.7"
},
Expand Down
2 changes: 1 addition & 1 deletion test/index.js
Expand Up @@ -288,7 +288,7 @@ describe('thunks', function () {
should(error).be.instanceOf(Error)
should(error.message).be.equal('some error!')
should(value).be.equal(undefined)
return new Promise(function (resolve, rejecct) {
return new Promise(function (resolve, reject) {
setImmediate(function () {
resolve(x)
})
Expand Down
1 change: 1 addition & 0 deletions thunks.js
Expand Up @@ -191,6 +191,7 @@
}

current.result = tryRun(domain.ctx, parent.callback, args)

if (current.callback) {
tickDepth = tickDepth || maxTickDepth
if (--tickDepth) return continuation(current, domain, tickDepth)
Expand Down

0 comments on commit d3c3bda

Please sign in to comment.