JSPM

hang

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 7761
  • Score
    100M100P100Q123349F
  • License MIT

Force the supplied callback in to async execution

Package Exports

  • hang

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (hang) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

hang

Made by unshiftVersion npmBuild StatusDependenciesCoverage StatusIRC channel

hang is micro helper function that will guarantee that your callbacks are called async. The returned function can be called in sync or completely async. When it's called in sync we will "hang" execution in a setImmidiate or setTimeout(0) to ensure that it's called in async.

Installation

The module is released in the public npm registry and can be installed by running:

npm install --save hang

Usage

Require the module and supply it the function that should be called in completely async:

'use strict';

var hang = require('hang');

var fn = hang(function (foo) {
  console.log(this, foo); // foo, bar
});

fn.call('foo', 'bar')

//
// Or call it "async"
//
setTimeout(function () {
  fn.call('foo', 'bar')
}, 10);

License

MIT