• Stars
    star
    137
  • Rank 266,121 (Top 6 %)
  • Language
    CoffeeScript
  • License
    MIT License
  • Created over 12 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A deferred library for Node.js and the browser with a jQuery compatible API

Simply Deferred

jQuery-like Deferred API for Node and the browser

Simply Deferred is now feature complete. Bug fixes will be made, but no API changes are expected unless they're to ensure compliance with the jQuery API.

Installation

npm install simply-deferred

Usage

var Deferred = require('simply-deferred').Deferred;
var rendering = new Deferred();
rendering.done(function(){
    console.log('Finished rendering');
});

//...

rendering.resolve();

API

Simply Deferred is fullly compatible with jQuery's API, so the docs and usage are the same. Like the jQuery deferred API, it provides the following methods:

  • Deferred()
  • deferred.state()
  • deferred.done()
  • deferred.fail()
  • deferred.progress()
  • deferred.always()
  • deferred.promise()
  • deferred.notify()
  • deferred.notifyWith()
  • deferred.resolve()
  • deferred.resolveWith()
  • deferred.rejectWith()
  • deferred.reject()
  • deferred.pipe()
  • deferred.then()
  • Deferred.when()

Collaborating

Please feel free to raise issues on github.com/sudhirj/simply-deferred/issues - both obvious bugs or incompatibilities with jQuery are welcome.

If you'd like contribute a fix or a feature, that would be even better. Please make sure all pull requests are accompanied by tests, though.

If you'd like to start work on a feature that is not part of the jQuery library, just raise an empty pull request and let's talk about it first - the goal here for this library to be a drop-in replacement for jQuery, with the same docs and API.

Usage with Zepto

Zepto now has a deferred module available, so you might want to use that if Zepto is your primary reason for using Simply Deferred.

Simply Deffered also acts as a plugin to Zepto. The absence of a Deferred library was one of the biggest reasons I've been holding back, so I thought it made sense to write one. Once you have both Zepto and Simply Deferred on your page, just do Deferred.installInto(Zepto) to set it up. The installation makes the following changes to bring it closer to jQuery:

  • Aliases the Deferred constructor to $.Deferred.
  • Aliases the when method to $.when.
  • Wraps $.ajax to return a promise, which has only the following methods: state(), done(), fail() and always(). The arguments passed to the done and fail callbacks are the same ones passed to the success and error options.

More Repositories

1

shortuuid.rb

Convert UUIDs & numbers into space efficient and URL-safe Base62 strings, or any other alphabet.
Ruby
63
star
2

pump

Transmit large files over lossy networks using Raptor fountain codes
Go
61
star
3

uulid.go

ULID-UUID compatibility library for generating and parsing ULIDs.
Go
32
star
4

gae-bundle

Google App Engine/Python Textmate Bundle
21
star
5

slicy

Generic utility methods for Go slices / arrays / collections, heavily inspired by Lodash.
Go
12
star
6

shortuuid.go

Encode large numbers and UUIDs into space efficient strings
Go
8
star
7

mappr

The source code for www.pinnspot.com, can also be used as mapping framework to create your own locators
Python
7
star
8

ranger

Download large files in parallel chunks in Go.
Go
7
star
9

zippo

Get a zip full of a list of file URLs provided.
Go
6
star
10

paisa.js

Transform money to Indian numbers and words
JavaScript
6
star
11

cirque

A circular queue that processes jobs in parallel but returns results in FIFO
Go
6
star
12

active_datastore

A wrapper and (future) ODM for the Google Cloud Datastore.
Ruby
5
star
13

notecase

A closed wallet microservice
Ruby
5
star
14

aws-regions.go

Find the AWS region closest to your server, especially when deploying on systems like Fly.io
Go
5
star
15

liz

Template manager and compiler for Hogan.js
CoffeeScript
4
star
16

switchboard

Java
4
star
17

paisa.rb

Format paisa values into canonical Indian Rupee representations.
Ruby
4
star
18

culcal

a cultural calendar
Python
3
star
19

shots

Collect and enrich CoWIN info for easier querying.
Ruby
2
star
20

strobe

Go channel fan-out: send messages to many channels simultaneously
Go
2
star
21

boragle

The borg oracle
Python
2
star
22

airport.rails

JavaScript
2
star
23

dont-panic

The Don't Panic app - our team's entry into the TW app contest
JavaScript
2
star
24

telescope

Fast image resizing and trasnformation using Go
Go
2
star
25

restis

A HTTP based data structure store inspired by Redis.
Go
2
star
26

ledger

An unimiginatively titled high performance multipurpose general ledger.
1
star
27

amrita-sudhir.com

The site at amrita-sudhir.com
Python
1
star
28

metroman

A Metro-style layout manager for modern browsers
JavaScript
1
star
29

amritafredrick.com

Python
1
star
30

schock

The shopping site at schokoladetante.com
Ruby
1
star
31

sudhirj.github.io

CSS
1
star
32

billboard

Resize and serve images off S3 on demand and on the fly.
Ruby
1
star
33

sudhirjonathan.com

My personal homepage
Ruby
1
star