How to use get-stream - 10 common examples

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

github beakerbrowser / webdb / test / indexed-level.js View on Github external
t.deepEqual(await getStream.array(db.indexes.lastName.createValueStream({gt: 'Frazee'})), [TARA])

  // test index ranges

  t.deepEqual(await getStream.array(db.indexes.lastName.createValueStream({gte: 'Frazee'})), [PAUL, TARA])
  t.deepEqual(await getStream.array(db.indexes.lastName.createValueStream({lte: 'Frazee'})), [PAUL])
  t.deepEqual(await getStream.array(db.indexes.lastName.createValueStream({gte: 'Frazee', lte: 'Vancil'})), [PAUL, TARA])
  t.deepEqual(await getStream.array(db.indexes.lastName.createValueStream({gt: 'Frazee', lte: 'Vancil'})), [TARA])
  t.deepEqual(await getStream.array(db.indexes.lastName.createValueStream({gte: 'Frazee', lt: 'Vancil'})), [PAUL])

  // test compound index ranges

  t.deepEqual(await getStream.array(db.indexes['fullName'].createValueStream({gte: ['Frazee']})), [PAUL, TARA])
  t.deepEqual(await getStream.array(db.indexes['fullName'].createValueStream({lte: ['Frazee']})), [])
  t.deepEqual(await getStream.array(db.indexes['fullName'].createValueStream({lte: ['Frazee-Walthall', 'Jack']})), [PAUL])
  t.deepEqual(await getStream.array(db.indexes['fullName'].createValueStream({lt: ['Frazee-Walthall', 'Jack']})), [PAUL])
  t.deepEqual(await getStream.array(db.indexes['fullName'].createValueStream({gte: ['Frazee'], lte: ['Vancil']})), [PAUL])
  t.deepEqual(await getStream.array(db.indexes['fullName'].createValueStream({gt: ['Frazee'], lte: ['Vancil']})), [PAUL])
  t.deepEqual(await getStream.array(db.indexes['fullName'].createValueStream({gt: ['Frazee'], lte: ['Vancil', 'Tara']})), [PAUL, TARA])
  t.deepEqual(await getStream.array(db.indexes['fullName'].createValueStream({gte: ['Frazee'], lt: ['Vancil']})), [PAUL])

  // test multiple index ranges

  t.deepEqual(await getStream.array(db.indexes.attributes.createValueStream({gte: 'hacker', lte: 'hacker'})), [PAUL, TARA])
  t.deepEqual(await getStream.array(db.indexes.attributes.createValueStream({gte: 'ginger', lte: 'ginger'})), [PAUL])
  t.deepEqual(await getStream.array(db.indexes.attributes.createValueStream({gte: 'brunette', lte: 'brunette'})), [TARA])
})
github beakerbrowser / webdb / test / indexed-level.js View on Github external
t.deepEqual(await db.indexes.lastName.get('Frazee'), PAUL)
  t.deepEqual(await db.indexes.lastName.get('Vancil'), TARA)

  t.deepEqual(await db.indexes['fullName'].get(['Frazee', 'Paul']), PAUL)
  t.deepEqual(await db.indexes['fullName'].get(['Vancil', 'Tara']), TARA)

  t.deepEqual(await db.indexes.attributes.get('hacker'), PAUL)
  t.deepEqual(await db.indexes.attributes.get('ginger'), PAUL)
  t.deepEqual(await db.indexes.attributes.get('brunette'), TARA)

  // test normal stream behavior

  t.deepEqual(await getStream.array(db.createReadStream()), [{key: '1', value: PAUL}, {key: '3', value: TARA}])
  t.deepEqual(await getStream.array(db.createReadStream({gte: 2})), [{key: '3', value: TARA}])
  t.deepEqual(await getStream.array(db.createReadStream({gte: 2, lt: 3})), [])

  t.deepEqual(await getStream.array(db.createKeyStream()), ['1', '3'])
  t.deepEqual(await getStream.array(db.createKeyStream({gte: 2})), ['3'])
  t.deepEqual(await getStream.array(db.createKeyStream({gte: 2, lt: 3})), [])

  t.deepEqual(await getStream.array(db.createValueStream()), [PAUL, TARA])
  t.deepEqual(await getStream.array(db.createValueStream({gte: 2})), [TARA])
  t.deepEqual(await getStream.array(db.createValueStream({gte: 2, lt: 3})), [])

  // test index stream behavior

  t.deepEqual(await getStream.array(db.indexes.lastName.createReadStream()), [{key: 1, value: PAUL}, {key: 3, value: TARA}])
  t.deepEqual(await getStream.array(db.indexes.lastName.createReadStream({gt: 'Frazee'})), [{key: 3, value: TARA}])

  t.deepEqual(await getStream.array(db.indexes.lastName.createKeyStream()), [1, 3])
  t.deepEqual(await getStream.array(db.indexes.lastName.createKeyStream({gt: 'Frazee'})), [3])
