Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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])
})
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])
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)));
};
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')
})
})
{
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));
});
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;
});
}
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));
});
it('should get bandwidth stats over readable stream', async () => {
const stream = ipfs.stats.bwReadableStream()
const [data] = await getStream.array(stream)
expectIsBandwidth(null, data)
})
})
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)
}
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'