Huge News!Announcing our $40M Series B led by Abstract Ventures.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 0.14.7-alpha.9 to 0.14.7-alpha.10

42

Core.js

@@ -6,3 +6,3 @@ "use strict";

exports.__esModule = true;
exports["default"] = void 0;
exports.default = void 0;

@@ -18,11 +18,12 @@ var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/json/stringify"));

if (i >= handlers.length) {
throw Error('resolve.no_providers_for ' + (0, _stringify["default"])(payload));
throw Error('resolve.no_providers_for ' + (0, _stringify.default)(payload));
}
var _handlers$i = handlers[i],
path = _handlers$i.path,
handle = _handlers$i.handle;
const {
path,
handle
} = handlers[i];
if (!(0, _common.unwrap)(payload, path)) return run(i + 1, payload);
var nextCalled = false;
return handle(payload, options, function (nextPayload) {
let nextCalled = false;
return handle(payload, options, nextPayload => {
if (nextCalled) {

@@ -44,29 +45,22 @@ throw Error('resolve.duplicate_next_call: ' + handlers[i].name);

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

@@ -6,8 +6,4 @@ "use strict";

exports.__esModule = true;
exports["default"] = void 0;
exports.default = void 0;
var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs3/regenerator"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator"));
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));

@@ -17,4 +13,2 @@

var _asyncIterator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncIterator"));
var _common = require("@graffy/common");

@@ -28,11 +22,5 @@

function validateArgs(first) {
var _context;
function validateArgs(first, ...args) {
let path;
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 {

@@ -45,23 +33,13 @@ path = (0, _common.makePath)(first);

for (var _i = 0, _args = args; _i < _args.length; _i++) {
var arg = _args[_i];
for (const arg of args) {
if (typeof arg !== 'undefined' && typeof arg !== 'object' && typeof arg !== 'function') {
throw Error('validateArgs.invalid_argument ' + (0, _stringify["default"])(arg));
throw Error('validateArgs.invalid_argument ' + (0, _stringify.default)(arg));
}
}
return (0, _concat["default"])(_context = [path]).call(_context, args);
return [path, ...args];
}
var Graffy = /*#__PURE__*/function () {
function Graffy(path, core) {
if (path === void 0) {
path = [];
}
if (core === void 0) {
core = new _Core["default"]();
}
class Graffy {
constructor(path = [], core = new _Core.default()) {
this.core = core;

@@ -71,223 +49,60 @@ this.path = path;

var _proto = Graffy.prototype;
on(type, ...args) {
var _context;
_proto.on = function on(type) {
var _context2;
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),
rawPath = _validateArgs[0],
rawHandler = _validateArgs[1];
var path = (0, _concat["default"])(_context2 = this.path).call(_context2, rawPath);
var handler = path.length ? (type === 'watch' ? _shift.shiftGen : _shift.shiftFn)(rawHandler, path) : rawHandler;
const [rawPath, rawHandler] = validateArgs(...args);
const path = (0, _concat.default)(_context = this.path).call(_context, rawPath);
const handler = path.length ? (type === 'watch' ? _shift.shiftGen : _shift.shiftFn)(rawHandler, path) : rawHandler;
this.core.on(type, path, handler);
};
}
_proto.onRead = function onRead() {
var _validateArgs2 = validateArgs.apply(void 0, arguments),
path = _validateArgs2[0],
handle = _validateArgs2[1];
onRead(...args) {
const [path, handle] = validateArgs(...args);
this.on('read', path, async function porcelainRead(query, options) {
return (0, _common.finalize)((0, _common.makeGraph)((await handle((0, _common.decorateQuery)(query), options))), query);
});
}
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) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_context3.t0 = _common.finalize;
_context3.t1 = _common.makeGraph;
_context3.next = 4;
return handle((0, _common.decorateQuery)(query), options);
onWatch(...args) {
const [path, handle] = validateArgs(...args);
this.on('watch', path, function porcelainWatch(query, options) {
return (0, _stream.makeStream)((push, end) => {
const subscription = handle((0, _common.decorateQuery)(query), options);
case 4:
_context3.t2 = _context3.sent;
_context3.t3 = (0, _context3.t1)(_context3.t2);
_context3.t4 = query;
return _context3.abrupt("return", (0, _context3.t0)(_context3.t3, _context3.t4));
(async function () {
try {
let firstValue = (await subscription.next()).value;
push(firstValue && (0, _common.finalize)((0, _common.makeGraph)(firstValue), query));
case 8:
case "end":
return _context3.stop();
for await (const value of subscription) {
push(value && (0, _common.makeGraph)(value));
}
} catch (e) {
end(e);
}
}, _callee);
}));
})();
function porcelainRead(_x, _x2) {
return _porcelainRead.apply(this, arguments);
}
return porcelainRead;
}());
};
_proto.onWatch = function onWatch() {
var _validateArgs3 = validateArgs.apply(void 0, arguments),
path = _validateArgs3[0],
handle = _validateArgs3[1];
this.on('watch', path, function porcelainWatch(query, options) {
return (0, _stream.makeStream)(function (push, end) {
var subscription = handle((0, _common.decorateQuery)(query), options);
(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
var firstValue, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, value;
return _regenerator["default"].wrap(function _callee2$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
_context4.prev = 0;
_context4.next = 3;
return subscription.next();
case 3:
firstValue = _context4.sent.value;
push(firstValue && (0, _common.finalize)((0, _common.makeGraph)(firstValue), query));
_iteratorNormalCompletion = true;
_didIteratorError = false;
_context4.prev = 7;
_iterator = (0, _asyncIterator2["default"])(subscription);
case 9:
_context4.next = 11;
return _iterator.next();
case 11:
_step = _context4.sent;
_iteratorNormalCompletion = _step.done;
_context4.next = 15;
return _step.value;
case 15:
_value = _context4.sent;
if (_iteratorNormalCompletion) {
_context4.next = 22;
break;
}
value = _value;
push(value && (0, _common.makeGraph)(value));
case 19:
_iteratorNormalCompletion = true;
_context4.next = 9;
break;
case 22:
_context4.next = 28;
break;
case 24:
_context4.prev = 24;
_context4.t0 = _context4["catch"](7);
_didIteratorError = true;
_iteratorError = _context4.t0;
case 28:
_context4.prev = 28;
_context4.prev = 29;
if (!(!_iteratorNormalCompletion && _iterator["return"] != null)) {
_context4.next = 33;
break;
}
_context4.next = 33;
return _iterator["return"]();
case 33:
_context4.prev = 33;
if (!_didIteratorError) {
_context4.next = 36;
break;
}
throw _iteratorError;
case 36:
return _context4.finish(33);
case 37:
return _context4.finish(28);
case 38:
_context4.next = 43;
break;
case 40:
_context4.prev = 40;
_context4.t1 = _context4["catch"](0);
end(_context4.t1);
case 43:
case "end":
return _context4.stop();
}
}
}, _callee2, null, [[0, 40], [7, 24, 28, 38], [29,, 33, 37]]);
}))();
return function () {
return subscription["return"]();
};
return () => subscription.return();
});
});
};
}
_proto.onWrite = function onWrite() {
var _validateArgs4 = validateArgs.apply(void 0, arguments),
path = _validateArgs4[0],
handle = _validateArgs4[1];
onWrite(...args) {
const [path, handle] = validateArgs(...args);
this.on('write', path, async function porcelainWrite(change, options) {
return (0, _common.makeGraph)((await handle((0, _common.decorate)(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) {
while (1) {
switch (_context5.prev = _context5.next) {
case 0:
_context5.t0 = _common.makeGraph;
_context5.next = 3;
return handle((0, _common.decorate)(change), options);
case 3:
_context5.t1 = _context5.sent;
return _context5.abrupt("return", (0, _context5.t0)(_context5.t1));
case 5:
case "end":
return _context5.stop();
}
}
}, _callee3);
}));
function porcelainWrite(_x3, _x4) {
return _porcelainWrite.apply(this, arguments);
}
return porcelainWrite;
}());
};
_proto.use = function use() {
var _validateArgs5 = validateArgs.apply(void 0, arguments),
path = _validateArgs5[0],
provider = _validateArgs5[1];
use(...args) {
const [path, provider] = validateArgs(...args);
provider(new Graffy(path, this.core));
};
}
_proto.call = function call(type, unwrappedPayload, options) {
var _this = this;
call(type, unwrappedPayload, options) {
const payload = (0, _common.wrap)(unwrappedPayload, this.path);
const result = this.core.call(type, payload, options);
var payload = (0, _common.wrap)(unwrappedPayload, this.path);
var result = this.core.call(type, payload, options);
var unwrapResult = function unwrapResult(value) {
return value && (0, _common.unwrap)(value, _this.path);
const unwrapResult = value => {
return value && (0, _common.unwrap)(value, this.path);
};

@@ -297,97 +112,28 @@

return type === 'watch' ? (0, _stream.mapStream)(result, unwrapResult) : result.then(unwrapResult);
};
}
_proto.read = /*#__PURE__*/function () {
var _read = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
var _validateArgs6,
path,
porcelainQuery,
options,
query,
result,
_args5 = arguments;
async read(...args) {
const [path, porcelainQuery, options] = validateArgs(...args);
const query = (0, _common.wrap)((0, _common.makeQuery)(porcelainQuery), path);
const result = await this.call('read', query, options || {});
return (0, _common.descend)((0, _common.decorate)(result), path);
}
return _regenerator["default"].wrap(function _callee4$(_context6) {
while (1) {
switch (_context6.prev = _context6.next) {
case 0:
_validateArgs6 = validateArgs.apply(void 0, _args5), path = _validateArgs6[0], porcelainQuery = _validateArgs6[1], options = _validateArgs6[2];
query = (0, _common.wrap)((0, _common.makeQuery)(porcelainQuery), path);
_context6.next = 4;
return this.call('read', query, options || {});
watch(...args) {
const [path, porcelainQuery, options] = validateArgs(...args);
const query = (0, _common.wrap)((0, _common.makeQuery)(porcelainQuery), path);
const stream = this.call('watch', query, options || {});
return (0, _stream.mapStream)(stream, value => (0, _common.descend)((0, _common.decorate)(value), path));
}
case 4:
result = _context6.sent;
return _context6.abrupt("return", (0, _common.descend)((0, _common.decorate)(result), path));
async write(...args) {
const [path, porcelainChange, options] = validateArgs(...args);
const change = (0, _common.wrap)((0, _common.makeGraph)(porcelainChange), path);
const writtenChange = await this.call('write', change, options || {});
return (0, _common.descend)((0, _common.decorate)(writtenChange), path);
}
case 6:
case "end":
return _context6.stop();
}
}
}, _callee4, this);
}));
}
function read() {
return _read.apply(this, arguments);
}
return read;
}();
_proto.watch = function watch() {
var _validateArgs7 = validateArgs.apply(void 0, arguments),
path = _validateArgs7[0],
porcelainQuery = _validateArgs7[1],
options = _validateArgs7[2];
var query = (0, _common.wrap)((0, _common.makeQuery)(porcelainQuery), path);
var stream = this.call('watch', query, options || {});
return (0, _stream.mapStream)(stream, function (value) {
return (0, _common.descend)((0, _common.decorate)(value), path);
});
};
_proto.write = /*#__PURE__*/function () {
var _write = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5() {
var _validateArgs8,
path,
porcelainChange,
options,
change,
writtenChange,
_args6 = arguments;
return _regenerator["default"].wrap(function _callee5$(_context7) {
while (1) {
switch (_context7.prev = _context7.next) {
case 0:
_validateArgs8 = validateArgs.apply(void 0, _args6), path = _validateArgs8[0], porcelainChange = _validateArgs8[1], options = _validateArgs8[2];
change = (0, _common.wrap)((0, _common.makeGraph)(porcelainChange), path);
_context7.next = 4;
return this.call('write', change, options || {});
case 4:
writtenChange = _context7.sent;
return _context7.abrupt("return", (0, _common.descend)((0, _common.decorate)(writtenChange), path));
case 6:
case "end":
return _context7.stop();
}
}
}, _callee5, this);
}));
function write() {
return _write.apply(this, arguments);
}
return write;
}();
return Graffy;
}();
exports["default"] = Graffy;
exports.default = Graffy;
module.exports = exports.default;

