# ember-timed-promise

> Create promises that have to be resolved before a given time

Latest version **0.0.3** (published 2015-05-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install ember-timed-promise
pnpm add ember-timed-promise
yarn add ember-timed-promise
bun add ember-timed-promise
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2015-05-17 |
| First published | 2015-05-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.10.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | bl4ckm0r3 |
| Keywords | ember-addon |

## Links

- npm: https://www.npmjs.com/package/ember-timed-promise
- npm.io page: https://npm.io/package/ember-timed-promise

## Dependencies (1)

- [ember-cli-babel](https://npm.io/package/ember-cli-babel.md) ^5.0.0

## Recent versions

- 0.0.3 (latest) — 2015-05-17
- 0.0.2 — 2015-05-12
- 0.0.1 — 2015-05-10

## README

# Ember-timed-promise

This is an extension of Ember.RSVP.Promise that allow the user to set a Timer
that will reject the promise if not resolved in time.
It uses ES6 syntax internally and babel to compile to ES5 friendly code


## Basic Usage
It works like a normal promise, only it accepts a time (in ms) and a promise/jQuery Deferred as an input and a custom message error (Will default to "<time>ms timer exceeded").

#### Ember.RSVP.Promise
```javascript
let prom = new Ember.RSVP.Promise((resolve, reject) =>{
  Ember.run.later(function() {
    resolve({
      response: true
    });
  }, 150); // This will delay the promise execution of 150ms
});

// The promise will reject and throw an error after 100ms
return new TimedPromise(100, prom, "It Failed!").then((response) => {
    Ember.Logger.log(response); // Will log {response : true}
  }, (reason) => {
    Ember.Logger.log(reason);
    // Will log Error("It Failed!")
});
```

#### jQuery Deferred
```javascript
let prom = Ember.$.getJSON("https://api.github.com/repos/emberjs/ember.js/pulls");
return new TimedPromise(2000, prom).then((response) => {
   Ember.Logger.log(response); // Will have an array of pulls from the ember repo
}).catch((reason) => {
   Ember.Logger.log(reason); // Why did you fail?
   });
```

## Installation

* `git clone` this repository
* `npm install`
* `bower install`

## Running

* `ember serve`
* Visit your app at http://localhost:4200/tests.

## Running Tests

* `ember test`
* `ember test --server`

## Building

* `ember build`

For more information on using ember-cli, visit [http://www.ember-cli.com/](http://www.ember-cli.com/).

---
_Source: https://npm.io/package/ember-timed-promise · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
