How to use the destroy.bind function in destroy

To help you get started, we’ve selected a few destroy 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 physiii / open-automation / node_modules / koa / lib / response.js View on Github external
if ('string' == typeof val) {
      if (setType) this.type = /^\s* this.ctx.onerror(err));

      // overwriting
      if (null != original && original != val) this.remove('Content-Length');

      if (setType) this.type = 'bin';
      return;
    }

    // json
    this.remove('Content-Length');
    this.type = 'json';
  },
github koajs / koa / lib / response.js View on Github external
if ('string' == typeof val) {
      if (setType) this.type = /^\s* this.ctx.onerror(err));

      // overwriting
      if (null != original && original != val) this.remove('Content-Length');

      if (setType) this.type = 'bin';
      return;
    }

    // json
    this.remove('Content-Length');
    this.type = 'json';
  },
github consojs / conso / lib / Response.js View on Github external
if ('string' == typeof val) {
            if (setType) this.type = /^\s* this.ctx.onerror(err));

            // overwriting
            if (null != original && original != val) this.remove('Content-Length');

            if (setType) this.type = 'bin';
            return;
        }

        // json
        this.remove('Content-Length');
        this.type = 'json';
    }
github polixjs / polix / extends / response.js View on Github external
if ('string' == typeof val) {
      if (setType) this.type = /^\s* this.ctx.onerror(err));

      // overwriting
      if (null != original && original != val) this.remove('Content-Length');

      if (setType) this.type = 'bin';
      return;
    }

    // json
    this.remove('Content-Length');
    this.type = 'json';
  },
github metrue / fx / images / node / node_modules / koa / lib / response.js View on Github external
if ('string' == typeof val) {
      if (setType) this.type = /^\s* this.ctx.onerror(err));

      // overwriting
      if (null != original && original != val) this.remove('Content-Length');

      if (setType) this.type = 'bin';
      return;
    }

    // json
    this.remove('Content-Length');
    this.type = 'json';
  },
github slashhuang / cuty / src / response.js View on Github external
if ('string' == typeof val) {
      if (setType) this.type = /^\s* this.ctx.onerror(err));

      // overwriting
      if (null != original && original != val) this.remove('Content-Length');

      if (setType) this.type = 'bin';
      return;
    }

    // json
    this.remove('Content-Length');
    this.type = 'json';
  },
github malijs / mali / lib / run.js View on Github external
function execDuplex (ctx, handler) {
  wrapEnd(ctx)
  inject(ctx.call, function (err) { onerror(err, ctx) })
  ctx.call.on('finish', destroy.bind(null, ctx.call))
  handler(ctx).then(() => {
    ctx.response.sendMetadata()
  }).catch(err => {
    ctx.call.emit('error', err)
    onerror(err, ctx)
  })
}
github malijs / mali / lib / run.js View on Github external
function execRes (ctx, handler, fn) {
  if (isStream(ctx.call)) {
    inject(ctx.call, function (err) { onerror(err, ctx) })
    onEnd(ctx.call, destroy.bind(null, ctx.call))
  }

  handler(ctx).then(() => {
    ctx.response.sendMetadata()
    asCallback(Promise.resolve(ctx.res), (err, response) => {
      if (err) {
        onerror(err, ctx)
        return fn(err)
      }

      const statusMetadata = ctx.response.getStatusMetadata()
      if (response instanceof Error) {
        return fn(response, null, statusMetadata)
      }

      return fn(err, response, statusMetadata)

destroy

destroy a stream if possible

MIT
Latest version published 3 years ago

Package Health Score

71 / 100
Full package analysis

Popular destroy functions