Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function shiftedNext(unwrappedNextPayload) {
nextCalled = true;
const nextPayload = wrap(unwrappedNextPayload, path);
if (remainingPayload.length) merge(nextPayload, remainingPayload);
const nextResult = await next(nextPayload);
// Remember the next() results that are not returned to this provider.
// These will be merged into the result later.
remainingNextResult = remove(nextResult, path) || [];
return unwrap(nextResult, path);
}
const remainingPayload = remove(payload, path) || [];
// This next function is offered to the provider function.
async function shiftedNext(unwrappedNextPayload) {
nextCalled = true;
const nextPayload = wrap(unwrappedNextPayload, path);
if (remainingPayload.length) merge(nextPayload, remainingPayload);
const nextResult = await next(nextPayload);
// Remember the next() results that are not returned to this provider.
// These will be merged into the result later.
remainingNextResult = remove(nextResult, path) || [];
return unwrap(nextResult, path);
}
const result = wrap(await fn(unwrappedPayload, options, shiftedNext), path);
if (!nextCalled && remainingPayload.length) {
remainingNextResult = await next(remainingPayload);
}
if (remainingNextResult && remainingNextResult.length) {
merge(result, remainingNextResult);
}
return result;
};
}
call(type, unwrappedPayload, options) {
const payload = wrap(unwrappedPayload, this.path);
const result = this.core.call(type, payload, options);
return unwrap(result, this.path);
}
mapStream(unwrappedStream, value => {
push(wrap(value, path));
});
return () => unwrappedStream.return();
const shiftedNext = async function*(unwrappedNextPayload) {
nextCalled = true;
const nextPayload = wrap(unwrappedNextPayload, path);
if (remainingPayload.length) merge(nextPayload, remainingPayload);
let pushRemaining;
remainingNextStream = makeStream(push => {
pushRemaining = push;
});
for await (const value of next(nextPayload)) {
const unwrappedValue = unwrap(value, path);
const remainingValue = remove(value, path);
if (remainingValue) pushRemaining(remainingValue);
if (unwrappedValue) yield unwrappedValue;
}
};
const resultStream = makeStream(push => {
push(wrap(firstValue, path));
mapStream(unwrappedStream, value => {
push(wrap(value, path));
});
return () => unwrappedStream.return();
});
async *watch(...args) {
const [path, porcelainQuery, options] = validateArgs(...args);
const query = wrap(makeQuery(porcelainQuery), path);
const stream = this.call('watch', query, options || {});
for await (const value of stream) yield descend(decorate(value), path);
}