New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

internal

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

internal

internal queue for your public libraries and APIs

  • 1.0.5
  • npm
  • Socket score

Version published
Weekly downloads
4K
decreased by-39.33%
Maintainers
1
Weekly downloads
 
Created
Source

internal

Internal queue for your public libraries and APIs. This library makes it easy to build asynchronous fluent APIs. You can also think of it as embedded promises.

Some examples of APIs you can build using internal:

  • nightmare
  • yieldb

Features

  • Runs asynchronous functions in order
  • Supports namespacing at any depth
  • Returns a promise for additional chaining
  • API methods can be synchronous, asynchronous, generators or promises
  • All methods are yieldable inside co

Usage

building a simple redis client:

var Internal = require('internal')
var client = require('redis')

// Wrap methods in Internal
var internal = Internal({
  connect: function (url) {
    this.client = client.createClient(url)
  },
  get: function (key, fn) {
    this.client.get(key, fn)
  },
  set: function (key, value, fn) {
    this.client.set(key, value, fn)
  }
})

function Redis () {
  // initialization stuff
}

Redis.prototype.connect = function (url) {
  // initialize an instance of internal, queue the
  // connect, and return the internal object
  return internal().connect(url)
}

var redis = new Redis()

// all async calls are queued
redis
  .connect('redis://localhost')
  .set('key', 'value')
  .get('key')
  .then(value => console.log(value))

See test for additional usage examples

Installation

npm install internal

License

MIT, go wild.

Keywords

FAQs

Package last updated on 02 Feb 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