@@ -6,8 +6,8 @@ "use strict";

exports.__esModule = true;
exports["default"] = void 0;
exports.default = void 0;
var _Graffy = _interopRequireDefault(require("./Graffy"));
var _default = _Graffy["default"];
exports["default"] = _default;
var _default = _Graffy.default;
exports.default = _default;
module.exports = exports.default;

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

"author": "aravind (https://github.com/aravindet)",
"version": "0.14.7-alpha.9",
"main": "index.js",
"source": "src/index.js",
"esnext": "src/index.js",
"version": "0.14.7-alpha.10",
"main": "./index.js",
"exports": {
"import": "./src/index.js",
"require": "./index.js"
},
"module": "./src/index.js",
"source": "./src/index.js",
"esnext": "./src/index.js",
"repository": {

@@ -17,5 +22,5 @@ "type": "git",

"@babel/runtime-corejs3": "^7.9.2",
"@graffy/common": "0.14.7-alpha.9",
"@graffy/stream": "0.14.7-alpha.9"
"@graffy/common": "0.14.7-alpha.10",
"@graffy/stream": "0.14.7-alpha.10"
}
}
"use strict";
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
exports.__esModule = true;

@@ -9,14 +7,2 @@ exports.shiftFn = shiftFn;

var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs3/regenerator"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator"));
var _wrapAsyncGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/wrapAsyncGenerator"));
var _awaitAsyncGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/awaitAsyncGenerator"));
var _asyncGeneratorDelegate2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncGeneratorDelegate"));
var _asyncIterator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncIterator"));
var _common = require("@graffy/common");

