@graffy/core
Advanced tools
Comparing version 0.14.6-beta5 to 0.14.6
@@ -42,3 +42,5 @@ "use strict"; | ||
var Core = /*#__PURE__*/function () { | ||
var Core = | ||
/*#__PURE__*/ | ||
function () { | ||
function Core() { | ||
@@ -45,0 +47,0 @@ this.handlers = {}; |
@@ -12,6 +12,6 @@ "use strict"; | ||
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 _asyncIterator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncIterator")); | ||
@@ -46,3 +46,3 @@ | ||
if (typeof arg !== 'object' && typeof arg !== 'function') { | ||
if (typeof arg !== 'undefined' && typeof arg !== 'object' && typeof arg !== 'function') { | ||
throw Error('validateArgs.invalid_argument ' + (0, _stringify["default"])(arg)); | ||
@@ -55,3 +55,5 @@ } | ||
var Graffy = /*#__PURE__*/function () { | ||
var Graffy = | ||
/*#__PURE__*/ | ||
function () { | ||
function Graffy(path, core) { | ||
@@ -93,4 +95,8 @@ if (path === void 0) { | ||
this.on('read', path, /*#__PURE__*/function () { | ||
var _porcelainRead = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(query, options) { | ||
this.on('read', path, | ||
/*#__PURE__*/ | ||
function () { | ||
var _porcelainRead = (0, _asyncToGenerator2["default"])( | ||
/*#__PURE__*/ | ||
_regenerator["default"].mark(function _callee(query, options) { | ||
return _regenerator["default"].wrap(function _callee$(_context3) { | ||
@@ -135,3 +141,5 @@ while (1) { | ||
var subscription = handle((0, _common.decorateQuery)(query), options); | ||
(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() { | ||
(0, _asyncToGenerator2["default"])( | ||
/*#__PURE__*/ | ||
_regenerator["default"].mark(function _callee2() { | ||
var firstValue, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, value; | ||
@@ -247,4 +255,8 @@ | ||
this.on('write', path, /*#__PURE__*/function () { | ||
var _porcelainWrite = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(change, options) { | ||
this.on('write', path, | ||
/*#__PURE__*/ | ||
function () { | ||
var _porcelainWrite = (0, _asyncToGenerator2["default"])( | ||
/*#__PURE__*/ | ||
_regenerator["default"].mark(function _callee3(change, options) { | ||
return _regenerator["default"].wrap(function _callee3$(_context5) { | ||
@@ -300,4 +312,8 @@ while (1) { | ||
_proto.read = /*#__PURE__*/function () { | ||
var _read = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4() { | ||
_proto.read = | ||
/*#__PURE__*/ | ||
function () { | ||
var _read = (0, _asyncToGenerator2["default"])( | ||
/*#__PURE__*/ | ||
_regenerator["default"].mark(function _callee4() { | ||
var _validateArgs6, | ||
@@ -352,4 +368,8 @@ path, | ||
_proto.write = /*#__PURE__*/function () { | ||
var _write = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5() { | ||
_proto.write = | ||
/*#__PURE__*/ | ||
function () { | ||
var _write = (0, _asyncToGenerator2["default"])( | ||
/*#__PURE__*/ | ||
_regenerator["default"].mark(function _callee5() { | ||
var _validateArgs8, | ||
@@ -356,0 +376,0 @@ path, |
@@ -5,3 +5,3 @@ { | ||
"author": "aravind (https://github.com/aravindet)", | ||
"version": "0.14.6-beta5", | ||
"version": "0.14.6", | ||
"main": "index.js", | ||
@@ -17,5 +17,5 @@ "source": "src/index.js", | ||
"@babel/runtime-corejs3": "^7.9.2", | ||
"@graffy/common": "0.14.6-beta5", | ||
"@graffy/stream": "0.14.6-beta5" | ||
"@graffy/common": "0.14.6", | ||
"@graffy/stream": "0.14.6" | ||
} | ||
} |
412
shift.js
@@ -30,3 +30,5 @@ "use strict"; | ||
function _mapStream() { | ||
_mapStream = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(stream, fn) { | ||
_mapStream = (0, _asyncToGenerator2["default"])( | ||
/*#__PURE__*/ | ||
_regenerator["default"].mark(function _callee5(stream, fn) { | ||
var _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, value; | ||
@@ -118,89 +120,96 @@ | ||
function shiftFn(fn, path) { | ||
return /*#__PURE__*/function () { | ||
var _shiftedFn = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(payload, options, next) { | ||
var nextCalled, remainingNextResult, unwrappedPayload, remainingPayload, shiftedNext, _shiftedNext, result; | ||
return ( | ||
/*#__PURE__*/ | ||
function () { | ||
var _shiftedFn = (0, _asyncToGenerator2["default"])( | ||
/*#__PURE__*/ | ||
_regenerator["default"].mark(function _callee2(payload, options, next) { | ||
var nextCalled, remainingNextResult, unwrappedPayload, remainingPayload, shiftedNext, _shiftedNext, result; | ||
return _regenerator["default"].wrap(function _callee2$(_context2) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
_shiftedNext = function _shiftedNext3() { | ||
_shiftedNext = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(unwrappedNextPayload) { | ||
var nextPayload, nextResult; | ||
return _regenerator["default"].wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
nextCalled = true; | ||
nextPayload = (0, _common.wrap)(unwrappedNextPayload, path); | ||
if (remainingPayload.length) (0, _common.merge)(nextPayload, remainingPayload); | ||
_context.next = 5; | ||
return next(nextPayload); | ||
return _regenerator["default"].wrap(function _callee2$(_context2) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
_shiftedNext = function _ref2() { | ||
_shiftedNext = (0, _asyncToGenerator2["default"])( | ||
/*#__PURE__*/ | ||
_regenerator["default"].mark(function _callee(unwrappedNextPayload) { | ||
var nextPayload, nextResult; | ||
return _regenerator["default"].wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
nextCalled = true; | ||
nextPayload = (0, _common.wrap)(unwrappedNextPayload, path); | ||
if (remainingPayload.length) (0, _common.merge)(nextPayload, remainingPayload); | ||
_context.next = 5; | ||
return next(nextPayload); | ||
case 5: | ||
nextResult = _context.sent; | ||
// Remember the next() results that are not returned to this provider. | ||
// These will be merged into the result later. | ||
remainingNextResult = (0, _common.remove)(nextResult, path) || []; | ||
return _context.abrupt("return", (0, _common.unwrap)(nextResult, path)); | ||
case 5: | ||
nextResult = _context.sent; | ||
// Remember the next() results that are not returned to this provider. | ||
// These will be merged into the result later. | ||
remainingNextResult = (0, _common.remove)(nextResult, path) || []; | ||
return _context.abrupt("return", (0, _common.unwrap)(nextResult, path)); | ||
case 8: | ||
case "end": | ||
return _context.stop(); | ||
case 8: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
} | ||
}, _callee); | ||
})); | ||
return _shiftedNext.apply(this, arguments); | ||
}; | ||
}, _callee); | ||
})); | ||
return _shiftedNext.apply(this, arguments); | ||
}; | ||
shiftedNext = function _shiftedNext2(_x10) { | ||
return _shiftedNext.apply(this, arguments); | ||
}; | ||
shiftedNext = function _ref(_x10) { | ||
return _shiftedNext.apply(this, arguments); | ||
}; | ||
nextCalled = false; | ||
unwrappedPayload = (0, _common.unwrap)(payload, path); | ||
remainingPayload = (0, _common.remove)(payload, path) || []; // This next function is offered to the provider function. | ||
nextCalled = false; | ||
unwrappedPayload = (0, _common.unwrap)(payload, path); | ||
remainingPayload = (0, _common.remove)(payload, path) || []; // This next function is offered to the provider function. | ||
_context2.t0 = _common.wrap; | ||
_context2.next = 8; | ||
return fn(unwrappedPayload, options, shiftedNext); | ||
_context2.t0 = _common.wrap; | ||
_context2.next = 8; | ||
return fn(unwrappedPayload, options, shiftedNext); | ||
case 8: | ||
_context2.t1 = _context2.sent; | ||
_context2.t2 = path; | ||
result = (0, _context2.t0)(_context2.t1, _context2.t2); | ||
case 8: | ||
_context2.t1 = _context2.sent; | ||
_context2.t2 = path; | ||
result = (0, _context2.t0)(_context2.t1, _context2.t2); | ||
if (!(!nextCalled && remainingPayload.length)) { | ||
_context2.next = 15; | ||
break; | ||
} | ||
if (!(!nextCalled && remainingPayload.length)) { | ||
_context2.next = 15; | ||
break; | ||
} | ||
_context2.next = 14; | ||
return next(remainingPayload); | ||
_context2.next = 14; | ||
return next(remainingPayload); | ||
case 14: | ||
remainingNextResult = _context2.sent; | ||
case 14: | ||
remainingNextResult = _context2.sent; | ||
case 15: | ||
if (remainingNextResult && remainingNextResult.length) { | ||
(0, _common.merge)(result, remainingNextResult); | ||
} | ||
case 15: | ||
if (remainingNextResult && remainingNextResult.length) { | ||
(0, _common.merge)(result, remainingNextResult); | ||
} | ||
return _context2.abrupt("return", result); | ||
return _context2.abrupt("return", result); | ||
case 17: | ||
case "end": | ||
return _context2.stop(); | ||
case 17: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
} | ||
} | ||
}, _callee2); | ||
})); | ||
}, _callee2); | ||
})); | ||
function shiftedFn(_x7, _x8, _x9) { | ||
return _shiftedFn.apply(this, arguments); | ||
} | ||
function shiftedFn(_x7, _x8, _x9) { | ||
return _shiftedFn.apply(this, arguments); | ||
} | ||
return shiftedFn; | ||
}(); | ||
return shiftedFn; | ||
}() | ||
); | ||
} // TODO: Provider calling next in a subscription function is not tested. | ||
@@ -210,164 +219,173 @@ | ||
function shiftGen(fn, path) { | ||
return /*#__PURE__*/function () { | ||
var _shiftedGen = (0, _wrapAsyncGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(payload, options, next) { | ||
var nextCalled, remainingNextStream, unwrappedPayload, remainingPayload, shiftedNext, unwrappedStream, firstValue, resultStream; | ||
return _regenerator["default"].wrap(function _callee4$(_context4) { | ||
while (1) { | ||
switch (_context4.prev = _context4.next) { | ||
case 0: | ||
nextCalled = false; | ||
unwrappedPayload = (0, _common.unwrap)(payload, path); | ||
remainingPayload = (0, _common.remove)(payload, path) || []; // TODO: This should probably use makeStream and propagate returns. | ||
return ( | ||
/*#__PURE__*/ | ||
function () { | ||
var _shiftedGen = (0, _wrapAsyncGenerator2["default"])( | ||
/*#__PURE__*/ | ||
_regenerator["default"].mark(function _callee4(payload, options, next) { | ||
var nextCalled, remainingNextStream, unwrappedPayload, remainingPayload, shiftedNext, unwrappedStream, firstValue, resultStream; | ||
return _regenerator["default"].wrap(function _callee4$(_context4) { | ||
while (1) { | ||
switch (_context4.prev = _context4.next) { | ||
case 0: | ||
nextCalled = false; | ||
unwrappedPayload = (0, _common.unwrap)(payload, path); | ||
remainingPayload = (0, _common.remove)(payload, path) || []; // TODO: This should probably use makeStream and propagate returns. | ||
shiftedNext = /*#__PURE__*/function () { | ||
var _shiftedNextFn = (0, _wrapAsyncGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(unwrappedNextPayload) { | ||
var nextPayload, pushRemaining, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, _value2, value, unwrappedValue, remainingValue; | ||
shiftedNext = | ||
/*#__PURE__*/ | ||
function () { | ||
var _shiftedNextFn = (0, _wrapAsyncGenerator2["default"])( | ||
/*#__PURE__*/ | ||
_regenerator["default"].mark(function _callee3(unwrappedNextPayload) { | ||
var nextPayload, pushRemaining, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, _value2, value, unwrappedValue, remainingValue; | ||
return _regenerator["default"].wrap(function _callee3$(_context3) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
case 0: | ||
nextCalled = true; | ||
nextPayload = (0, _common.wrap)(unwrappedNextPayload, path); | ||
if (remainingPayload.length) (0, _common.merge)(nextPayload, remainingPayload); | ||
remainingNextStream = (0, _stream.makeStream)(function (push) { | ||
pushRemaining = push; | ||
}); | ||
_iteratorNormalCompletion2 = true; | ||
_didIteratorError2 = false; | ||
_context3.prev = 6; | ||
_iterator2 = (0, _asyncIterator2["default"])(next(nextPayload)); | ||
return _regenerator["default"].wrap(function _callee3$(_context3) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
case 0: | ||
nextCalled = true; | ||
nextPayload = (0, _common.wrap)(unwrappedNextPayload, path); | ||
if (remainingPayload.length) (0, _common.merge)(nextPayload, remainingPayload); | ||
remainingNextStream = (0, _stream.makeStream)(function (push) { | ||
pushRemaining = push; | ||
}); | ||
_iteratorNormalCompletion2 = true; | ||
_didIteratorError2 = false; | ||
_context3.prev = 6; | ||
_iterator2 = (0, _asyncIterator2["default"])(next(nextPayload)); | ||
case 8: | ||
_context3.next = 10; | ||
return (0, _awaitAsyncGenerator2["default"])(_iterator2.next()); | ||
case 8: | ||
_context3.next = 10; | ||
return (0, _awaitAsyncGenerator2["default"])(_iterator2.next()); | ||
case 10: | ||
_step2 = _context3.sent; | ||
_iteratorNormalCompletion2 = _step2.done; | ||
_context3.next = 14; | ||
return (0, _awaitAsyncGenerator2["default"])(_step2.value); | ||
case 10: | ||
_step2 = _context3.sent; | ||
_iteratorNormalCompletion2 = _step2.done; | ||
_context3.next = 14; | ||
return (0, _awaitAsyncGenerator2["default"])(_step2.value); | ||
case 14: | ||
_value2 = _context3.sent; | ||
case 14: | ||
_value2 = _context3.sent; | ||
if (_iteratorNormalCompletion2) { | ||
_context3.next = 26; | ||
break; | ||
} | ||
if (_iteratorNormalCompletion2) { | ||
_context3.next = 26; | ||
break; | ||
} | ||
value = _value2; | ||
unwrappedValue = (0, _common.unwrap)(value, path); | ||
remainingValue = (0, _common.remove)(value, path); | ||
if (remainingValue) pushRemaining(remainingValue); | ||
value = _value2; | ||
unwrappedValue = (0, _common.unwrap)(value, path); | ||
remainingValue = (0, _common.remove)(value, path); | ||
if (remainingValue) pushRemaining(remainingValue); | ||
if (!unwrappedValue) { | ||
if (!unwrappedValue) { | ||
_context3.next = 23; | ||
break; | ||
} | ||
_context3.next = 23; | ||
return unwrappedValue; | ||
case 23: | ||
_iteratorNormalCompletion2 = true; | ||
_context3.next = 8; | ||
break; | ||
} | ||
_context3.next = 23; | ||
return unwrappedValue; | ||
case 26: | ||
_context3.next = 32; | ||
break; | ||
case 23: | ||
_iteratorNormalCompletion2 = true; | ||
_context3.next = 8; | ||
break; | ||
case 28: | ||
_context3.prev = 28; | ||
_context3.t0 = _context3["catch"](6); | ||
_didIteratorError2 = true; | ||
_iteratorError2 = _context3.t0; | ||
case 26: | ||
_context3.next = 32; | ||
break; | ||
case 32: | ||
_context3.prev = 32; | ||
_context3.prev = 33; | ||
case 28: | ||
_context3.prev = 28; | ||
_context3.t0 = _context3["catch"](6); | ||
_didIteratorError2 = true; | ||
_iteratorError2 = _context3.t0; | ||
if (!(!_iteratorNormalCompletion2 && _iterator2["return"] != null)) { | ||
_context3.next = 37; | ||
break; | ||
} | ||
case 32: | ||
_context3.prev = 32; | ||
_context3.prev = 33; | ||
if (!(!_iteratorNormalCompletion2 && _iterator2["return"] != null)) { | ||
_context3.next = 37; | ||
break; | ||
} | ||
return (0, _awaitAsyncGenerator2["default"])(_iterator2["return"]()); | ||
_context3.next = 37; | ||
return (0, _awaitAsyncGenerator2["default"])(_iterator2["return"]()); | ||
case 37: | ||
_context3.prev = 37; | ||
case 37: | ||
_context3.prev = 37; | ||
if (!_didIteratorError2) { | ||
_context3.next = 40; | ||
break; | ||
} | ||
if (!_didIteratorError2) { | ||
_context3.next = 40; | ||
break; | ||
} | ||
throw _iteratorError2; | ||
throw _iteratorError2; | ||
case 40: | ||
return _context3.finish(37); | ||
case 40: | ||
return _context3.finish(37); | ||
case 41: | ||
return _context3.finish(32); | ||
case 41: | ||
return _context3.finish(32); | ||
case 42: | ||
case "end": | ||
return _context3.stop(); | ||
case 42: | ||
case "end": | ||
return _context3.stop(); | ||
} | ||
} | ||
} | ||
}, _callee3, null, [[6, 28, 32, 42], [33,, 37, 41]]); | ||
})); | ||
}, _callee3, null, [[6, 28, 32, 42], [33,, 37, 41]]); | ||
})); | ||
function shiftedNextFn(_x4) { | ||
return _shiftedNextFn.apply(this, arguments); | ||
} | ||
function shiftedNextFn(_x4) { | ||
return _shiftedNextFn.apply(this, arguments); | ||
} | ||
return shiftedNextFn; | ||
}(); | ||
return shiftedNextFn; | ||
}(); | ||
unwrappedStream = fn(unwrappedPayload, options, shiftedNext); // We expect next() to be called before the first value is yielded. | ||
unwrappedStream = fn(unwrappedPayload, options, shiftedNext); // We expect next() to be called before the first value is yielded. | ||
_context4.t0 = _awaitAsyncGenerator2["default"]; | ||
_context4.next = 8; | ||
return (0, _awaitAsyncGenerator2["default"])(unwrappedStream.next()); | ||
_context4.t0 = _awaitAsyncGenerator2["default"]; | ||
_context4.next = 8; | ||
return (0, _awaitAsyncGenerator2["default"])(unwrappedStream.next()); | ||
case 8: | ||
_context4.t1 = _context4.sent.value; | ||
_context4.next = 11; | ||
return (0, _context4.t0)(_context4.t1); | ||
case 8: | ||
_context4.t1 = _context4.sent.value; | ||
_context4.next = 11; | ||
return (0, _context4.t0)(_context4.t1); | ||
case 11: | ||
firstValue = _context4.sent; | ||
resultStream = (0, _stream.makeStream)(function (push) { | ||
push((0, _common.wrap)(firstValue, path)); | ||
mapStream(unwrappedStream, function (value) { | ||
push((0, _common.wrap)(value, path)); | ||
case 11: | ||
firstValue = _context4.sent; | ||
resultStream = (0, _stream.makeStream)(function (push) { | ||
push((0, _common.wrap)(firstValue, path)); | ||
mapStream(unwrappedStream, function (value) { | ||
push((0, _common.wrap)(value, path)); | ||
}); | ||
return function () { | ||
return unwrappedStream["return"](); | ||
}; | ||
}); | ||
return function () { | ||
return unwrappedStream["return"](); | ||
}; | ||
}); | ||
if (!nextCalled && remainingPayload.length) { | ||
remainingNextStream = next(remainingPayload); | ||
} | ||
if (!nextCalled && remainingPayload.length) { | ||
remainingNextStream = next(remainingPayload); | ||
} | ||
return _context4.delegateYield((0, _asyncGeneratorDelegate2["default"])((0, _asyncIterator2["default"])(remainingNextStream ? (0, _common.mergeStreams)(resultStream, remainingNextStream) : resultStream), _awaitAsyncGenerator2["default"]), "t2", 15); | ||
return _context4.delegateYield((0, _asyncGeneratorDelegate2["default"])((0, _asyncIterator2["default"])(remainingNextStream ? (0, _common.mergeStreams)(resultStream, remainingNextStream) : resultStream), _awaitAsyncGenerator2["default"]), "t2", 15); | ||
case 15: | ||
case "end": | ||
return _context4.stop(); | ||
case 15: | ||
case "end": | ||
return _context4.stop(); | ||
} | ||
} | ||
} | ||
}, _callee4); | ||
})); | ||
}, _callee4); | ||
})); | ||
function shiftedGen(_x, _x2, _x3) { | ||
return _shiftedGen.apply(this, arguments); | ||
} | ||
function shiftedGen(_x, _x2, _x3) { | ||
return _shiftedGen.apply(this, arguments); | ||
} | ||
return shiftedGen; | ||
}(); | ||
return shiftedGen; | ||
}() | ||
); | ||
} |
@@ -26,3 +26,7 @@ import { | ||
for (const arg of args) { | ||
if (typeof arg !== 'object' && typeof arg !== 'function') { | ||
if ( | ||
typeof arg !== 'undefined' && | ||
typeof arg !== 'object' && | ||
typeof arg !== 'function' | ||
) { | ||
throw Error('validateArgs.invalid_argument ' + JSON.stringify(arg)); | ||
@@ -29,0 +33,0 @@ } |
37575
917
+ Added@graffy/common@0.14.6(transitive)
+ Added@graffy/stream@0.14.6(transitive)
- Removed@graffy/common@0.14.6-beta5(transitive)
- Removed@graffy/stream@0.14.6-beta5(transitive)
Updated@graffy/common@0.14.6
Updated@graffy/stream@0.14.6