How to use the methods.includes 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 visionmedia / superagent / src / node / index.js View on Github external
} else if (typeof connectOverride === 'object') {
    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.includes('del')) {
  // 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 = method === 'del' ? 'delete' : method;

  method = method.toUpperCase();
  request[name] = (url, data, fn) => {
    const req = request(method, url);
    if (typeof data === 'function') {
      fn = data;
github QUST-Coder / official-website-backend / base / base_router.js View on Github external
methodNames.forEach(name => {
            let preHandleName = name.replace(methodNameReg, "$1-$2").split("-");
            let method = preHandleName[0];
            if (methods.includes(method)) {
                let path = preHandleName[1].replace(/^./, function (match) {
                    return match.toLowerCase();
                });
                if (this.__router[method] && path) {
                    if (path == "api") {
                        this.__router[method]("/api*", this.__proto__[name].bind(this));
                    } else {
                        this.__router[method](`/${path}`, this.__proto__[name].bind(this));
                    }
                }
            }
        });
    }
github apogeu / apogeu / src / routes.js View on Github external
const isMethod = method => methods.includes(method);
const isFunction = func => typeof func === 'function';