@@ -26,181 +12,38 @@

function mapStream(_x5, _x6) {
return _mapStream.apply(this, arguments);
async function mapStream(stream, fn) {
for await (const value of stream) {
fn(value);
}
}
function _mapStream() {
_mapStream = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(stream, fn) {
var _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, value;
return _regenerator["default"].wrap(function _callee5$(_context5) {
while (1) {
switch (_context5.prev = _context5.next) {
case 0:
_iteratorNormalCompletion = true;
_didIteratorError = false;
_context5.prev = 2;
_iterator = (0, _asyncIterator2["default"])(stream);
case 4:
_context5.next = 6;
return _iterator.next();
case 6:
_step = _context5.sent;
_iteratorNormalCompletion = _step.done;
_context5.next = 10;
return _step.value;
case 10:
_value = _context5.sent;
if (_iteratorNormalCompletion) {
_context5.next = 17;
break;
}
value = _value;
fn(value);
case 14:
_iteratorNormalCompletion = true;
_context5.next = 4;
break;
case 17:
_context5.next = 23;
break;
case 19:
_context5.prev = 19;
_context5.t0 = _context5["catch"](2);
_didIteratorError = true;
_iteratorError = _context5.t0;
case 23:
_context5.prev = 23;
_context5.prev = 24;
if (!(!_iteratorNormalCompletion && _iterator["return"] != null)) {
_context5.next = 28;
break;
}
_context5.next = 28;
return _iterator["return"]();
case 28:
_context5.prev = 28;
if (!_didIteratorError) {
_context5.next = 31;
break;
}
throw _iteratorError;
case 31:
return _context5.finish(28);
case 32:
return _context5.finish(23);
case 33:
case "end":
return _context5.stop();
}
}
}, _callee5, null, [[2, 19, 23, 33], [24,, 28, 32]]);
}));
return _mapStream.apply(this, arguments);
}
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 async function shiftedFn(payload, options, next) {
let nextCalled = false;
let remainingNextResult;
const unwrappedPayload = (0, _common.unwrap)(payload, path);
const remainingPayload = (0, _common.remove)(payload, path) || []; // This next function is offered to the provider function.
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);
async function shiftedNext(unwrappedNextPayload) {
nextCalled = true;
const nextPayload = (0, _common.wrap)(unwrappedNextPayload, path);
if (remainingPayload.length) (0, _common.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.
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));
remainingNextResult = (0, _common.remove)(nextResult, path) || [];
return (0, _common.unwrap)(nextResult, path);
}
case 8:
case "end":
return _context.stop();
}
}
}, _callee);
}));
return _shiftedNext.apply(this, arguments);
};
const result = (0, _common.wrap)((await fn(unwrappedPayload, options, shiftedNext)), path);
shiftedNext = function _shiftedNext2(_x10) {
return _shiftedNext.apply(this, arguments);
};
if (!nextCalled && remainingPayload.length) {
remainingNextResult = await next(remainingPayload);
}
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);
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;
}
_context2.next = 14;
return next(remainingPayload);
case 14:
remainingNextResult = _context2.sent;
case 15:
if (remainingNextResult && remainingNextResult.length) {
(0, _common.merge)(result, remainingNextResult);
}
return _context2.abrupt("return", result);
case 17:
case "end":
return _context2.stop();
}
}
}, _callee2);
}));
function shiftedFn(_x7, _x8, _x9) {
return _shiftedFn.apply(this, arguments);
if (remainingNextResult && remainingNextResult.length) {
(0, _common.merge)(result, remainingNextResult);
}
return shiftedFn;
}();
return result;
};
} // TODO: Provider calling next in a subscription function is not tested.

