Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fetch-component-data

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fetch-component-data - npm Package Compare versions

Comparing version 10.0.0 to 11.0.0

305

lib/fetchComponentData.js
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {

@@ -9,23 +8,12 @@ value: true

exports["default"] = fetchComponentData;
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _excluded = ["store", "action", "parallel"];
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
// Executes fetchdata on a component, handles async or callback formats

@@ -38,11 +26,8 @@ function executeFetch(Component, executeFetchOpts) {

done = true;
if (err && res && !err.status) {
err.status = res.status;
}
if (err) return reject(err);
resolve(res);
});
if (p && p.then) {

@@ -61,3 +46,2 @@ p.then(function (res) {

}
function _executeFetchComponentData(_x) {

@@ -72,136 +56,103 @@ return _executeFetchComponentData2.apply(this, arguments);

*/
function _executeFetchComponentData2() {
_executeFetchComponentData2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(options) {
var store, action, parallel, rest, promises, result, _iterator, _step, branch, match, route, Component, componentModule, p, _res, results, _iterator2, _step2, res;
return _regenerator["default"].wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
store = options.store, action = options.action, parallel = options.parallel, rest = (0, _objectWithoutProperties2["default"])(options, _excluded);
promises = [];
result = {};
_iterator = _createForOfIteratorHelper(options.branch);
_context.prev = 4;
_iterator.s();
case 6:
if ((_step = _iterator.n()).done) {
_context.next = 30;
break;
}
branch = _step.value;
match = branch.match, route = branch.route;
Component = route.component;
if (Component) {
_context.next = 12;
break;
}
return _context.abrupt("continue", 28);
case 12:
if (!Component.load) {
_context.next = 17;
break;
}
_context.next = 15;
return Component.load();
case 15:
componentModule = _context.sent;
Component = componentModule["default"];
case 17:
while (Component.WrappedComponent) {
Component = Component.WrappedComponent;
}
if (!Component.fetchData) {
_context.next = 28;
break;
}
p = executeFetch(Component, _objectSpread(_objectSpread({}, rest), {}, {
store: store,
action: action,
match: match,
route: route
}));
if (!parallel) {
_context.next = 24;
break;
}
promises.push(p);
while (1) switch (_context.prev = _context.next) {
case 0:
store = options.store, action = options.action, parallel = options.parallel, rest = (0, _objectWithoutProperties2["default"])(options, _excluded);
promises = [];
result = {};
_iterator = _createForOfIteratorHelper(options.branch);
_context.prev = 4;
_iterator.s();
case 6:
if ((_step = _iterator.n()).done) {
_context.next = 30;
break;
}
branch = _step.value;
match = branch.match, route = branch.route;
Component = route.component;
if (Component) {
_context.next = 12;
break;
}
return _context.abrupt("continue", 28);
case 12:
if (!Component.load) {
_context.next = 17;
break;
}
_context.next = 15;
return Component.load();
case 15:
componentModule = _context.sent;
Component = componentModule["default"];
case 17:
while (Component.WrappedComponent) {
Component = Component.WrappedComponent;
}
if (!Component.fetchData) {
_context.next = 28;
break;
case 24:
_context.next = 26;
return p;
case 26:
_res = _context.sent;
if (_res) result = _objectSpread(_objectSpread({}, result), _res);
case 28:
_context.next = 6;
}
p = executeFetch(Component, _objectSpread(_objectSpread({}, rest), {}, {
store: store,
action: action,
match: match,
route: route
}));
if (!parallel) {
_context.next = 24;
break;
case 30:
_context.next = 35;
}
promises.push(p);
_context.next = 28;
break;
case 24:
_context.next = 26;
return p;
case 26:
_res = _context.sent;
if (_res) result = _objectSpread(_objectSpread({}, result), _res);
case 28:
_context.next = 6;
break;
case 30:
_context.next = 35;
break;
case 32:
_context.prev = 32;
_context.t0 = _context["catch"](4);
_iterator.e(_context.t0);
case 35:
_context.prev = 35;
_iterator.f();
return _context.finish(35);
case 38:
if (!parallel) {
_context.next = 44;
break;
case 32:
_context.prev = 32;
_context.t0 = _context["catch"](4);
_iterator.e(_context.t0);
case 35:
_context.prev = 35;
_iterator.f();
return _context.finish(35);
case 38:
if (!parallel) {
_context.next = 44;
break;
}
_context.next = 41;
return Promise.all(promises);
case 41:
results = _context.sent;
_iterator2 = _createForOfIteratorHelper(results);
try {
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
res = _step2.value;
if (res) result = _objectSpread(_objectSpread({}, result), res);
}
_context.next = 41;
return Promise.all(promises);
case 41:
results = _context.sent;
_iterator2 = _createForOfIteratorHelper(results);
try {
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
res = _step2.value;
if (res) result = _objectSpread(_objectSpread({}, result), res);
}
} catch (err) {
_iterator2.e(err);
} finally {
_iterator2.f();
}
case 44:
return _context.abrupt("return", result);
case 45:
case "end":
return _context.stop();
}
} catch (err) {
_iterator2.e(err);
} finally {
_iterator2.f();
}
case 44:
return _context.abrupt("return", result);
case 45:
case "end":
return _context.stop();
}

@@ -212,7 +163,5 @@ }, _callee, null, [[4, 32, 35, 38]]);

}
function fetchComponentData(_x2, _x3) {
return _fetchComponentData.apply(this, arguments);
}
function _fetchComponentData() {

@@ -222,41 +171,30 @@ _fetchComponentData = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(options, callback) {

return _regenerator["default"].wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
_context2.prev = 0;
_context2.next = 3;
return _executeFetchComponentData(options);
case 3:
res = _context2.sent;
if (!callback) {
_context2.next = 6;
break;
}
return _context2.abrupt("return", callback(null, res));
case 6:
return _context2.abrupt("return", res);
case 9:
_context2.prev = 9;
_context2.t0 = _context2["catch"](0);
console.log(_context2.t0);
if (!callback) {
_context2.next = 14;
break;
}
return _context2.abrupt("return", callback(_context2.t0));
case 14:
throw _context2.t0;
case 15:
case "end":
return _context2.stop();
}
while (1) switch (_context2.prev = _context2.next) {
case 0:
_context2.prev = 0;
_context2.next = 3;
return _executeFetchComponentData(options);
case 3:
res = _context2.sent;
if (!callback) {
_context2.next = 6;
break;
}
return _context2.abrupt("return", callback(null, res));
case 6:
return _context2.abrupt("return", res);
case 9:
_context2.prev = 9;
_context2.t0 = _context2["catch"](0);
console.log(_context2.t0);
if (!callback) {
_context2.next = 14;
break;
}
return _context2.abrupt("return", callback(_context2.t0));
case 14:
throw _context2.t0;
case 15:
case "end":
return _context2.stop();
}

@@ -267,3 +205,2 @@ }, _callee2, null, [[0, 9]]);

}
module.exports = exports.default;
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {

@@ -20,5 +19,3 @@ value: true

});
var _fetchComponentData = _interopRequireDefault(require("./fetchComponentData"));
var _middleware = _interopRequireDefault(require("./middleware"));
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {

@@ -9,15 +8,9 @@ value: true

exports["default"] = createFetchComponentDataMiddlware;
var _lodash = _interopRequireDefault(require("lodash"));
var _reactRouterConfig = require("react-router-config");
var _fetchComponentData = _interopRequireDefault(require("./fetchComponentData"));
var routeChangeTypes = ['@@reduxReactRouter/routerDidChange', '@@router/LOCATION_CHANGE'];
var locsEqual = function locsEqual(locA, locB) {
return locA && locB && locA.pathname === locB.pathname && locA.search === locB.search;
};
function createFetchComponentDataMiddlware(getRoutes) {

@@ -30,3 +23,2 @@ var routes = getRoutes();

var currentLocation = router.location;
if (currentLocation && _lodash["default"].includes(routeChangeTypes, action.type)) {

@@ -43,3 +35,2 @@ var newLocation = action.payload && action.payload.location || action.payload;

}
return next(action);

@@ -50,3 +41,2 @@ };

}
module.exports = exports.default;
{
"name": "fetch-component-data",
"version": "10.0.0",
"version": "11.0.0",
"description": "Small util functions for Frameworkstein",

@@ -42,3 +42,3 @@ "main": "lib/index.js",

},
"gitHead": "55031fe2a6b77003200d967720e816b432a0214a"
"gitHead": "d2747da3c08698b97922c941aa18189f0211f49e"
}
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