Comparing version 0.17.0 to 0.18.0
@@ -7,3 +7,3 @@ 'use strict'; | ||
var _omit = require('lodash/omit'); | ||
var _omit = require('./utils/omit'); | ||
@@ -20,3 +20,3 @@ var _omit2 = _interopRequireDefault(_omit); | ||
var Component = function Component(props) { | ||
return (0, _createElement2.default)(props[propName], (0, _omit2.default)(props, propName)); | ||
return (0, _createElement2.default)(props[propName], (0, _omit2.default)(props, [propName])); | ||
}; | ||
@@ -23,0 +23,0 @@ Component.displayName = 'componentFromProp(' + propName + ')'; |
@@ -6,2 +6,3 @@ 'use strict'; | ||
}); | ||
exports.internalCreateElement = undefined; | ||
@@ -20,8 +21,4 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
var createElement = function createElement(Component, props, children) { | ||
/* eslint-disable */ | ||
var hasKey = props && props.hasOwnProperty('key'); | ||
/* eslint-enable */ | ||
if (!hasKey && (0, _isReferentiallyTransparentFunctionComponent2.default)(Component)) { | ||
var _createElement = function _createElement(hasKey, isReferentiallyTransparent, Component, props, children) { | ||
if (!hasKey && isReferentiallyTransparent) { | ||
var component = Component; | ||
@@ -45,2 +42,17 @@ if (children) { | ||
var internalCreateElement = exports.internalCreateElement = function internalCreateElement(Component) { | ||
var isReferentiallyTransparent = (0, _isReferentiallyTransparentFunctionComponent2.default)(Component); | ||
return function (p, c) { | ||
return _createElement(false, isReferentiallyTransparent, Component, p, c); | ||
}; | ||
}; | ||
var createElement = function createElement(Component, props, children) { | ||
var isReferentiallyTransparent = (0, _isReferentiallyTransparentFunctionComponent2.default)(Component); | ||
/* eslint-disable */ | ||
var hasKey = props && props.hasOwnProperty('key'); | ||
/* eslint-enable */ | ||
return _createElement(hasKey, isReferentiallyTransparent, Component, props, children); | ||
}; | ||
exports.default = createElement; |
@@ -13,4 +13,2 @@ 'use strict'; | ||
var _createElement2 = _interopRequireDefault(_createElement); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -20,4 +18,5 @@ | ||
return function (BaseComponent) { | ||
var createElement = (0, _createElement.internalCreateElement)(BaseComponent); | ||
var DefaultProps = function DefaultProps(ownerProps) { | ||
return (0, _createElement2.default)(BaseComponent, ownerProps); | ||
return createElement(ownerProps); | ||
}; | ||
@@ -24,0 +23,0 @@ DefaultProps.defaultProps = props; |
@@ -9,3 +9,3 @@ 'use strict'; | ||
var _omit = require('lodash/omit'); | ||
var _omit = require('./utils/omit'); | ||
@@ -20,4 +20,2 @@ var _omit2 = _interopRequireDefault(_omit); | ||
var _createElement2 = _interopRequireDefault(_createElement); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -27,4 +25,5 @@ | ||
return function (BaseComponent) { | ||
var createElement = (0, _createElement.internalCreateElement)(BaseComponent); | ||
return function (props) { | ||
return (0, _createElement2.default)(BaseComponent, _extends({}, (0, _omit2.default)(props, propName), props[propName])); | ||
return createElement(_extends({}, (0, _omit2.default)(props, [propName]), props[propName])); | ||
}; | ||
@@ -31,0 +30,0 @@ }; |
@@ -15,4 +15,2 @@ 'use strict'; | ||
var _createElement2 = _interopRequireDefault(_createElement); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -22,4 +20,5 @@ | ||
return function (BaseComponent) { | ||
var createElement = (0, _createElement.internalCreateElement)(BaseComponent); | ||
var GetContext = function GetContext(ownerProps, context) { | ||
return (0, _createElement2.default)(BaseComponent, _extends({}, ownerProps, context)); | ||
return createElement(_extends({}, ownerProps, context)); | ||
}; | ||
@@ -26,0 +25,0 @@ |
22
index.js
@@ -6,3 +6,3 @@ 'use strict'; | ||
}); | ||
exports.hoistStatics = exports.nest = exports.componentFromProp = exports.createSink = exports.isClassComponent = exports.shallowEqual = exports.wrapDisplayName = exports.getDisplayName = exports.compose = exports.setDisplayName = exports.setPropTypes = exports.setStatic = exports.toClass = exports.lifecycle = exports.doOnReceiveProps = exports.getContext = exports.withContext = exports.onlyUpdateForPropTypes = exports.onlyUpdateForKeys = exports.pure = exports.shouldUpdate = exports.renderNothing = exports.renderComponent = exports.branch = exports.withReducer = exports.withState = exports.flattenProp = exports.renameProps = exports.renameProp = exports.defaultProps = exports.withHandlers = exports.withProps = exports.mapPropsOnChange = exports.mapProps = undefined; | ||
exports.hoistStatics = exports.nest = exports.componentFromProp = exports.createSink = exports.isClassComponent = exports.shallowEqual = exports.wrapDisplayName = exports.getDisplayName = exports.compose = exports.setDisplayName = exports.setPropTypes = exports.setStatic = exports.toClass = exports.getContext = exports.withContext = exports.onlyUpdateForPropTypes = exports.onlyUpdateForKeys = exports.pure = exports.shouldUpdate = exports.renderNothing = exports.renderComponent = exports.branch = exports.withReducer = exports.withState = exports.flattenProp = exports.renameProps = exports.renameProp = exports.defaultProps = exports.withHandlers = exports.withPropsOnChange = exports.withProps = exports.mapProps = undefined; | ||
@@ -13,6 +13,2 @@ var _mapProps2 = require('./mapProps'); | ||
var _mapPropsOnChange2 = require('./mapPropsOnChange'); | ||
var _mapPropsOnChange3 = _interopRequireDefault(_mapPropsOnChange2); | ||
var _withProps2 = require('./withProps'); | ||
@@ -22,2 +18,6 @@ | ||
var _withPropsOnChange2 = require('./withPropsOnChange'); | ||
var _withPropsOnChange3 = _interopRequireDefault(_withPropsOnChange2); | ||
var _withHandlers2 = require('./withHandlers'); | ||
@@ -87,10 +87,2 @@ | ||
var _doOnReceiveProps2 = require('./doOnReceiveProps'); | ||
var _doOnReceiveProps3 = _interopRequireDefault(_doOnReceiveProps2); | ||
var _lifecycle2 = require('./lifecycle'); | ||
var _lifecycle3 = _interopRequireDefault(_lifecycle2); | ||
var _toClass2 = require('./toClass'); | ||
@@ -152,4 +144,4 @@ | ||
exports.mapPropsOnChange = _mapPropsOnChange3.default; | ||
exports.withProps = _withProps3.default; | ||
exports.withPropsOnChange = _withPropsOnChange3.default; | ||
exports.withHandlers = _withHandlers3.default; | ||
@@ -171,4 +163,2 @@ exports.defaultProps = _defaultProps3.default; | ||
exports.getContext = _getContext3.default; | ||
exports.doOnReceiveProps = _doOnReceiveProps3.default; | ||
exports.lifecycle = _lifecycle3.default; | ||
exports.toClass = _toClass3.default; | ||
@@ -175,0 +165,0 @@ |
@@ -13,4 +13,2 @@ 'use strict'; | ||
var _createElement2 = _interopRequireDefault(_createElement); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -20,4 +18,5 @@ | ||
return function (BaseComponent) { | ||
var createElement = (0, _createElement.internalCreateElement)(BaseComponent); | ||
return function (props) { | ||
return (0, _createElement2.default)(BaseComponent, propsMapper(props)); | ||
return createElement(propsMapper(props)); | ||
}; | ||
@@ -24,0 +23,0 @@ }; |
@@ -9,6 +9,2 @@ 'use strict'; | ||
var _createElement2 = _interopRequireDefault(_createElement); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } | ||
@@ -21,2 +17,3 @@ | ||
var createElements = Components.map(_createElement.internalCreateElement); | ||
var Nest = function Nest(_ref) { | ||
@@ -26,4 +23,4 @@ var props = _objectWithoutProperties(_ref, []); | ||
var children = _ref.children; | ||
return Components.reduceRight(function (child, Component) { | ||
return (0, _createElement2.default)(Component, props, child); | ||
return createElements.reduceRight(function (child, createElement) { | ||
return createElement(props, child); | ||
}, children); | ||
@@ -30,0 +27,0 @@ }; |
@@ -7,6 +7,2 @@ 'use strict'; | ||
var _pick = require('lodash/pick'); | ||
var _pick2 = _interopRequireDefault(_pick); | ||
var _shouldUpdate = require('./shouldUpdate'); | ||
@@ -24,12 +20,14 @@ | ||
var _pick = require('./utils/pick'); | ||
var _pick2 = _interopRequireDefault(_pick); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var onlyUpdateForKeys = function onlyUpdateForKeys(propKeys) { | ||
return function (BaseComponent) { | ||
return (0, _shouldUpdate2.default)(function (props, nextProps) { | ||
return !(0, _shallowEqual2.default)((0, _pick2.default)(nextProps, propKeys), (0, _pick2.default)(props, propKeys)); | ||
})(BaseComponent); | ||
}; | ||
return (0, _shouldUpdate2.default)(function (props, nextProps) { | ||
return !(0, _shallowEqual2.default)((0, _pick2.default)(nextProps, propKeys), (0, _pick2.default)(props, propKeys)); | ||
}); | ||
}; | ||
exports.default = (0, _createHelper2.default)(onlyUpdateForKeys, 'onlyUpdateForKeys'); |
{ | ||
"name": "recompose", | ||
"version": "0.17.0", | ||
"version": "0.18.0", | ||
"author": "Andrew Clark <acdlite@me.com>", | ||
@@ -26,2 +26,3 @@ "repository": { | ||
"dependencies": { | ||
"fbjs": "^0.8.1", | ||
"hoist-non-react-statics": "^1.0.0", | ||
@@ -28,0 +29,0 @@ "lodash": "^4.3.0" |
@@ -9,3 +9,3 @@ 'use strict'; | ||
var _omit = require('lodash/omit'); | ||
var _omit = require('./utils/omit'); | ||
@@ -28,3 +28,3 @@ var _omit2 = _interopRequireDefault(_omit); | ||
return (0, _mapProps2.default)(function (props) { | ||
return _extends({}, (0, _omit2.default)(props, oldName), _defineProperty({}, newName, props[oldName])); | ||
return _extends({}, (0, _omit2.default)(props, [oldName]), _defineProperty({}, newName, props[oldName])); | ||
}); | ||
@@ -31,0 +31,0 @@ }; |
@@ -9,14 +9,10 @@ 'use strict'; | ||
var _omit = require('lodash/omit'); | ||
var _omit = require('./utils/omit'); | ||
var _omit2 = _interopRequireDefault(_omit); | ||
var _pick = require('lodash/pick'); | ||
var _pick = require('./utils/pick'); | ||
var _pick2 = _interopRequireDefault(_pick); | ||
var _mapKeys = require('lodash/mapKeys'); | ||
var _mapKeys2 = _interopRequireDefault(_mapKeys); | ||
var _mapProps = require('./mapProps'); | ||
@@ -35,5 +31,13 @@ | ||
var mapKeys = function mapKeys(obj, func) { | ||
return keys(obj).reduce(function (result, key) { | ||
var val = obj[key]; | ||
result[func(val, key)] = val; | ||
return result; | ||
}, {}); | ||
}; | ||
var renameProps = function renameProps(nameMap) { | ||
return (0, _mapProps2.default)(function (props) { | ||
return _extends({}, (0, _omit2.default)(props, keys(nameMap)), (0, _mapKeys2.default)((0, _pick2.default)(props, keys(nameMap)), function (_, oldName) { | ||
return _extends({}, (0, _omit2.default)(props, keys(nameMap)), mapKeys((0, _pick2.default)(props, keys(nameMap)), function (_, oldName) { | ||
return nameMap[oldName]; | ||
@@ -40,0 +44,0 @@ })); |
@@ -13,4 +13,2 @@ 'use strict'; | ||
var _createElement2 = _interopRequireDefault(_createElement); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -20,4 +18,5 @@ | ||
return function (_) { | ||
var createElement = (0, _createElement.internalCreateElement)(Component); | ||
var RenderComponent = function RenderComponent(props) { | ||
return (0, _createElement2.default)(Component, props); | ||
return createElement(props); | ||
}; | ||
@@ -24,0 +23,0 @@ if (process.env.NODE_ENV !== 'production') { |
@@ -7,34 +7,8 @@ 'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; | ||
var _shallowEqual = require('fbjs/lib/shallowEqual'); | ||
exports.default = shallowEqual; | ||
// Copied from https://github.com/facebook/fbjs/blob/master/src/core/shallowEqual.js | ||
var _shallowEqual2 = _interopRequireDefault(_shallowEqual); | ||
var hasOwnProperty = Object.prototype.hasOwnProperty; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function shallowEqual(objA, objB) { | ||
if (objA === objB) { | ||
return true; | ||
} | ||
if ((typeof objA === 'undefined' ? 'undefined' : _typeof(objA)) !== 'object' || objA === null || (typeof objB === 'undefined' ? 'undefined' : _typeof(objB)) !== 'object' || objB === null) { | ||
return false; | ||
} | ||
var keysA = Object.keys(objA); | ||
var keysB = Object.keys(objB); | ||
if (keysA.length !== keysB.length) { | ||
return false; | ||
} | ||
// Test for A's keys different from B. | ||
var bHasOwnProperty = hasOwnProperty.bind(objB); | ||
for (var i = 0; i < keysA.length; i++) { | ||
if (!bHasOwnProperty(keysA[i]) || objA[keysA[i]] !== objB[keysA[i]]) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
exports.default = _shallowEqual2.default; |
@@ -17,4 +17,2 @@ 'use strict'; | ||
var _createElement2 = _interopRequireDefault(_createElement); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -30,2 +28,3 @@ | ||
return function (BaseComponent) { | ||
var createElement = (0, _createElement.internalCreateElement)(BaseComponent); | ||
return function (_Component) { | ||
@@ -48,3 +47,3 @@ _inherits(_class, _Component); | ||
value: function render() { | ||
return (0, _createElement2.default)(BaseComponent, this.props); | ||
return createElement(this.props); | ||
} | ||
@@ -51,0 +50,0 @@ }]); |
@@ -17,4 +17,2 @@ 'use strict'; | ||
var _createElement2 = _interopRequireDefault(_createElement); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -30,2 +28,4 @@ | ||
return function (BaseComponent) { | ||
var createElement = (0, _createElement.internalCreateElement)(BaseComponent); | ||
var WithContext = function (_Component) { | ||
@@ -53,3 +53,3 @@ _inherits(WithContext, _Component); | ||
value: function render() { | ||
return (0, _createElement2.default)(BaseComponent, this.props); | ||
return createElement(this.props); | ||
} | ||
@@ -56,0 +56,0 @@ }]); |
@@ -13,12 +13,6 @@ 'use strict'; | ||
var _mapValues = require('lodash/mapValues'); | ||
var _createElement = require('./createElement'); | ||
var _mapValues2 = _interopRequireDefault(_mapValues); | ||
var _createHelper = require('./createHelper'); | ||
var _createElement = require('recompose/createElement'); | ||
var _createElement2 = _interopRequireDefault(_createElement); | ||
var _createHelper = require('recompose/createHelper'); | ||
var _createHelper2 = _interopRequireDefault(_createHelper); | ||
@@ -34,2 +28,9 @@ | ||
var mapValues = function mapValues(obj, func) { | ||
return Object.keys(obj).reduce(function (result, key, i) { | ||
result[key] = func(obj[key], key, i); | ||
return result; | ||
}, {}); | ||
}; | ||
var withHandlers = function withHandlers(handlers) { | ||
@@ -39,2 +40,3 @@ return function (BaseComponent) { | ||
var createElement = (0, _createElement.internalCreateElement)(BaseComponent); | ||
return _temp2 = _class = function (_Component) { | ||
@@ -60,3 +62,3 @@ _inherits(_class, _Component); | ||
value: function render() { | ||
return (0, _createElement2.default)(BaseComponent, _extends({}, this.props, this.handlers)); | ||
return createElement(_extends({}, this.props, this.handlers)); | ||
} | ||
@@ -69,3 +71,3 @@ }]); | ||
this.handlers = (0, _mapValues2.default)(handlers, function (createHandler) { | ||
this.handlers = mapValues(handlers, function (createHandler) { | ||
return function () { | ||
@@ -72,0 +74,0 @@ var handler = createHandler(_this2.props); |
@@ -9,6 +9,2 @@ 'use strict'; | ||
var _isFunction = require('lodash/isFunction'); | ||
var _isFunction2 = _interopRequireDefault(_isFunction); | ||
var _createHelper = require('./createHelper'); | ||
@@ -18,5 +14,5 @@ | ||
var _createElement = require('./createElement'); | ||
var _mapProps = require('./mapProps'); | ||
var _createElement2 = _interopRequireDefault(_createElement); | ||
var _mapProps2 = _interopRequireDefault(_mapProps); | ||
@@ -26,15 +22,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var withProps = function withProps(input) { | ||
return function (BaseComponent) { | ||
var getProps = void 0; | ||
var props = (0, _isFunction2.default)(input) ? input(getProps) : input; | ||
return function (ownerProps) { | ||
getProps = function getProps() { | ||
return ownerProps; | ||
}; | ||
return (0, _createElement2.default)(BaseComponent, _extends({}, ownerProps, props)); | ||
}; | ||
}; | ||
return (0, _mapProps2.default)(function (props) { | ||
return _extends({}, props, typeof input === 'function' ? input(props) : input); | ||
}); | ||
}; | ||
exports.default = (0, _createHelper2.default)(withProps, 'withProps'); |
@@ -13,6 +13,2 @@ 'use strict'; | ||
var _isFunction = require('lodash/isFunction'); | ||
var _isFunction2 = _interopRequireDefault(_isFunction); | ||
var _createHelper = require('./createHelper'); | ||
@@ -24,4 +20,2 @@ | ||
var _createElement2 = _interopRequireDefault(_createElement); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -39,2 +33,3 @@ | ||
return function (BaseComponent) { | ||
var createElement = (0, _createElement.internalCreateElement)(BaseComponent); | ||
return function (_Component) { | ||
@@ -55,3 +50,3 @@ _inherits(_class2, _Component); | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(_class2)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.state = { | ||
stateValue: (0, _isFunction2.default)(initialState) ? initialState(_this.props) : initialState | ||
stateValue: typeof initialState === 'function' ? initialState(_this.props) : initialState | ||
}, _this.dispatch = function (action) { | ||
@@ -72,3 +67,3 @@ return _this.setState(function (_ref) { | ||
return (0, _createElement2.default)(BaseComponent, _extends({}, this.props, (_extends2 = {}, _defineProperty(_extends2, stateName, this.state.stateValue), _defineProperty(_extends2, dispatchName, this.dispatch), _extends2))); | ||
return createElement(_extends({}, this.props, (_extends2 = {}, _defineProperty(_extends2, stateName, this.state.stateValue), _defineProperty(_extends2, dispatchName, this.dispatch), _extends2))); | ||
} | ||
@@ -75,0 +70,0 @@ }]); |
@@ -13,6 +13,2 @@ 'use strict'; | ||
var _isFunction = require('lodash/isFunction'); | ||
var _isFunction2 = _interopRequireDefault(_isFunction); | ||
var _createHelper = require('./createHelper'); | ||
@@ -24,4 +20,2 @@ | ||
var _createElement2 = _interopRequireDefault(_createElement); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -39,2 +33,3 @@ | ||
return function (BaseComponent) { | ||
var createElement = (0, _createElement.internalCreateElement)(BaseComponent); | ||
return function (_Component) { | ||
@@ -55,3 +50,3 @@ _inherits(_class2, _Component); | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_Object$getPrototypeO = Object.getPrototypeOf(_class2)).call.apply(_Object$getPrototypeO, [this].concat(args))), _this), _this.state = { | ||
stateValue: (0, _isFunction2.default)(initialState) ? initialState(_this.props) : initialState | ||
stateValue: typeof initialState === 'function' ? initialState(_this.props) : initialState | ||
}, _this.updateStateValue = function (updateFn, callback) { | ||
@@ -61,3 +56,3 @@ return _this.setState(function (_ref) { | ||
return { | ||
stateValue: (0, _isFunction2.default)(updateFn) ? updateFn(stateValue) : updateFn | ||
stateValue: typeof updateFn === 'function' ? updateFn(stateValue) : updateFn | ||
}; | ||
@@ -73,3 +68,3 @@ }, callback); | ||
return (0, _createElement2.default)(BaseComponent, _extends({}, this.props, (_extends2 = {}, _defineProperty(_extends2, stateName, this.state.stateValue), _defineProperty(_extends2, stateUpdaterName, this.updateStateValue), _extends2))); | ||
return createElement(_extends({}, this.props, (_extends2 = {}, _defineProperty(_extends2, stateName, this.state.stateValue), _defineProperty(_extends2, stateUpdaterName, this.updateStateValue), _extends2))); | ||
} | ||
@@ -76,0 +71,0 @@ }]); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
553733
45
3425
4
2
7
1
+ Addedfbjs@^0.8.1