🚀 Socket Launch Week 🚀 Day 5: Introducing Socket Fix.Learn More
Socket
Sign inDemoInstall
Socket

@graffy/core

Package Overview
Dependencies
Maintainers
1
Versions
230
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@graffy/core - npm Package Compare versions

Comparing version

to
0.15.3-beta.2

4

cjs/Graffy.js

@@ -10,7 +10,7 @@ "use strict";

var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator"));
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/json/stringify"));
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/json/stringify"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator"));

@@ -17,0 +17,0 @@ var _asyncIterator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncIterator"));

@@ -9,2 +9,6 @@ "use strict";

var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs3/regenerator"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator"));

@@ -18,6 +22,2 @@

var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs3/regenerator"));
var _asyncIterator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncIterator"));

@@ -24,0 +24,0 @@

import { unwrap } from '@graffy/common';
import debug from 'debug';
import { format } from '@graffy/testing';
const log = debug('graffy:core');
var log = debug('graffy:core');

@@ -14,9 +14,8 @@ function resolve(handlers, firstPayload, options) {

const {
path,
handle
} = handlers[i];
var _handlers$i = handlers[i],
path = _handlers$i.path,
handle = _handlers$i.handle;
if (!unwrap(payload, path)) return run(i + 1, payload);
let nextCalled = false;
return handle(payload, options, nextPayload => {
var nextCalled = false;
return handle(payload, options, function (nextPayload) {
if (nextCalled) {

@@ -38,20 +37,29 @@ throw Error('resolve.duplicate_next_call: ' + handlers[i].name);

export default class Core {
constructor() {
var Core = /*#__PURE__*/function () {
function Core() {
this.handlers = {};
}
on(type, path, handle) {
var _proto = Core.prototype;
_proto.on = function on(type, path, handle) {
this.handlers[type] = this.handlers[type] || [];
this.handlers[type].push({
path,
handle
path: path,
handle: handle
});
}
};
call(type, payload, options = {}) {
_proto.call = function call(type, payload, options) {
if (options === void 0) {
options = {};
}
log('call', type, format(payload));
return resolve(this.handlers[type], payload, options);
}
};
}
return Core;
}();
export { Core as default };

@@ -0,1 +1,3 @@

import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
import _asyncIterator from "@babel/runtime/helpers/esm/asyncIterator";
import { decodeGraph, decodeQuery, wrapObject, unwrapObject, encodeGraph, makePath, encodeQuery, finalize, wrap } from '@graffy/common';

@@ -6,5 +8,9 @@ import { makeStream, mapStream } from '@graffy/stream';

function validateArgs(first, ...args) {
let path;
function validateArgs(first) {
var path;
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
try {

@@ -17,3 +23,5 @@ path = makePath(first);

for (const arg of args) {
for (var _i = 0, _args = args; _i < _args.length; _i++) {
var arg = _args[_i];
if (typeof arg !== 'undefined' && typeof arg !== 'object' && typeof arg !== 'function') {

@@ -24,7 +32,15 @@ throw Error('validateArgs.invalid_argument ' + JSON.stringify(arg));

return [path, ...args];
return [path].concat(args);
}
export default class Graffy {
constructor(path = [], core = new Core()) {
var Graffy = /*#__PURE__*/function () {
function Graffy(path, core) {
if (path === void 0) {
path = [];
}
if (core === void 0) {
core = new Core();
}
this.core = core;

@@ -34,83 +50,324 @@ this.path = path;

on(type, ...args) {
const [path, handler] = validateArgs(...args);
var _proto = Graffy.prototype;
_proto.on = function on(type) {
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
args[_key2 - 1] = arguments[_key2];
}
var _validateArgs = validateArgs.apply(void 0, args),
path = _validateArgs[0],
handler = _validateArgs[1];
this.core.on(type, path, handler);
}
};
onRead(...args) {
const [pathArg, handle] = validateArgs(...args);
const path = this.path.concat(pathArg);
this.on('read', path, shiftFn(async function porcelainRead(query, options) {
return finalize(encodeGraph(await handle(decodeQuery(query), options)), query);
}, path));
}
_proto.onRead = function onRead() {
var _validateArgs2 = validateArgs.apply(void 0, arguments),
pathArg = _validateArgs2[0],
handle = _validateArgs2[1];
onWatch(...args) {
const [pathArg, handle] = validateArgs(...args);
const path = this.path.concat(pathArg);
this.on('watch', path, shiftGen(function porcelainWatch(query, options) {
return makeStream((push, end) => {
const subscription = handle(decodeQuery(query), options);
var path = this.path.concat(pathArg);
this.on('read', path, shiftFn( /*#__PURE__*/function () {
var _porcelainRead = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(query, options) {
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.t0 = finalize;
_context.t1 = encodeGraph;
_context.next = 4;
return handle(decodeQuery(query), options);
(async function () {
try {
let firstValue = (await subscription.next()).value;
push(firstValue && finalize(encodeGraph(firstValue), query));
case 4:
_context.t2 = _context.sent;
_context.t3 = (0, _context.t1)(_context.t2);
_context.t4 = query;
return _context.abrupt("return", (0, _context.t0)(_context.t3, _context.t4));
for await (const value of subscription) {
push(value && encodeGraph(value));
case 8:
case "end":
return _context.stop();
}
} catch (e) {
end(e);
}
})();
}, _callee);
}));
return () => subscription.return();
function porcelainRead(_x, _x2) {
return _porcelainRead.apply(this, arguments);
}
return porcelainRead;
}(), path));
};
_proto.onWatch = function onWatch() {
var _validateArgs3 = validateArgs.apply(void 0, arguments),
pathArg = _validateArgs3[0],
handle = _validateArgs3[1];
var path = this.path.concat(pathArg);
this.on('watch', path, shiftGen(function porcelainWatch(query, options) {
return makeStream(function (push, end) {
var subscription = handle(decodeQuery(query), options);
_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
var firstValue, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, value;
return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
_context2.prev = 0;
_context2.next = 3;
return subscription.next();
case 3:
firstValue = _context2.sent.value;
push(firstValue && finalize(encodeGraph(firstValue), query));
_iteratorNormalCompletion = true;
_didIteratorError = false;
_context2.prev = 7;
_iterator = _asyncIterator(subscription);
case 9:
_context2.next = 11;
return _iterator.next();
case 11:
_step = _context2.sent;
_iteratorNormalCompletion = _step.done;
_context2.next = 15;
return _step.value;
case 15:
_value = _context2.sent;
if (_iteratorNormalCompletion) {
_context2.next = 22;
break;
}
value = _value;
push(value && encodeGraph(value));
case 19:
_iteratorNormalCompletion = true;
_context2.next = 9;
break;
case 22:
_context2.next = 28;
break;
case 24:
_context2.prev = 24;
_context2.t0 = _context2["catch"](7);
_didIteratorError = true;
_iteratorError = _context2.t0;
case 28:
_context2.prev = 28;
_context2.prev = 29;
if (!(!_iteratorNormalCompletion && _iterator.return != null)) {
_context2.next = 33;
break;
}
_context2.next = 33;
return _iterator.return();
case 33:
_context2.prev = 33;
if (!_didIteratorError) {
_context2.next = 36;
break;
}
throw _iteratorError;
case 36:
return _context2.finish(33);
case 37:
return _context2.finish(28);
case 38:
_context2.next = 43;
break;
case 40:
_context2.prev = 40;
_context2.t1 = _context2["catch"](0);
end(_context2.t1);
case 43:
case "end":
return _context2.stop();
}
}
}, _callee2, null, [[0, 40], [7, 24, 28, 38], [29,, 33, 37]]);
}))();
return function () {
return subscription.return();
};
});
}, path));
}
};
onWrite(...args) {
const [pathArg, handle] = validateArgs(...args);
const path = this.path.concat(pathArg);
this.on('write', path, shiftFn(async function porcelainWrite(change, options) {
return encodeGraph(await handle(decodeGraph(change), options));
}, path));
}
_proto.onWrite = function onWrite() {
var _validateArgs4 = validateArgs.apply(void 0, arguments),
pathArg = _validateArgs4[0],
handle = _validateArgs4[1];
use(...args) {
const [path, provider] = validateArgs(...args);
var path = this.path.concat(pathArg);
this.on('write', path, shiftFn( /*#__PURE__*/function () {
var _porcelainWrite = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(change, options) {
return regeneratorRuntime.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_context3.t0 = encodeGraph;
_context3.next = 3;
return handle(decodeGraph(change), options);
case 3:
_context3.t1 = _context3.sent;
return _context3.abrupt("return", (0, _context3.t0)(_context3.t1));
case 5:
case "end":
return _context3.stop();
}
}
}, _callee3);
}));
function porcelainWrite(_x3, _x4) {
return _porcelainWrite.apply(this, arguments);
}
return porcelainWrite;
}(), path));
};
_proto.use = function use() {
var _validateArgs5 = validateArgs.apply(void 0, arguments),
path = _validateArgs5[0],
provider = _validateArgs5[1];
provider(new Graffy(path, this.core));
}
};
call(type, payload, options = {}) {
_proto.call = function call(type, payload, options) {
if (options === void 0) {
options = {};
}
return this.core.call(type, payload, options);
}
};
async read(...args) {
const [pathArg, porcelainQuery, options] = validateArgs(...args);
const path = this.path.concat(pathArg);
const rootQuery = wrapObject(porcelainQuery, path);
const query = encodeQuery(rootQuery);
const result = await this.call('read', query, options || {});
return unwrapObject(decodeGraph(result, rootQuery), path);
}
_proto.read = /*#__PURE__*/function () {
var _read = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
var _validateArgs6,
pathArg,
porcelainQuery,
options,
path,
rootQuery,
query,
result,
_args5 = arguments;
watch(...args) {
const [pathArg, porcelainQuery, options] = validateArgs(...args);
const path = this.path.concat(pathArg);
const rootQuery = wrapObject(porcelainQuery, path);
const query = encodeQuery(rootQuery);
const stream = this.call('watch', query, options || {});
return mapStream(stream, value => unwrapObject(decodeGraph(value, rootQuery), path));
}
return regeneratorRuntime.wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
_validateArgs6 = validateArgs.apply(void 0, _args5), pathArg = _validateArgs6[0], porcelainQuery = _validateArgs6[1], options = _validateArgs6[2];
path = this.path.concat(pathArg);
rootQuery = wrapObject(porcelainQuery, path);
query = encodeQuery(rootQuery);
_context4.next = 6;
return this.call('read', query, options || {});
async write(...args) {
const [pathArg, porcelainChange, options] = validateArgs(...args);
const path = this.path.concat(pathArg);
const change = wrap(encodeGraph(porcelainChange), path);
const writtenChange = await this.call('write', change, options || {});
return unwrapObject(decodeGraph(writtenChange), path);
}
case 6:
result = _context4.sent;
return _context4.abrupt("return", unwrapObject(decodeGraph(result, rootQuery), path));
}
case 8:
case "end":
return _context4.stop();
}
}
}, _callee4, this);
}));
function read() {
return _read.apply(this, arguments);
}
return read;
}();
_proto.watch = function watch() {
var _validateArgs7 = validateArgs.apply(void 0, arguments),
pathArg = _validateArgs7[0],
porcelainQuery = _validateArgs7[1],
options = _validateArgs7[2];
var path = this.path.concat(pathArg);
var rootQuery = wrapObject(porcelainQuery, path);
var query = encodeQuery(rootQuery);
var stream = this.call('watch', query, options || {});
return mapStream(stream, function (value) {
return unwrapObject(decodeGraph(value, rootQuery), path);
});
};
_proto.write = /*#__PURE__*/function () {
var _write = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {
var _validateArgs8,
pathArg,
porcelainChange,
options,
path,
change,
writtenChange,
_args6 = arguments;
return regeneratorRuntime.wrap(function _callee5$(_context5) {
while (1) {
switch (_context5.prev = _context5.next) {
case 0:
_validateArgs8 = validateArgs.apply(void 0, _args6), pathArg = _validateArgs8[0], porcelainChange = _validateArgs8[1], options = _validateArgs8[2];
path = this.path.concat(pathArg);
change = wrap(encodeGraph(porcelainChange), path);
_context5.next = 5;
return this.call('write', change, options || {});
case 5:
writtenChange = _context5.sent;
return _context5.abrupt("return", unwrapObject(decodeGraph(writtenChange), path));
case 7:
case "end":
return _context5.stop();
}
}
}, _callee5, this);
}));
function write() {
return _write.apply(this, arguments);
}
return write;
}();
return Graffy;
}();
export { Graffy as default };