github semantic-release / semantic-release / test / helpers / mockserver.js View on Github external
async function start() {
  await getStream(await docker.pull(IMAGE));

  container = await docker.createContainer({
    Tty: true,
    Image: IMAGE,
    PortBindings: {[`${MOCK_SERVER_PORT}/tcp`]: [{HostPort: `${MOCK_SERVER_PORT}`}]},
  });
  await container.start();

  try {
    // Wait for the mock server to be ready
    await pRetry(() => got.put(`http://${MOCK_SERVER_HOST}:${MOCK_SERVER_PORT}/status`, {cache: false}), {
      retries: 7,
      minTimeout: 1000,
      factor: 2,
    });
  } catch (_) {
github semantic-release / semantic-release / test / helpers / npm-registry.js View on Github external
async function start() {
  await getStream(await docker.pull(IMAGE));

  container = await docker.createContainer({
    Tty: true,
    Image: IMAGE,
    PortBindings: {[`${COUCHDB_PORT}/tcp`]: [{HostPort: `${SERVER_PORT}`}]},
    Env: [`COUCHDB_USER=${COUCHDB_USER}`, `COUCHDB_PASSWORD=${COUCHDB_PASSWORD}`],
  });

  await container.start();
  await delay(4000);

  try {
    // Wait for the registry to be ready
    await pRetry(() => got(`http://${SERVER_HOST}:${SERVER_PORT}/registry/_design/app`, {cache: false}), {
      retries: 7,
      minTimeout: 1000,
github lukechilds / cacheable-request / test / cache.js View on Github external
cacheableRequest(opts, async response => {
		const body = await getStream(response);
		response.body = body;

		// Give the cache time to update
		await delay(100);

		resolve(response);
	})
		.on('request', req => req.end())
github sindresorhus / neat-csv / index.js View on Github external
module.exports = async (data, options) => {
	if (typeof data === 'string' || Buffer.isBuffer(data)) {
		data = toReadableStream(data);
	}

	// TODO: Use `stream.pipeline` here when targeting Node.js 10
	return getStream.array(data.pipe(csvParser(options)));
};
github npm / libnpmaccess / test / index.js View on Github external
test('ls-collaborators stream', t => {
  const serverCollaborators = {
    'myorg:myteam': 'write',
    'myorg:anotherteam': 'read',
    'myorg:thirdteam': 'special-case'
  }
  const clientCollaborators = [
    ['myorg:myteam', 'read-write'],
    ['myorg:anotherteam', 'read-only'],
    ['myorg:thirdteam', 'special-case']
  ]
  tnock(t, REG).get(
    '/-/package/%40foo%2Fbar/collaborators?format=cli'
  ).reply(200, serverCollaborators)
  return getStream.array(
    access.lsCollaborators.stream('@foo/bar', OPTS)
  ).then(data => {
    t.deepEqual(data, clientCollaborators, 'got collaborators')
  })
})
github staeco / iris-ql / test / Query / executeStream.js View on Github external
it('should work with format and pumpify', async () => {
    const query = new Query({ limit: 1 }, { model: user.scope('public') })
    const stream = await query.executeStream({
      format: json
    })
    should(stream.contentType).eql(json.contentType)
    const res = await collect(pumpify.obj(
      stream,
      through2()
    ))
    should(typeof res).eql('string')
    const parsed = JSON.parse(res)
    parsed.length.should.equal(1)
    should.not.exist(parsed[0].authToken)
    should.exist(parsed[0].name)
  })
  it('should execute with proper model name', async () => {
github szmarczak / http2-wrapper / test / headers.js View on Github external
test('removing headers', wrapper, async (t, server) => {
	const request = makeRequest(server.options);
	request.setHeader('foo', 'bar');
	request.removeHeader('foo');
	request.end();

	const res = await pEvent(request, 'response');
	const data = JSON.parse(await getStream(res));
	t.is(data.headers.foo, undefined);
});
github npm / pacote / test / file.tarball.js View on Github external
return fs.writeFileAsync(tarballPath, tarData).then(() => {
      return getBuff(fetch.tarball(npa(tarballPath), OPTS))
    }).then(data => {
      t.deepEqual(data, tarData, 'fetched tarball data matches one from local')

get-stream

Get a stream as a string, buffer, or array

MIT
Latest version published 1 year ago

Package Health Score

78 / 100
Full package analysis

Popular get-stream functions