How to use the methods.indexOf function in methods

To help you get started, we’ve selected a few methods examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mendersoftware / gui / node_modules / superagent / lib / node / index.js View on Github external
// These aren't supposed to have any body
    return false;
  }

  // header content is a string, and distinction between 0 and no information is crucial
  if ('0' === res.headers['content-length']) {
    // We know that the body is empty (unfortunately, this check does not cover chunked encoding)
    return false;
  }

  // console.log(res);
  return /^\s*(?:deflate|gzip)\s*$/.test(res.headers['content-encoding']);
};

// generate HTTP verb methods
if (methods.indexOf('del') == -1) {
  // create a copy so we don't cause conflicts with
  // other packages using the methods package and
  // npm 3.x
  methods = methods.slice(0);
  methods.push('del');
}
methods.forEach(method => {
  const name = method;
  method = 'del' == method ? 'delete' : method;

  method = method.toUpperCase();
  request[name] = (url, data, fn) => {
    const req = request(method, url);
    if ('function' == typeof data) (fn = data), (data = null);
    if (data) {
      if (method === 'GET' || method === 'HEAD') {
github Frost-Dev / Frost-API / src / streamingServer.js View on Github external
let {
				method,
				endpoint,
				query,
				body
			} = request;

			// パラメータを検証
			if (method == null || endpoint == null) {
				return connection.error('rest', 'request format is invalid');
			}

			method = method.toLowerCase();

			if (methods.indexOf(method) == -1) {
				return connection.error('rest', '"method" parameter is invalid');
			}

			// endpointを整形
			if (endpoint == '') {
				endpoint = '/';
			}
			else if (endpoint != '/' && endpoint[endpoint.length - 1] == '/') {
				endpoint = endpoint.substr(0, endpoint.length - 1);
			}

			// 対象Routeのモジュールを取得
			let routeFunc;
			let params = [];

			try {
github visionmedia / superagent / lib / node / index.js View on Github external
this._connectOverride = {'*': connectOverride};
  } else if ('object' === typeof connectOverride) {
    this._connectOverride = connectOverride;
  } else {
    this._connectOverride = undefined;
  }
  return this;
};

Request.prototype.trustLocalhost = function(toggle) {
    this._trustLocalhost = toggle === undefined ? true : toggle;
    return this;
};

// generate HTTP verb methods
if (methods.indexOf('del') == -1) {
  // create a copy so we don't cause conflicts with
  // other packages using the methods package and
  // npm 3.x
  methods = methods.slice(0);
  methods.push('del');
}
methods.forEach(method => {
  const name = method;
  method = 'del' == method ? 'delete' : method;

  method = method.toUpperCase();
  request[name] = (url, data, fn) => {
    const req = request(method, url);
    if ('function' == typeof data) (fn = data), (data = null);
    if (data) {
      if (method === 'GET' || method === 'HEAD') {
github ngageoint / mage-server / node_modules / method-override / index.js View on Github external
function supports(method) {
  return ~methods.indexOf(method);
}
github expressjs / method-override / index.js View on Github external
function supports (method) {
  return method &&
    typeof method === 'string' &&
    methods.indexOf(method.toLowerCase()) !== -1
}