Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

areq

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

areq

An asynchronous request controller

  • 0.0.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
25
Maintainers
1
Weekly downloads
 
Created
Source

areq

A timeout controller for asynchronous requests

NPM

Travis branch npm npm


## Table of Contents
  1. Overiew
  2. Installation
  3. Usage
  4. APIs
  5. Table of Identifiers

1. Overview

areq is a timeout controller for asynchronous requests with Promise defers (e.g., Q.defer()).

2. Installation

$ npm install areq --save

3. Usage

areq [TBD].

Here is a quick example.

var Q = require('q'),
    Areq = require('areq'),
    EventEmitter = require('events');

var myEmitter = Object.create(new EventEmitter()),
    areq = new Areq(myEmitter, 6000);   // timeout after 6 seconds

var fooAsyncReq = function (callback) {
    var deferred = Q.defer();

    areq.register('some_event', deferred, function (result) {
        if (result !== 'what_i_want') {
            areq.reject('some_event', new Error('Bad response.'));
        } else {
            areq.resolve('some_event', result);
        }
    });

    return deferred.promise.nodeify(callback);
};

fooAsyncReq(function (err, result) {
    if (err)
        console.log(err);
    else
        console.log(result);
});

4. APIs


new Areq(emitter[, areqTimeout])

TBD.

Arguments

  • emitter (EventEmitter): TBD

Returns:

  • (Object) Returns an instance of Areq class.

Example



register(evt, deferred, listener[, time])

TBD.

Arguments

  • evt (String): TBD

Returns:

  • (Object) Returns .

Example



resolve(evt, value)

TBD.

Arguments

  • evt (String): TBD

Returns:

  • (Object) Returns .

Example



reject(evt, err)

TBD.

Arguments

  • evt (String): TBD

Returns:

  • (Object) Returns .

Example



getRecord(evt)

TBD.

Arguments

  • evt (String): TBD

Returns:

  • (Object) Returns .

Example



isEventPending(evt)

TBD.

Arguments

  • evt (String): TBD

Returns:

  • (Object) Returns .

Example



FAQs

Package last updated on 07 Jul 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc