How to use the get-stream.array function in get-stream

To help you get started, we’ve selected a few get-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 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 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 jamesramsay / hercule / test / units / trim.js View on Github external
{
      content: 'dog',
      parents: [],
      source: 'index.md',
    },
    {
      content: '\n',
      parents: ['index.md'],
      source: 'activity.md',
    },
  ];
  const testStream = new Trim();

  spigot({ objectMode: true }, input).pipe(testStream);

  getStream
    .array(testStream)
    .then(output => {
      t.deepEqual(output, expect);
      t.end();
    })
    .catch(err => t.fail(err));
});
github semantic-release / semantic-release / test / helpers / git-utils.js View on Github external
export async function gitGetCommits(from, execaOpts) {
  Object.assign(gitLogParser.fields, {hash: 'H', message: 'B', gitTags: 'd', committerDate: {key: 'ci', type: Date}});
  return (
    await getStream.array(
      gitLogParser.parse({_: `${from ? from + '..' : ''}HEAD`}, {...execaOpts, env: {...process.env, ...execaOpts.env}})
    )
  ).map(commit => {
    commit.message = commit.message.trim();
    commit.gitTags = commit.gitTags.trim();
    return commit;
  });
}
github jamesramsay / hercule / test / units / transclude.js View on Github external
test.cb('should pass through objects unmodified', t => {
  const input = [{ content: 'Hello world!' }];
  const testStream = transclude();

  spigot({ objectMode: true }, input).pipe(testStream);

  getStream
    .array(testStream)
    .then(output => {
      t.deepEqual(output, input);
      t.end();
    })
    .catch(err => t.fail(err));
});
github ipfs / interface-js-ipfs-core / src / stats / bw-readable-stream.js View on Github external
it('should get bandwidth stats over readable stream', async () => {
      const stream = ipfs.stats.bwReadableStream()

      const [data] = await getStream.array(stream)

      expectIsBandwidth(null, data)
    })
  })
github etalab / decoupage-administratif / build / util.js View on Github external
async function extractDataFromFile(path) {
  const [file] = await decompress(path)
  const stream = pumpify(
    intoStream(file.data),
    decodeStream('win1252'),
    parse({separator: '\t', strict: true})
  )
  return getStream(stream)
}
github ipfs / interface-js-ipfs-core / src / files-regular / ls-readable-stream.js View on Github external
emptyDir('empty-folder'),
        content('files/hello.txt'),
        content('files/ipfs.txt'),
        emptyDir('files/empty')
      ]

      const res = await ipfs.add(dirs)

      const root = res[res.length - 1]
      expect(root.path).to.equal('test-folder')
      expect(root.hash).to.equal(fixtures.directory.cid)

      const cid = 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP'
      const stream = ipfs.lsReadableStream(cid)

      const files = await getStream.array(stream)
      expect(files).to.eql([
        {
          depth: 1,
          name: 'alice.txt',
          path: 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/alice.txt',
          size: 11685,
          hash: 'QmZyUEQVuRK3XV7L9Dk26pg6RVSgaYkiSTEdnT2kZZdwoi',
          type: 'file'
        },
        {
          depth: 1,
          name: 'empty-folder',
          path: 'QmVvjDy7yF7hdnqE8Hrf4MHo5ABDtb5AbX6hWbD3Y42bXP/empty-folder',
          size: 0,
          hash: 'QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn',
          type: 'dir'

get-stream

Get a stream as a string, Buffer, ArrayBuffer or array

MIT
Latest version published 8 months ago

Package Health Score

87 / 100
Full package analysis

Popular get-stream functions