@@ -0,83 +1,346 @@

import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
import _wrapAsyncGenerator from "@babel/runtime/helpers/esm/wrapAsyncGenerator";
import _awaitAsyncGenerator from "@babel/runtime/helpers/esm/awaitAsyncGenerator";
import _asyncGeneratorDelegate from "@babel/runtime/helpers/esm/asyncGeneratorDelegate";
import _asyncIterator from "@babel/runtime/helpers/esm/asyncIterator";
import { wrap, unwrap, remove, merge, mergeStreams } from '@graffy/common';
import { makeStream } from '@graffy/stream';
async function mapStream(stream, fn) {
for await (const value of stream) {
fn(value);
}
function mapStream(stream, fn) {
var _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, value;
return regeneratorRuntime.async(function mapStream$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_iteratorNormalCompletion = true;
_didIteratorError = false;
_context.prev = 2;
_iterator = _asyncIterator(stream);
case 4:
_context.next = 6;
return regeneratorRuntime.awrap(_iterator.next());
case 6:
_step = _context.sent;
_iteratorNormalCompletion = _step.done;
_context.next = 10;
return regeneratorRuntime.awrap(_step.value);
case 10:
_value = _context.sent;
if (_iteratorNormalCompletion) {
_context.next = 17;
break;
}
value = _value;
fn(value);
case 14:
_iteratorNormalCompletion = true;
_context.next = 4;
break;
case 17:
_context.next = 23;
break;
case 19:
_context.prev = 19;
_context.t0 = _context["catch"](2);
_didIteratorError = true;
_iteratorError = _context.t0;
case 23:
_context.prev = 23;
_context.prev = 24;
if (!(!_iteratorNormalCompletion && _iterator.return != null)) {
_context.next = 28;
break;
}
_context.next = 28;
return regeneratorRuntime.awrap(_iterator.return());
case 28:
_context.prev = 28;
if (!_didIteratorError) {
_context.next = 31;
break;
}
throw _iteratorError;
case 31:
return _context.finish(28);
case 32:
return _context.finish(23);
case 33:
case "end":
return _context.stop();
}
}
}, null, null, [[2, 19, 23, 33], [24,, 28, 32]], Promise);
}
export function shiftFn(fn, path) {
return async function shiftedFn(payload, options, next) {
let nextCalled = false;
let remainingNextResult;
const unwrappedPayload = unwrap(payload, path);
const remainingPayload = remove(payload, path) || []; // This next function is offered to the provider function.
return /*#__PURE__*/function () {
var _shiftedFn = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(payload, options, next) {
var nextCalled, remainingNextResult, unwrappedPayload, remainingPayload, shiftedNext, _shiftedNext, result;
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.
return regeneratorRuntime.wrap(function _callee2$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_shiftedNext = function _shiftedNext3() {
_shiftedNext = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(unwrappedNextPayload) {
var nextPayload, nextResult;
return regeneratorRuntime.wrap(function _callee$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
nextCalled = true;
nextPayload = wrap(unwrappedNextPayload, path);
if (remainingPayload.length) merge(nextPayload, remainingPayload);
_context2.next = 5;
return next(nextPayload);
remainingNextResult = remove(nextResult, path) || [];
return unwrap(nextResult, path);
}
case 5:
nextResult = _context2.sent;
// Remember the next() results that are not returned to this provider.
// These will be merged into the result later.
remainingNextResult = remove(nextResult, path) || [];
return _context2.abrupt("return", unwrap(nextResult, path));
const result = wrap(await fn(unwrappedPayload, options, shiftedNext), path);
case 8:
case "end":
return _context2.stop();
}
}
}, _callee);
}));
return _shiftedNext.apply(this, arguments);
};
if (!nextCalled && remainingPayload.length) {
remainingNextResult = await next(remainingPayload);
}
shiftedNext = function _shiftedNext2(_x8) {
return _shiftedNext.apply(this, arguments);
};
if (remainingNextResult && remainingNextResult.length) {
merge(result, remainingNextResult);
nextCalled = false;
unwrappedPayload = unwrap(payload, path);
remainingPayload = remove(payload, path) || []; // This next function is offered to the provider function.
_context3.t0 = wrap;
_context3.next = 8;
return fn(unwrappedPayload, options, shiftedNext);
case 8:
_context3.t1 = _context3.sent;
_context3.t2 = path;
result = (0, _context3.t0)(_context3.t1, _context3.t2);
if (!(!nextCalled && remainingPayload.length)) {
_context3.next = 15;
break;
}
_context3.next = 14;
return next(remainingPayload);
case 14:
remainingNextResult = _context3.sent;
case 15:
if (remainingNextResult && remainingNextResult.length) {
merge(result, remainingNextResult);
}
return _context3.abrupt("return", result);
case 17:
case "end":
return _context3.stop();
}
}
}, _callee2);
}));
function shiftedFn(_x5, _x6, _x7) {
return _shiftedFn.apply(this, arguments);
}
return result;
};
return shiftedFn;
}();
} // TODO: Provider calling next in a subscription function is not tested.
export function shiftGen(fn, path) {
return async function* shiftedGen(payload, options, next) {
let nextCalled = false;
let remainingNextStream;
const unwrappedPayload = unwrap(payload, path);
const remainingPayload = remove(payload, path) || []; // TODO: This should probably use makeStream and propagate returns.
return /*#__PURE__*/function () {
var _shiftedGen = _wrapAsyncGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(payload, options, next) {
var nextCalled, remainingNextStream, unwrappedPayload, remainingPayload, shiftedNext, unwrappedStream, firstValue, resultStream;
return regeneratorRuntime.wrap(function _callee4$(_context5) {
while (1) {
switch (_context5.prev = _context5.next) {
case 0:
nextCalled = false;
unwrappedPayload = unwrap(payload, path);
remainingPayload = remove(payload, path) || []; // TODO: This should probably use makeStream and propagate returns.
const shiftedNext = async function* shiftedNextFn(unwrappedNextPayload) {
nextCalled = true;
const nextPayload = wrap(unwrappedNextPayload, path);
if (remainingPayload.length) merge(nextPayload, remainingPayload);
let pushRemaining;
remainingNextStream = makeStream(push => {
pushRemaining = push;
});
shiftedNext = /*#__PURE__*/function () {
var _shiftedNextFn = _wrapAsyncGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(unwrappedNextPayload) {
var nextPayload, pushRemaining, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, _value2, value, unwrappedValue, remainingValue;
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;
}
};
return regeneratorRuntime.wrap(function _callee3$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
nextCalled = true;
nextPayload = wrap(unwrappedNextPayload, path);
if (remainingPayload.length) merge(nextPayload, remainingPayload);
remainingNextStream = makeStream(function (push) {
pushRemaining = push;
});
_iteratorNormalCompletion2 = true;
_didIteratorError2 = false;
_context4.prev = 6;
_iterator2 = _asyncIterator(next(nextPayload));
const unwrappedStream = fn(unwrappedPayload, options, shiftedNext); // We expect next() to be called before the first value is yielded.
case 8:
_context4.next = 10;
return _awaitAsyncGenerator(_iterator2.next());
const firstValue = await (await unwrappedStream.next()).value;
const resultStream = makeStream(push => {
push(wrap(firstValue, path));
mapStream(unwrappedStream, value => {
push(wrap(value, path));
});
return () => unwrappedStream.return();
});
case 10:
_step2 = _context4.sent;
_iteratorNormalCompletion2 = _step2.done;
_context4.next = 14;
return _awaitAsyncGenerator(_step2.value);
if (!nextCalled && remainingPayload.length) {
remainingNextStream = next(remainingPayload);
case 14:
_value2 = _context4.sent;
if (_iteratorNormalCompletion2) {
_context4.next = 26;
break;
}
value = _value2;
unwrappedValue = unwrap(value, path);
remainingValue = remove(value, path);
if (remainingValue) pushRemaining(remainingValue);
if (!unwrappedValue) {
_context4.next = 23;
break;
}
_context4.next = 23;
return unwrappedValue;
case 23:
_iteratorNormalCompletion2 = true;
_context4.next = 8;
break;
case 26:
_context4.next = 32;
break;
case 28:
_context4.prev = 28;
_context4.t0 = _context4["catch"](6);
_didIteratorError2 = true;
_iteratorError2 = _context4.t0;
case 32:
_context4.prev = 32;
_context4.prev = 33;
if (!(!_iteratorNormalCompletion2 && _iterator2.return != null)) {
_context4.next = 37;
break;
}
_context4.next = 37;
return _awaitAsyncGenerator(_iterator2.return());
case 37:
_context4.prev = 37;
if (!_didIteratorError2) {
_context4.next = 40;
break;
}
throw _iteratorError2;
case 40:
return _context4.finish(37);
case 41:
return _context4.finish(32);
case 42:
case "end":
return _context4.stop();
}
}
}, _callee3, null, [[6, 28, 32, 42], [33,, 37, 41]]);
}));
function shiftedNextFn(_x4) {
return _shiftedNextFn.apply(this, arguments);
}
return shiftedNextFn;
}();
unwrappedStream = fn(unwrappedPayload, options, shiftedNext); // We expect next() to be called before the first value is yielded.
_context5.t0 = _awaitAsyncGenerator;
_context5.next = 8;
return _awaitAsyncGenerator(unwrappedStream.next());
case 8:
_context5.t1 = _context5.sent.value;
_context5.next = 11;
return (0, _context5.t0)(_context5.t1);
case 11:
firstValue = _context5.sent;
resultStream = makeStream(function (push) {
push(wrap(firstValue, path));
mapStream(unwrappedStream, function (value) {
push(wrap(value, path));
});
return function () {
return unwrappedStream.return();
};
});
if (!nextCalled && remainingPayload.length) {
remainingNextStream = next(remainingPayload);
}
return _context5.delegateYield(_asyncGeneratorDelegate(_asyncIterator(remainingNextStream ? mergeStreams(resultStream, remainingNextStream) : resultStream), _awaitAsyncGenerator), "t2", 15);
case 15:
case "end":
return _context5.stop();
}
}
}, _callee4);
}));
function shiftedGen(_x, _x2, _x3) {
return _shiftedGen.apply(this, arguments);
}
yield* remainingNextStream ? mergeStreams(resultStream, remainingNextStream) : resultStream;
};
return shiftedGen;
}();
}
import wrappers from './wrappers';
export default function wrapProvider(provider, options = {}) {
const {
decode,
shift,
finalize,
_debounce,
link,
_fetch,
_watch
} = options;
export default function wrapProvider(provider, options) {
if (options === void 0) {
options = {};
}
var _options = options,
decode = _options.decode,
shift = _options.shift,
finalize = _options.finalize,
_debounce = _options._debounce,
link = _options.link,
_fetch = _options._fetch,
_watch = _options._watch;
/*

@@ -13,0 +16,0 @@ The wrapper closest to the user-supplied provider should be applied first.

@@ -5,5 +5,6 @@ {

"author": "aravind (https://github.com/aravindet)",
"version": "0.15.3-beta.1",
"version": "0.15.3-beta.2",
"main": "./cjs/index.js",
"module": "./esm/index.js",
"types": "./types/index.d.ts",
"repository": {

@@ -17,7 +18,7 @@ "type": "git",

"@babel/runtime-corejs3": "^7.10.4",
"@graffy/common": "0.15.3-beta.1",
"@graffy/common": "0.15.3-beta.2",
"debug": "^4.1.1",
"@graffy/testing": "0.15.3-beta.1",
"@graffy/stream": "0.15.3-beta.1"
"@graffy/testing": "0.15.3-beta.2",
"@graffy/stream": "0.15.3-beta.2"
}
}