global-queue

v1.0.1
Generate a method that will push onto a global queue.
global queue push analytics

global-queue

Generate a method that will push onto a global queue, commonly used by 3rd-party Javascript tools.

Installation

$ component install segmentio/global-queue

Example

var push = require('global-queue')('_analytics');

push('key', '506g76b52f52c3f662000190');
push('identify', '[email protected]');
push('track', 'Loaded a Page');

window._analytics;
// [
//   ['key', '506g76b52f52c3f662000190'],
//   ['identify', '[email protected]'],
//   ['track', 'Loaded a Page']
// ]

API

generate(name, [options])

Return a function that will push onto the global queue named name, creating it if it doesn't already exist. Options:

{
  wrap: true
}

Setting wrap to false will not wrap your arguments in an array. Most services want that, but some keep them as objects or plain values.

License

MIT

npm i global-queue

Metadata

  • MIT
  • Whatever
  • Unknown
  • released 5/13/2015

Downloads

Maintainers