Sha256: 78a7130fad5942fa7e7d1baa0bc30c3c94e1fc6da9abe29e8554f3b1ff5614b2

Contents?: true

Size: 1.22 KB

Versions: 26

Compression:

Stored size: 1.22 KB

Contents

'use strict';

var utils = require('./../utils');

function InterceptorManager() {
  this.handlers = [];
}

/**
 * Add a new interceptor to the stack
 *
 * @param {Function} fulfilled The function to handle `then` for a `Promise`
 * @param {Function} rejected The function to handle `reject` for a `Promise`
 *
 * @return {Number} An ID used to remove interceptor later
 */
InterceptorManager.prototype.use = function use(fulfilled, rejected) {
  this.handlers.push({
    fulfilled: fulfilled,
    rejected: rejected
  });
  return this.handlers.length - 1;
};

/**
 * Remove an interceptor from the stack
 *
 * @param {Number} id The ID that was returned by `use`
 */
InterceptorManager.prototype.eject = function eject(id) {
  if (this.handlers[id]) {
    this.handlers[id] = null;
  }
};

/**
 * Iterate over all the registered interceptors
 *
 * This method is particularly useful for skipping over any
 * interceptors that may have become `null` calling `eject`.
 *
 * @param {Function} fn The function to call for each interceptor
 */
InterceptorManager.prototype.forEach = function forEach(fn) {
  utils.forEach(this.handlers, function forEachHandler(h) {
    if (h !== null) {
      fn(h);
    }
  });
};

module.exports = InterceptorManager;

Version data entries

26 entries across 14 versions & 4 rubygems

Version Path
waves_lib-0.1.0 js/node_modules/axios/lib/core/InterceptorManager.js
authing_ruby-1.1.4 lib/authing_ruby/test/js_sdk_test/node_modules/axios/lib/core/InterceptorManager.js
authing_ruby-1.1.4 lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/lib/core/InterceptorManager.js
authing_ruby-1.1.3 lib/authing_ruby/test/js_sdk_test/node_modules/axios/lib/core/InterceptorManager.js
authing_ruby-1.1.3 lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/lib/core/InterceptorManager.js
authing_ruby-1.1.2 lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/lib/core/InterceptorManager.js
authing_ruby-1.1.2 lib/authing_ruby/test/js_sdk_test/node_modules/axios/lib/core/InterceptorManager.js
authing_ruby-1.1.1 lib/authing_ruby/test/js_sdk_test/node_modules/axios/lib/core/InterceptorManager.js
authing_ruby-1.1.1 lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/lib/core/InterceptorManager.js
authing_ruby-1.1.0 lib/authing_ruby/test/js_sdk_test/node_modules/axios/lib/core/InterceptorManager.js
authing_ruby-1.1.0 lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/lib/core/InterceptorManager.js
authing_ruby-1.0.9 lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/lib/core/InterceptorManager.js
authing_ruby-1.0.9 lib/authing_ruby/test/js_sdk_test/node_modules/axios/lib/core/InterceptorManager.js
authing_ruby-1.0.8 lib/authing_ruby/test/js_sdk_test/node_modules/axios/lib/core/InterceptorManager.js
authing_ruby-1.0.8 lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/lib/core/InterceptorManager.js
authing_ruby-1.0.7 lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/lib/core/InterceptorManager.js
authing_ruby-1.0.7 lib/authing_ruby/test/js_sdk_test/node_modules/axios/lib/core/InterceptorManager.js
authing_ruby-1.0.6 lib/authing_ruby/test/js_sdk_test/node_modules/authing-js-sdk/node_modules/axios/lib/core/InterceptorManager.js
authing_ruby-1.0.6 lib/authing_ruby/test/js_sdk_test/node_modules/axios/lib/core/InterceptorManager.js
ilog-0.4.1 node_modules/axios/lib/core/InterceptorManager.js