How to use into-stream - 10 common examples

To help you get started, we’ve selected a few into-stream 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 zeit / pkg / lib / producer.js View on Github external
if (stripe.file === target.output) {
              return cb(wasReported(
                'Trying to take executable into executable', stripe.file
              ));
            }

            assert.equal(stripe.store, STORE_CONTENT); // others must be buffers from walker
            return cb(undefined, pipeToNewMeter(fs.createReadStream(stripe.file)));
          } else {
            assert(false, 'producer: bad stripe');
          }
        } else {
          payloadSize = track;
          preludePosition = payloadPosition + payloadSize;
          return cb(undefined, next(
            intoStream(makePreludeBufferFromPrelude(
              replaceDollarWise(
              replaceDollarWise(prelude, '%VIRTUAL_FILESYSTEM%', JSON.stringify(vfs)),
                                         '%DEFAULT_ENTRYPOINT%', JSON.stringify(entrypoint))
            ))
          ));
        }
      } else {
        return cb();
      }
    }).on('error', (error) => {
      reject(error);
github beakerbrowser / beaker / app / background-process / protocols / dat.js View on Github external
try {
      entry = await pda.stat(archiveFS, path)
      entry.path = path
    } catch (e) {}
  }
  // detect if this is a folder without a trailing slash
  if (!isFolder) {
    await tryStat(filepath)
    if (entry && entry.isDirectory()) {
      cleanup()
      return respond({
        statusCode: 303,
        headers: {
          Location: `dat://${urlp.host}${urlp.pathname || ''}/${urlp.search || ''}`
        },
        data: intoStream('')
      })
    }
  }
  entry = false
  // do actual lookup
  if (isFolder) {
    await tryStat(filepath + 'index.html')
    await tryStat(filepath + 'index.md')
    await tryStat(filepath)
  } else {
    await tryStat(filepath)
    await tryStat(filepath + '.html') // fallback to .html
  }

  // handle folder
  if (entry && entry.isDirectory()) {
github beakerbrowser / beaker / app / background-process / protocols / beaker.js View on Github external
var cb = once((statusCode, status, contentType, path) => {
    const headers = {
      'Cache-Control': 'no-cache',
      'Content-Type': (contentType || 'text/html; charset=utf-8'),
      'Content-Security-Policy': BEAKER_CSP,
      'Access-Control-Allow-Origin': '*'
    }
    if (typeof path === 'string') {
      respond({statusCode, headers, data: fs.createReadStream(path)})
    } else if (typeof path === 'function') {
      respond({statusCode, headers, data: intoStream(path())})
    } else {
      respond({statusCode, headers, data: intoStream(errorPage(statusCode + ' ' + status))})
    }
  })
  async function serveICO (path, size = 16) {
github Soluto / dynamico / server / azure-blob-storage / lib / index.ts View on Github external
async upsertIndex(index: Index) {
    try {
      const currentIndex = await this.getIndex();
      const updatedIndex = JSON.stringify({ ...currentIndex, ...index });
      const indexStream = intoStream(updatedIndex);

      await uploadStreamToBlockBlob(this.aborter, indexStream, this.indexBlobUrl, updatedIndex.length, 10);
    } catch (error) {
      throw new FailedIndexUpsert(error, index);
    }
  }
github beakerbrowser / beaker / app / background-process / protocols / beaker.js View on Github external
var cb = once((statusCode, status, contentType, path) => {
    const headers = {
      'Cache-Control': 'no-cache',
      'Content-Type': (contentType || 'text/html; charset=utf-8'),
      'Content-Security-Policy': BEAKER_CSP,
      'Access-Control-Allow-Origin': '*'
    }
    if (typeof path === 'string') {
      respond({statusCode, headers, data: fs.createReadStream(path)})
    } else if (typeof path === 'function') {
      respond({statusCode, headers, data: intoStream(path())})
    } else {
      respond({statusCode, headers, data: intoStream(errorPage(statusCode + ' ' + status))})
    }
  })
  async function serveICO (path, size = 16) {
github beakerbrowser / beaker / app / background-process / protocols / dat.js View on Github external
fileReadStream.once('end', () => {
    if (!headersSent) {
      cleanup()
      debug('Served empty file')
      respond({
        statusCode: 200,
        headers: {
          'Content-Security-Policy': cspHeader,
          'Access-Control-Allow-Origin': '*'
        },
        data: intoStream('')
      })
    }
  })
github CGamesPlay / chronicler / src / main / ElectronRequestConnector.js View on Github external
const nextStream = () => {
        currentIdx += 1;
        if (currentIdx === uploads.length) return null;
        const chunk = uploads[currentIdx];
        if (chunk.bytes) {
          return intoStream(chunk.bytes);
        } else if (chunk.file) {
          return fs.createReadStream(chunk.file);
        } else {
          throw new Error("not implemented");
        }
      };
      const stream = new StreamConcat(nextStream);
github beakerbrowser / beaker / app / bg / protocols / intent.js View on Github external
return respond({
        statusCode: 303,
        headers: {Location: `beaker://library/?view=addressbook&site=${encodeURIComponent(urlp.qs.url)}`},
        data: intoStream('')
      })
    case 'unwalled.garden/view-feed':
      return respond({
        statusCode: 303,
        headers: {Location: `dat://beaker.social/profile/${encodeURIComponent(urlp.qs.url)}`},
        data: intoStream('')
      })
    case 'unwalled.garden/view-file':
      return respond({
        statusCode: 303,
        headers: {Location: `beaker://editor/${urlp.qs.url}`},
        data: intoStream('')
      })
  }

  respond({
    statusCode: 404,
    headers: {'Content-Type': 'text/html; charset=utf-8'},
    data: intoStream(errorPage('404 Intent Not Found: ' + urlp.name))
  })
}
github zeit / pkg / lib / producer.js View on Github external
new Multistream((cb) => {
      if (count === 0) {
        return cb(undefined, next(
          intoStream(binaryBuffer)
        ));
      } else
      if (count === 1) {
        payloadPosition = meter.bytes;
        return cb(undefined, next(
          intoStream(Buffer.alloc(0))
        ));
      } else
      if (count === 2) {
        if (prevStripe && !prevStripe.skip) {
          let { snap, store } = prevStripe;
          snap = snapshotify(snap, slash);
          vfs[snap][store] = [ track, meter.bytes ];
          track += meter.bytes;
        }
github zeit / now / packages / now-build-utils / src / file-blob.ts View on Github external
toStream(): NodeJS.ReadableStream {
    return intoStream(this.data);
  }
}

into-stream

Convert a string/promise/array/iterable/asynciterable/buffer/typedarray/arraybuffer/object into a stream

MIT
Latest version published 5 months ago

Package Health Score

76 / 100
Full package analysis

Popular into-stream functions