22// shim for using process in browser
33
44var process = module . exports = { } ;
5-
6- // cached from whatever global is present so that test runners that stub it
7- // don't break things. But we need to wrap it in a try catch in case it is
8- // wrapped in strict mode code which doesn't define any globals. It's inside a
9- // function because try/catches deoptimize in certain engines.
10-
11- var cachedSetTimeout ;
12- var cachedClearTimeout ;
13-
14- ( function ( ) {
15- try {
16- cachedSetTimeout = setTimeout ;
17- } catch ( e ) {
18- cachedSetTimeout = function ( ) {
19- throw new Error ( 'setTimeout is not defined' ) ;
20- }
21- }
22- try {
23- cachedClearTimeout = clearTimeout ;
24- } catch ( e ) {
25- cachedClearTimeout = function ( ) {
26- throw new Error ( 'clearTimeout is not defined' ) ;
27- }
28- }
29- } ( ) )
305var queue = [ ] ;
316var draining = false ;
327var currentQueue ;
338var queueIndex = - 1 ;
349
3510function cleanUpNextTick ( ) {
36- if ( ! draining || ! currentQueue ) {
37- return ;
38- }
3911 draining = false ;
4012 if ( currentQueue . length ) {
4113 queue = currentQueue . concat ( queue ) ;
@@ -51,7 +23,7 @@ function drainQueue() {
5123 if ( draining ) {
5224 return ;
5325 }
54- var timeout = cachedSetTimeout ( cleanUpNextTick ) ;
26+ var timeout = setTimeout ( cleanUpNextTick ) ;
5527 draining = true ;
5628
5729 var len = queue . length ;
@@ -68,7 +40,7 @@ function drainQueue() {
6840 }
6941 currentQueue = null ;
7042 draining = false ;
71- cachedClearTimeout ( timeout ) ;
43+ clearTimeout ( timeout ) ;
7244}
7345
7446process . nextTick = function ( fun ) {
@@ -80,7 +52,7 @@ process.nextTick = function (fun) {
8052 }
8153 queue . push ( new Item ( fun , args ) ) ;
8254 if ( queue . length === 1 && ! draining ) {
83- cachedSetTimeout ( drainQueue , 0 ) ;
55+ setTimeout ( drainQueue , 0 ) ;
8456 }
8557} ;
8658
@@ -120,7 +92,6 @@ process.chdir = function (dir) {
12092process . umask = function ( ) { return 0 ; } ;
12193
12294} , { } ] , 2 :[ function ( require , module , exports ) {
123- ( function ( Buffer ) {
12495// uuid.js
12596//
12697// Copyright (c) 2010-2012 Robert Kieffer
@@ -394,7 +365,6 @@ process.umask = function() { return 0; };
394365 }
395366} ) ( 'undefined' !== typeof window ? window : null ) ;
396367
397- } ) . call ( this , require ( "buffer" ) . Buffer )
398368} , { } ] , 3 :[ function ( require , module , exports ) {
399369( function ( process ) {
400370var
@@ -2247,9 +2217,10 @@ KuzzleDataCollection.prototype.getMapping = function (options, cb) {
22472217 *
22482218 * @param {object } document - either a KuzzleDocument instance or a JSON object
22492219 * @param {object } [options] - optional arguments
2220+ * @param {responseCallback } [cb] - Returns a raw Kuzzle response
22502221 * @returns {* } this
22512222 */
2252- KuzzleDataCollection . prototype . publishMessage = function ( document , options ) {
2223+ KuzzleDataCollection . prototype . publishMessage = function ( document , options , cb ) {
22532224 var data = { } ;
22542225
22552226 if ( document instanceof KuzzleDocument ) {
@@ -2259,7 +2230,7 @@ KuzzleDataCollection.prototype.publishMessage = function (document, options) {
22592230 }
22602231
22612232 data = this . kuzzle . addHeaders ( data , this . headers ) ;
2262- this . kuzzle . query ( this . buildQueryArgs ( 'write' , 'publish' ) , data , options ) ;
2233+ this . kuzzle . query ( this . buildQueryArgs ( 'write' , 'publish' ) , data , options , cb ) ;
22632234
22642235 return this ;
22652236} ;
0 commit comments