JSPM

timers-browserify-full

0.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 45
  • Score
    100M100P100Q65843F
  • License MIT

timers module based on nodes code for browserify

Package Exports

  • timers-browserify-full

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 (timers-browserify-full) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

timers-browserify-full travis npm downloads

saucelabs

This module is based on the original source files of node v0.12.0. This means that it is as compatible to node as possible, and it also uses linked lists like node. But it also means that it is quite heavy, and not necessary for most browserify projects. If you don't heavily use timers, the timers-browserify module, which is already integrated in browserify, is probably better suited.

Size: 1.73KB gzipped (4.45KB uncompressed)

install / usage with browserify

npm install timers-browserify-full

To use it with browserify, you have to use the js API of browserify; the command line API does not support changing builtins.

Example:

var browserify = require('browserify');

var builtins = require('browserify/lib/builtins.js');
builtins.timers = require.resolve('timers-browserify-full');

var b = browserify();

b.add(...

The above example will use timers-browserify-full for all browserify builds. If you only want it for a specific build of a larger build script:

var browserify = require('browserify');

var builtins = require('browserify/lib/builtins.js');
var myBuiltins = {};
Object.keys(builtins).forEach(function(key) {
  myBuiltins[key] = builtins[key];
});

myBuiltins.timers = require.resolve('timers-browserify-full')

var b = browserify({builtins: myBuiltins});

b.add(...

globals

In node, the functions setTimeout, clearTimeout, setInterval, clearInterval, setImmediate & clearImmediate are added to the global namespace. I don't recommend doing this in the browser, because it overrides the native functions. But you can use the following snippet inside your modules — this doesn't touch the global namespace:

var timers = require('timers');

var setTimeout = timers.setTimeout,
    clearTimeout = timers.clearTimeout,
    setInterval = timers.setInterval,
    clearInterval = timers.clearInterval,
    setImmediate = timers.setImmediate,
    clearImmediate = timers.clearImmediate;

credit

The two main files, timers.js and _linklist.js, are of course based on joyent/node; the _linklist.js file is even untouched!

The two scripts in bin are borrowed from feross/buffer with modifications.

license

MIT