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 6.17.14 to 7.0.0

75

lib/fetchComponentData.js

@@ -1,36 +0,28 @@

'use strict';
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = fetchComponentData;
var _promise = require('babel-runtime/core-js/promise');
var _lodash = _interopRequireDefault(require("lodash"));
var _promise2 = _interopRequireDefault(_promise);
var _queueAsync = _interopRequireDefault(require("queue-async"));
exports.default = fetchComponentData;
var _lodash = require('lodash');
var _lodash2 = _interopRequireDefault(_lodash);
var _queueAsync = require('queue-async');
var _queueAsync2 = _interopRequireDefault(_queueAsync);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// eslint-disable-line
var defaults = {
parallelism: 1
};
/*
* @param store the current redux store
* @param branch the matching react-router routes
* @param action the action that has triggered this fetch
* @param parallelism the number of fetches to execute in parallel
*/
/*
* @param store the current redux store
* @param branch the matching react-router routes
* @param action the action that has triggered this fetch
* @param parallelism the number of fetches to execute in parallel
*/
}; // eslint-disable-line
function fetchComponentData(options, callback) {
return new _promise2.default(function (resolve, reject) {
var _$defaults = _lodash2.default.defaults(options, defaults),
return new Promise(function (resolve, reject) {
var _$defaults = _lodash["default"].defaults(options, defaults),
store = _$defaults.store,

@@ -43,6 +35,4 @@ branch = _$defaults.branch,

var result = {};
var queue = new _queueAsync2.default(parallelism);
var queue = new _queueAsync["default"](parallelism);
branch.forEach(function (branch) {
var Component = branch.route.component;

@@ -54,10 +44,10 @@ if (!Component) return callback && callback();

}
if (!Component.fetchData) return;
queue.defer(function (callback) {
var match = branch.match;
var match = branch.match; // It's possible for compoennts to both call a callback fn and return a promise, in this case
// we need to make sure we don't call our queue callback again
// It's possible for compoennts to both call a callback fn and return a promise, in this case
// we need to make sure we don't call our queue callback again
var called = false;
var done = function done(err) {

@@ -67,13 +57,20 @@ var res = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

if (called) {
console.log('[fetchData] ' + Component.name + ' has returned a promise in addition to calling the provided callback, this may mean some data was not loaded correctly (use one or the other)');
console.log("[fetchData] ".concat(Component.name, " has returned a promise in addition to calling the provided callback, this may mean some data was not loaded correctly (use one or the other)"));
return;
}
called = true;
if (res) _lodash2.default.extend(result, res);
if (res) _lodash["default"].extend(result, res);
callback(err);
};
var promise = void 0;
var promise;
try {
promise = Component.fetchData({ store: store, action: action, match: match, location: location }, done);
promise = Component.fetchData({
store: store,
action: action,
match: match,
location: location
}, done);
} catch (err) {

@@ -86,3 +83,3 @@ return done(err);

return done(null, res);
}).catch(function (err) {
})["catch"](function (err) {
return done(err);

@@ -93,4 +90,3 @@ });

});
queue.await(function (err) {
queue["await"](function (err) {
if (callback) callback(err, result);

@@ -101,2 +97,3 @@ if (err) reject(err);else resolve(result);

}
module.exports = exports['default'];
module.exports = exports.default;

@@ -1,19 +0,23 @@

'use strict';
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.fetchComponentDataMiddleware = exports.fetchComponentData = undefined;
Object.defineProperty(exports, "fetchComponentData", {
enumerable: true,
get: function get() {
return _fetchComponentData["default"];
}
});
Object.defineProperty(exports, "fetchComponentDataMiddleware", {
enumerable: true,
get: function get() {
return _middleware["default"];
}
});
var _fetchComponentData = require('./fetchComponentData');
var _fetchComponentData = _interopRequireDefault(require("./fetchComponentData"));
var _fetchComponentData2 = _interopRequireDefault(_fetchComponentData);
var _middleware = require('./middleware');
var _middleware2 = _interopRequireDefault(_middleware);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.fetchComponentData = _fetchComponentData2.default;
exports.fetchComponentDataMiddleware = _middleware2.default;
var _middleware = _interopRequireDefault(require("./middleware"));

@@ -1,20 +0,16 @@

'use strict';
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = createFetchComponentDataMiddlware;
exports["default"] = createFetchComponentDataMiddlware;
var _lodash = require('lodash');
var _lodash = _interopRequireDefault(require("lodash"));
var _lodash2 = _interopRequireDefault(_lodash);
var _reactRouterConfig = require("react-router-config");
var _reactRouterConfig = require('react-router-config');
var _fetchComponentData = _interopRequireDefault(require("./fetchComponentData"));
var _fetchComponentData = require('./fetchComponentData');
var _fetchComponentData2 = _interopRequireDefault(_fetchComponentData);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var routeChangeTypes = ['@@reduxReactRouter/routerDidChange', '@@router/LOCATION_CHANGE'];

@@ -28,3 +24,2 @@

var routes = getRoutes();
return function (store) {

@@ -36,8 +31,12 @@ return function (next) {

if (currentLocation && _lodash2.default.includes(routeChangeTypes, action.type)) {
if (currentLocation && _lodash["default"].includes(routeChangeTypes, action.type)) {
var newLocation = action.payload;
if (locsEqual(currentLocation, newLocation)) return;
var branch = (0, _reactRouterConfig.matchRoutes)(routes, newLocation.pathname);
(0, _fetchComponentData2.default)({ store: store, branch: branch, action: action, location: newLocation });
(0, _fetchComponentData["default"])({
store: store,
branch: branch,
action: action,
location: newLocation
});
}

@@ -50,2 +49,3 @@

}
module.exports = exports['default'];
module.exports = exports.default;
{
"name": "fetch-component-data",
"version": "6.17.14",
"version": "7.0.0",
"description": "Small util functions for Frameworkstein",

@@ -16,5 +16,5 @@ "main": "lib/index.js",

"scripts": {
"prepublish": "rm -rf ./lib && babel ./src --ignore '/node_modules/' --out-dir ./lib",
"build": "rm -rf ./lib && babel ./src --ignore '/node_modules/' --out-dir ./lib",
"watch": "rm -rf ./lib && babel ./src --ignore '/node_modules/' --watch --out-dir ./lib",
"prepublish": "babel --root-mode upward ./src --out-dir ./lib --delete-dir-on-start",
"build": "babel --root-mode upward ./src --out-dir ./lib --delete-dir-on-start",
"watch": "babel --root-mode upward ./src --out-dir ./lib --delete-dir-on-start --watch",
"test": "eval $(cat test/.env) mocha test/**/*.tests.js",

@@ -31,4 +31,5 @@ "cover": "eval $(cat test/.env) istanbul cover _mocha -- test/**/*.tests.js"

"devDependencies": {
"babel-cli": "^6.0.0"
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0"
}
}
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