How to use the isstream.isReadable function in isstream

To help you get started, we’ve selected a few isstream 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 moleculerjs / moleculer-web / src / index.js View on Github external
// Other (stringify or raw text)
			else {
				if (!responseType) {
					res.setHeader("Content-Type", "application/json; charset=utf-8");
					chunk = JSON.stringify(data);
				} else {
					res.setHeader("Content-Type", responseType);
					if (_.isString(data))
						chunk = data;
					else
						chunk = data.toString();
				}
			}

			// Auto generate & add ETag
			if(route.etag && chunk && !res.getHeader("ETag") && !isReadableStream(chunk)) {
				res.setHeader("ETag", generateETag.call(this, chunk, route.etag));
			}

			// Freshness
			if (isFresh(req, res))
				res.statusCode = 304;

			if (res.statusCode === 204 || res.statusCode === 304) {
				res.removeHeader("Content-Type");
				res.removeHeader("Content-Length");
				res.removeHeader("Transfer-Encoding");

				chunk = "";
			}

			if (req.method === "HEAD") {
github autoric / super-router / lib / Response.js View on Github external
setBody(body) {
    this._body             = new TransformStream({ objectMode : true });
    this._body._transform  = function (chunk, encoding, done) {
      return done(null, chunk);
    };
    this._lastAssignedBody = this._body;

    if (isReadableStream(body)) {
      body.pipe(this._body);
      body.on('error', (err) => {
        this._body.emit('error', err);
      });
    }
    else if (!_.isUndefined(body)) {
      this._body.end(body);
      this._lastAssignedBody = body;
    }
  }
github umple / umple / umpleonline / watson / node_modules / ibm-cloud-sdk-core / lib / helper.js View on Github external
function isFileParam(obj) {
    return Boolean(obj &&
        (isstream_1.isReadable(obj) ||
            Buffer.isBuffer(obj) ||
            isFileObject(obj) ||
            (obj.data && isFileParam(obj.data))));
}
exports.isFileParam = isFileParam;
github watson-developer-cloud / node-sdk / lib / helper.ts View on Github external
function isFileStream(obj: any): obj is FileStream {
  return obj && isReadable(obj) && obj.path;
}
github autoric / super-router / lib / Request.js View on Github external
constructor(options) {
    if (!_.isObject(options)) {
      throw new TypeError('options must be an object.');
    }

    const headers = options.headers;
    const body    = options.body;

    if (headers != null && !_.isObject(headers)) {
      throw new TypeError('headers must be an object.');
    }
    if (body != null && !isReadableStream(body)) {
      throw new TypeError('body must be a readable stream.');
    }

    this.path   = options.path;
    this.method = options.method;

    this._originalPath    = options.originalPath || options.path;
    this._headers         = new Map();
    _.each(headers, (v, k) => {
      this._headers.set(k.toLowerCase(), v);
    });
    this._body            = new TransformStream();
    this._body._transform = function (chunk, encoding, done) {
      return done(null, chunk);
    };
    if (isReadableStream(body)) {
github umple / umple / umpleonline / watson / node_modules / ibm-cloud-sdk-core / lib / helper.js View on Github external
function isFileStream(obj) {
    return obj && isstream_1.isReadable(obj) && obj.path;
}
function isFileParam(obj) {
github IBM / node-sdk-core / lib / helper.ts View on Github external
function isFileStream(obj: any): obj is FileStream {
  return Boolean(obj && isReadable(obj) && obj.path);
}

isstream

Determine if an object is a Stream

MIT
Latest version published 9 years ago

Package Health Score

67 / 100
Full package analysis