synchronous-promise
Advanced tools
Comparing version 2.0.6 to 2.0.7
@@ -0,0 +0,0 @@ (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){ |
@@ -0,0 +0,0 @@ /// <reference path="index.d.ts" /> |
@@ -0,0 +0,0 @@ export interface SynchronousPromise<T> extends Promise<T> { |
@@ -0,0 +0,0 @@ /* jshint node: true */ |
@@ -0,0 +0,0 @@ /* |
{ | ||
"name": "synchronous-promise", | ||
"version": "2.0.6", | ||
"version": "2.0.7", | ||
"description": "Synchronous Promise-like prototype to use in testing where you would have used an ES6 Promise", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -44,4 +44,4 @@ # synchronous-promise | ||
doSomethingInteresting | ||
function and perform our asserts in there: | ||
function and perform our asserts in there: | ||
```javascript | ||
@@ -65,5 +65,5 @@ describe('the thing', () => { | ||
I need to put that out there before anyone takes offense or thinks that I'm suggesting | ||
I need to put that out there before anyone takes offense or thinks that I'm suggesting | ||
that they're "doing it wrong". | ||
If you're doing this (or something very similar), great; `async/await`, if available, | ||
If you're doing this (or something very similar), great; `async/await`, if available, | ||
can make this code quite clean and linear too. | ||
@@ -111,3 +111,3 @@ | ||
And have error handling, either from the basic A+ spec: | ||
```javascript | ||
@@ -151,3 +151,3 @@ initial.then(message => { | ||
(`race()` isn't because I haven't determined a good strategy for that yet, | ||
(`race()` isn't because I haven't determined a good strategy for that yet, | ||
considering the synchronous design goal -- but it's | ||
@@ -210,5 +210,5 @@ unlikely you'll need `race()` from a test). | ||
expect(data).to.be.null; // because we paused... | ||
expect(captured).to.be.null; // because we paused... | ||
promise.resume(); | ||
expect(data).to.equal('123'); // because we resumed... | ||
expect(captured).to.equal('123'); // because we resumed... | ||
``` | ||
@@ -221,3 +221,3 @@ | ||
SynchronousPromise is purposefully written with prototypical, ES5 syntax so you | ||
can use it from ES5 if you like. Use the `synchronous-promise.js` file from the | ||
can use it from ES5 if you like. Use the `synchronous-promise.js` file from the | ||
`dist` folder if you'd like to include it in a browser environment (eg karma). | ||
@@ -237,3 +237,3 @@ | ||
can interfere with TypeScript: if | ||
- SynchronousPromise is installed globally (ie, overriding the | ||
- SynchronousPromise is installed globally (ie, overriding the | ||
native `Promise` implementation) and | ||
@@ -251,3 +251,3 @@ - You create a SynchronousPromise which is resolved asynchronously, | ||
This is due to how TypeScript generates the `__awaiter` function | ||
which is `yielded` to provide `async`/`await` functionality, in | ||
which is `yielded` to provide `async`/`await` functionality, in | ||
particular that the emitted code assumes that the global `Promise` | ||
@@ -275,3 +275,3 @@ will _always be asynchronous_, which is normally a reasonable assumption. | ||
}); | ||
``` | ||
``` | ||
@@ -284,3 +284,3 @@ It's not elegant that client code needs to know about the transpiled | ||
but discussion so far has not beein particularly convincing that | ||
TypeScript emission will be altered to (imo) a more robust | ||
TypeScript emission will be altered to (imo) a more robust | ||
implementation which wraps the emitted `__awaiter` in a closure. | ||
@@ -297,6 +297,6 @@ | ||
ES6 Promise, where possible (or the shim, where you're in ES5). Or Q. | ||
Or jQUery.Deferred(), Bluebird or any of the implementations at [https://promisesaplus.com/implementations](https://promisesaplus.com/implementations). | ||
Or jQUery.Deferred(), Bluebird or any of the implementations at [https://promisesaplus.com/implementations](https://promisesaplus.com/implementations). | ||
Basically, this seems to work quite well for testing and | ||
I've tried to implement every behaviour I'd expect from a promise -- but I'm | ||
pretty sure that a native `Promise` will be better for production code any day. | ||
pretty sure that a native `Promise` will be better for production code any day. |
@@ -0,0 +0,0 @@ { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
67739