Skip to content

Commit

Permalink
Merge v0.8.11 into v0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
kriskowal committed Nov 25, 2012
2 parents afb63d0 + 1d2480c commit 5873d41
Show file tree
Hide file tree
Showing 12 changed files with 1,390 additions and 410 deletions.
21 changes: 21 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"browser": true,
"node": true,

"curly": true,
"eqeqeq": true,
"noarg": true,
"nonew": true,
"trailing": true,
"undef": true,

"globals": {
"bootstrap": false,
"cajaVM": false,
"define": false,
"Q": true,
"ReturnValue": false,
"ses": false,
"setImmediate": false
}
}
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ design
examples
spec
.coverignore
.jshintrc
.mailmap
.npmignore
.travis.yml
CHANGES.md
LICENSE
README.md
VERSIONS.md
q.min.js
q.min.js.gz
Expand Down
114 changes: 103 additions & 11 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,109 @@

## Next major

- WARNING: The undocumented ``Method`` export will be
removed. Use ``sender(op)``.
- WARNING: The deprecated ``node`` export will be removed.
Use ``nbind``.
- WARNING: The deprecated ``deferred.node()`` interface will be
removed. Use ``deferred.makeNodeResolver()``.
- WARNING: The deprecated ``call``, ``apply``, and ``bind`` are
replaced with ``fcall``, ``fapply``, and ``fbind``. Use of a
``thisp`` is discouraged. For calling methods, use ``post`` or
``invoke``.
- WARNING: The undocumented ``view`` and ``viewInfo`` will be removed.
The following deprecated or undocumented methods will be removed. Their
replacements are listed here:

<table>
<thead>
<tr>
<th>0.8.x method</th>
<th>0.9 replacement</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>call</code>, <code>apply</code>, <code>bind</code> (*)</td>
<td><code>fcall</code>/<code>invoke</code>, <code>fapply</code>/<code>post</code>, <code>fbind</code></td>
</tr>
<tr>
<td><code>ncall</code>, <code>napply</code>, <code>bind</code> (*)</td>
<td><code>nfcall</code>/<code>ninvoke</code>, <code>nfapply</code>/<code>npost</code>, <code>nfbind</code></td>
</tr>
<tr>
<td><code>end</code></td>
<td><code>done</code></td>
</tr>
<tr>
<td><code>ref</code></td>
<td><code>resolve</code></td>
</tr>
<tr>
<td><code>node</code></td>
<td><code>nbind</code></td>
</tr>
<tr>
<td><code>nend</code></td>
<td><code>nodeify</code></td>
</tr>
<tr>
<td><code>deferred.node</code></td>
<td><code>deferred.makeNodeResolver</code></td>
</tr>
<tr>
<td><code>Method</code>, <code>sender</code></td>
<td><code>dispatcher</code></td>
</tr>
<tr>
<td><code>send</code></td>
<td><code>dispatch</code></td>
</tr>
<tr>
<td><code>view</code>, <code>viewInfo</code></td>
<td>(none)</td>
</tr>
</tbody>
</table>

(*) Use of ``thisp`` is discouraged. For calling methods, use ``post`` or
``invoke``.

## 0.8.11
- Added ``nfcall``, ``nfapply``, and ``nfbind`` as ``thisp``-less versions of
``ncall`, ``napply``, and ``nbind``. The latter are now deprecated. #142
- Long stack traces no longer cause linearly-growing memory usage when chaining
promises together. #111
- Inspecting ``error.stack`` in a rejection handler will now give a long stack
trace. #103
- Fixed ``Q.timeout`` to clear its timeout handle when the promise is rejected;
previously, it kept the event loop alive until the timeout period expired.
#145 @dfilatov
- Added `q/queue` module, which exports an infinite promise queue
constructor.

## 0.8.10

- Added ``done`` as a replacement for ``end``, taking the usual fulfillment,
rejection, and progress handlers. It's essentially equivalent to
``then(f, r, p).end()``.
- Added ``Q.onerror``, a settable error trap that you can use to get full stack
traces for uncaught errors. #94
- Added ``thenResolve`` as a shortcut for returning a constant value once a
promise is fulfilled. #108 @ForbesLindesay
- Various tweaks to progress notification, including propagation and
transformation of progress values and only forwarding a single progress
object.
- Renamed ``nend`` to ``nodeify``. It no longer returns an always-fulfilled
promise when a Node callback is passed.
- ``deferred.resolve`` and ``deferred.reject`` no longer (sometimes) return
``deferred.promise``.
- Fixed stack traces getting mangled if they hit ``end`` twice. #116 #121 @ef4
- Fixed ``ninvoke`` and ``npost`` to work on promises for objects with Node
methods. #134
- Fixed accidental coercion of objects with nontrivial ``valueOf`` methods,
like ``Date``s, by the promise's ``valueOf`` method. #135
- Fixed ``spread`` not calling the passed rejection handler if given a rejected
promise.

## 0.8.9

- Added ``nend``
- Added preliminary progress notification support, via
``promise.then(onFulfilled, onRejected, onProgress)``,
``promise.progress(onProgress)``, and ``deferred.notify(...progressData)``.
- Made ``put`` and ``del`` return the object acted upon for easier chaining.
#84
- Fixed coercion cycles with cooperating promises. #106

## 0.8.7

Expand Down
35 changes: 12 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ If a function cannot return a value or throw an exception without
blocking, it can return a promise instead. A promise is an object
that represents the return value or the thrown exception that the
function may eventually provide. A promise can also be used as a
proxy for a [remote object][Q-Comm] to overcome latency.
proxy for a [remote object][Q-Connection] to overcome latency.

[Q-Comm]: https://github.com/kriskowal/q-comm
[Q-Connection]: https://github.com/kriskowal/q-connection

On the first pass, promises can mitigate the “[Pyramid of
Doom][POD]”: the situation where code marches to the right faster
Expand Down Expand Up @@ -38,7 +38,7 @@ Q.fcall(step1)
}, function (error) {
// Handle any error from step1 through step4
})
.end();
.done();
```

With this approach, you also get implicit error propagation,
Expand Down Expand Up @@ -241,8 +241,7 @@ the recived promises fails first gets handled by the error handler.

```javascript
function eventualAdd(a, b) {
return Q.all([a, b])
.spread(function (a, b) {
return Q.spread([a, b], function (a, b) {
return a + b;
})
}
Expand All @@ -261,16 +260,6 @@ return foo()
})
```

And you can use ``Q.spread`` directly on an array of promises.

```javascript
function eventualAdd(a, b) {
return Q.spread([a, b], function (a, b) {
return a + b;
})
}
```

The ``all`` function returns a promise for an array of values. If one
of the given promise fails, the whole returned promise fails, not
waiting for the rest of the batch. If you want to wait for all of the
Expand Down Expand Up @@ -379,7 +368,7 @@ foo()
.then(function () {
return "bar";
})
.end()
.done()
```

Ending a promise chain makes sure that, if an error doesn’t get
Expand Down Expand Up @@ -426,7 +415,7 @@ return Q.fcall(eventualAdd, 2, 2);
#### Using Deferreds

If you have to interface with asynchronous functions that are callback-based
instead of promise-based, Q provides a few shortcuts (like ``Q.ncall`` and
instead of promise-based, Q provides a few shortcuts (like ``Q.nfcall`` and
friends). But much of the time, the solution will be to use *deferreds*.

```javascript
Expand Down Expand Up @@ -593,22 +582,22 @@ FS.readFile("foo.txt", "utf-8", deferred.makeNodeResolver());
return deferred.promise;
```

And there are ``Q.ncall`` and ``Q.ninvoke`` for even shorter
And there are ``Q.nfcall`` and ``Q.ninvoke`` for even shorter
expression.

```javascript
return Q.ncall(FS.readFile, FS, "foo.txt", "utf-8");
return Q.nfcall(FS.readFile, "foo.txt", "utf-8");
```

```javascript
return Q.ninvoke(FS, 'readFile', "foo.txt", "utf-8");
return Q.ninvoke(FS, "readFile", "foo.txt", "utf-8");
```

There is also a ``Q.nbind`` function that that creates a reusable
There is also a ``Q.nfbind`` function that that creates a reusable
wrapper.

```javascript
var readFile = Q.nbind(FS.readFile, FS)
var readFile = Q.nfbind(FS.readFile);
return readFile("foo.txt", "utf-8");
```

Expand All @@ -627,7 +616,7 @@ will [be ameliorated][streamsnext].

A method-by-method [Q API reference][reference] is available on the wiki.

[reference]: q/wiki/API-Reference
[reference]: https://github.com/kriskowal/q/wiki/API-Reference

## More Examples

Expand Down
2 changes: 2 additions & 0 deletions minify
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
closure < q.js > q.min.js
gzip < q.min.js > q.min.js.gz
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "q",
"version": "0.8.7",
"version": "0.8.11",
"description": "A library for promises (CommonJS/Promises/A,B,D)",
"homepage": "http://github.com/kriskowal/q/",
"author": "Kris Kowal <[email protected]> (http://github.com/kriskowal/)",
"homepage": "https://github.com/kriskowal/q",
"author": "Kris Kowal <[email protected]> (https://github.com/kriskowal)",
"keywords": [
"q",
"promise",
Expand All @@ -15,7 +15,7 @@
"node"
],
"contributors": [
"Kris Kowal <[email protected]> (http://github.com/kriskowal/)",
"Kris Kowal <[email protected]> (https://github.com/kriskowal)",
"Irakli Gozalishvili <[email protected]> (http://jeditoolkit.com)",
"Domenic Denicola <[email protected]> (http://domenicdenicola.com)"
],
Expand All @@ -32,23 +32,23 @@
"main": "q.js",
"repository": {
"type": "git",
"url": "http://github.com/kriskowal/q.git"
"url": "git://github.com/kriskowal/q.git"
},
"engines": {
"node": ">=0.6.0",
"teleport": ">=0.2.0"
},
"dependencies": {},
"devDependencies": {
"jshint": ">=0.7.3",
"jshint": ">=0.9.1",
"cover": "*",
"jasmine-node": "*",
"opener": "*"
},
"scripts": {
"test": "jasmine-node spec",
"test-browser": "opener spec/q-spec.html",
"lint": "jshint --show-non-errors q.js",
"lint": "jshint q.js",
"cover": "cover run node_modules/jasmine-node/bin/jasmine-node spec && cover report html && opener cover_html/index.html"
},
"overlay": {
Expand Down
Loading

0 comments on commit 5873d41

Please sign in to comment.