New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

compose-state

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

compose-state - npm Package Compare versions

Comparing version 1.0.10 to 1.0.11

36

dist.js

@@ -1,1 +0,35 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.composeDerivedStateFromProps=exports.composeState=void 0;function a(a){for(var c=1;c<arguments.length;c++){var d=null==arguments[c]?{}:arguments[c],e=Object.keys(d);"function"==typeof Object.getOwnPropertySymbols&&(e=e.concat(Object.getOwnPropertySymbols(d).filter(function(a){return Object.getOwnPropertyDescriptor(d,a).enumerable}))),e.forEach(function(c){b(a,c,d[c])})}return a}function b(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function c(a){return f(a)||e(a)||d()}function d(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function e(a){if(Symbol.iterator in Object(a)||"[object Arguments]"===Object.prototype.toString.call(a))return Array.from(a)}function f(a){if(Array.isArray(a)){for(var b=0,c=Array(a.length);b<a.length;b++)c[b]=a[b];return c}}var g=function(b){return function(){for(var d=arguments.length,e=Array(d),f=0;f<d;f++)e[f]=arguments[f];return e.reduceRight(function(d,e){return function(){for(var f=arguments.length,g=Array(f),h=0;h<f;h++)g[h]=arguments[h];var i=d.apply(void 0,g),j=e instanceof Function?e.apply(void 0,c(g.slice(0,b)).concat([a({},g[b],i)],c(g.slice(b+1)))):e;return j||i?a({},i,j):null}},function(){return null})}},h=g(0);exports.composeState=h;var i=g(1);exports.composeDerivedStateFromProps=i;var j=h;exports.default=j;
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = exports.composeDerivedStateFromProps = exports.composeState = void 0;
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var composeStateFactory = function composeStateFactory(stateIndex) {
return function () {
for (var _len = arguments.length, updaters = new Array(_len), _key = 0; _key < _len; _key++) {
updaters[_key] = arguments[_key];
}
return updaters.reduceRight(function (accumulator, current) {
return function (stateOrProps1, stateOrProps2) {
var accumulatedState = accumulator(stateOrProps1, stateOrProps2);
var currentState = current instanceof Function ? stateIndex === 0 ? current(_objectSpread({}, stateOrProps1, accumulatedState), stateOrProps2) : current(stateOrProps1, _objectSpread({}, stateOrProps2, accumulatedState)) : current;
return currentState || accumulatedState ? _objectSpread({}, accumulatedState, currentState) : null;
};
}, function () {
return null;
});
};
};
var composeState = composeStateFactory(0);
exports.composeState = composeState;
var composeDerivedStateFromProps = composeStateFactory(1);
exports.composeDerivedStateFromProps = composeDerivedStateFromProps;
var _default = composeState;
exports["default"] = _default;

14

index.js
const composeStateFactory = stateIndex => (...updaters) =>
updaters.reduceRight(
(accumulator, current) => (...args) => {
const accumulatedState = accumulator(...args);
(accumulator, current) => (stateOrProps1, stateOrProps2) => {
const accumulatedState = accumulator(stateOrProps1, stateOrProps2);
const currentState =
current instanceof Function
? current(
...args.slice(0, stateIndex),
{ ...args[stateIndex], ...accumulatedState },
...args.slice(stateIndex + 1),
)
? stateIndex === 0
? current({ ...stateOrProps1, ...accumulatedState }, stateOrProps2)
: current(stateOrProps1, { ...stateOrProps2, ...accumulatedState })
: current;

@@ -18,3 +16,3 @@

},
() => null,
() => null
);

@@ -21,0 +19,0 @@

@@ -13,3 +13,3 @@ {

},
"version": "1.0.10",
"version": "1.0.11",
"description": "Compose multiple setState or getDerivedStateFromProps updaters in React",

@@ -19,11 +19,9 @@ "main": "dist.js",

"devDependencies": {
"@babel/cli": "^7.1.0",
"@babel/core": "^7.1.0",
"@babel/plugin-proposal-class-properties": "^7.1.0",
"@babel/preset-env": "^7.1.0",
"@babel/cli": "^7.4.4",
"@babel/core": "^7.4.4",
"@babel/plugin-proposal-class-properties": "^7.4.4",
"@babel/preset-env": "^7.4.4",
"@babel/preset-react": "^7.0.0",
"babel-core": "^7.0.0-bridge",
"babel-jest": "^23.6.0",
"babel-preset-minify": "^0.5.0",
"jest": "^23.6.0",
"babel-jest": "^24.8.0",
"jest": "^24.8.0",
"react": ">16.3",

@@ -34,21 +32,19 @@ "react-test-renderer": ">16.3"

"build": "babel index.js --out-file dist.js",
"test": "jest --watch test.js"
"test": "jest"
},
"babel": {
"presets": [
[
"minify",
{
"mangle": {
"topLevel": true
}
}
],
"@babel/env",
"@babel/react"
"@babel/env"
],
"plugins": [
"@babel/proposal-class-properties"
]
"env": {
"test": {
"presets": [
"@babel/react"
],
"plugins": [
"@babel/proposal-class-properties"
]
}
}
}
}
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