@@ -210,164 +53,42 @@

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 async function* shiftedGen(payload, options, next) {
let nextCalled = false;
let remainingNextStream;
const unwrappedPayload = (0, _common.unwrap)(payload, path);
const 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;
const shiftedNext = async function* shiftedNextFn(unwrappedNextPayload) {
nextCalled = true;
const nextPayload = (0, _common.wrap)(unwrappedNextPayload, path);
if (remainingPayload.length) (0, _common.merge)(nextPayload, remainingPayload);
let pushRemaining;
remainingNextStream = (0, _stream.makeStream)(push => {
pushRemaining = push;
});
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));
for await (const value of next(nextPayload)) {
const unwrappedValue = (0, _common.unwrap)(value, path);
const remainingValue = (0, _common.remove)(value, path);
if (remainingValue) pushRemaining(remainingValue);
if (unwrappedValue) yield unwrappedValue;
}
};
case 8:
_context3.next = 10;
return (0, _awaitAsyncGenerator2["default"])(_iterator2.next());
const unwrappedStream = fn(unwrappedPayload, options, shiftedNext); // We expect next() to be called before the first value is yielded.
case 10:
_step2 = _context3.sent;
_iteratorNormalCompletion2 = _step2.done;
_context3.next = 14;
return (0, _awaitAsyncGenerator2["default"])(_step2.value);
const firstValue = await (await unwrappedStream.next()).value;
const resultStream = (0, _stream.makeStream)(push => {
push((0, _common.wrap)(firstValue, path));
mapStream(unwrappedStream, value => {
push((0, _common.wrap)(value, path));
});
return () => unwrappedStream.return();
});
case 14:
_value2 = _context3.sent;
if (_iteratorNormalCompletion2) {
_context3.next = 26;
break;
}
value = _value2;
unwrappedValue = (0, _common.unwrap)(value, path);
remainingValue = (0, _common.remove)(value, path);
if (remainingValue) pushRemaining(remainingValue);
if (!unwrappedValue) {
_context3.next = 23;
break;
}
_context3.next = 23;
return unwrappedValue;
case 23:
_iteratorNormalCompletion2 = true;
_context3.next = 8;
break;
case 26:
_context3.next = 32;
break;
case 28:
_context3.prev = 28;
_context3.t0 = _context3["catch"](6);
_didIteratorError2 = true;
_iteratorError2 = _context3.t0;
case 32:
_context3.prev = 32;
_context3.prev = 33;
if (!(!_iteratorNormalCompletion2 && _iterator2["return"] != null)) {
_context3.next = 37;
break;
}
_context3.next = 37;
return (0, _awaitAsyncGenerator2["default"])(_iterator2["return"]());
case 37:
_context3.prev = 37;
if (!_didIteratorError2) {
_context3.next = 40;
break;
}
throw _iteratorError2;
case 40:
return _context3.finish(37);
case 41:
return _context3.finish(32);
case 42:
case "end":
return _context3.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.
_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 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"]();
};
});
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);
case 15:
case "end":
return _context4.stop();
}
}
}, _callee4);
}));
function shiftedGen(_x, _x2, _x3) {
return _shiftedGen.apply(this, arguments);
if (!nextCalled && remainingPayload.length) {
remainingNextStream = next(remainingPayload);
}
return shiftedGen;
}();
yield* remainingNextStream ? (0, _common.mergeStreams)(resultStream, remainingNextStream) : resultStream;
};
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc