Comparing version 0.2.0-beta1 to 0.2.0
@@ -37,2 +37,3 @@ 'use strict'; | ||
for (var actionName in actions) { | ||
/* istanbul ignore if */ | ||
if (!actions.hasOwnProperty(actionName)) { | ||
@@ -39,0 +40,0 @@ continue; |
@@ -16,5 +16,5 @@ 'use strict'; | ||
var _test = require('./test'); | ||
var _unwrapComponent = require('./unwrapComponent'); | ||
var _test2 = _interopRequireDefault(_test); | ||
var _unwrapComponent2 = _interopRequireDefault(_unwrapComponent); | ||
@@ -24,3 +24,3 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
exports.Provider = _Provider2.default; | ||
exports.unwrap = _test2.default; | ||
exports.unwrap = _unwrapComponent2.default; | ||
exports.wrap = _wrapComponent2.default; |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
@@ -6,2 +6,6 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
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; }; | ||
exports.default = intersection; | ||
/** | ||
@@ -16,7 +20,84 @@ * Intersection method for shallow objects | ||
exports.default = function (dominantObject, slaveObject) { | ||
/* | ||
* Tells us, on a nested basis, if objects are the same, or differ at some level | ||
*/ | ||
function objectsAreDifferent(dominantObject, slaveObject) { | ||
for (var key in dominantObject) { | ||
if (!dominantObject.hasOwnProperty(key)) { | ||
continue; | ||
} | ||
var dominantKeyValue = dominantObject[key]; | ||
var slaveKeyValue = slaveObject[key]; | ||
if (!slaveKeyValue) { | ||
return true; | ||
} | ||
if ((typeof dominantKeyValue === 'undefined' ? 'undefined' : _typeof(dominantKeyValue)) === 'object') { | ||
return objectsAreDifferent(dominantKeyValue, slaveKeyValue); | ||
} | ||
if (dominantKeyValue !== slaveKeyValue) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
/* | ||
* compares arrays in a nested basis | ||
*/ | ||
function arraysAreDifferent(dominantArray, slaveArray) { | ||
// if array has been `push`ed to, it is different | ||
if (slaveArray.length !== dominantArray.length) { | ||
return true; | ||
} | ||
var responseValues = dominantArray.map(function (dominantIndexValue, index) { | ||
var slaveIndexValue = slaveArray[index]; | ||
if (Array.isArray(dominantIndexValue)) { | ||
return arraysAreDifferent(dominantIndexValue, slaveIndexValue); | ||
} else if ((typeof dominantIndexValue === 'undefined' ? 'undefined' : _typeof(dominantIndexValue)) === 'object') { | ||
return objectsAreDifferent(dominantIndexValue, slaveIndexValue); | ||
} | ||
return dominantIndexValue !== slaveIndexValue; | ||
}); | ||
return responseValues.indexOf(true) !== -1; | ||
} | ||
/* | ||
* Validates object comparisons and returns the deep nested object that | ||
* is unique. | ||
* | ||
* For example, | ||
* if you compared these to objects: | ||
* | ||
* ```js | ||
* { | ||
* foo: { bar: 1 } | ||
* baz: { bax: 2 } | ||
* } | ||
* { | ||
* foo: { bar: -1 }, | ||
* baz: { bax: 2 }, | ||
* } | ||
* ``` | ||
* | ||
* These two have the same `baz` value, but unique `foo` values. Thus | ||
* our expected result would be to include the foo object. | ||
* | ||
* ```js | ||
* { foo: { bar: -1 } } | ||
* ``` | ||
*/ | ||
function intersection(dominantObject, slaveObject) { | ||
var intersectedObject = {}; | ||
for (var key in slaveObject) { | ||
if (!dominantObject.hasOwnProperty(key)) { | ||
for (var key in dominantObject) { | ||
if (!slaveObject.hasOwnProperty(key)) { | ||
continue; | ||
@@ -26,4 +107,20 @@ } | ||
var dominantKeyValue = dominantObject[key]; | ||
var slaveKeyValue = slaveObject[key]; | ||
if (dominantKeyValue !== slaveObject[key]) { | ||
if (Array.isArray(dominantKeyValue)) { | ||
if (arraysAreDifferent(dominantKeyValue, slaveKeyValue)) { | ||
intersectedObject[key] = dominantKeyValue; | ||
} | ||
continue; | ||
} else if ((typeof dominantKeyValue === 'undefined' ? 'undefined' : _typeof(dominantKeyValue)) === 'object') { | ||
if (typeof dominantKeyValue.then === 'function') { | ||
intersectedObject[key] = dominantKeyValue; | ||
} else if (objectsAreDifferent(dominantKeyValue, slaveKeyValue)) { | ||
// check to see if nested object is different | ||
intersectedObject[key] = dominantKeyValue; | ||
} | ||
continue; | ||
} else if (dominantKeyValue !== slaveKeyValue) { | ||
intersectedObject[key] = dominantKeyValue; | ||
@@ -34,4 +131,3 @@ } | ||
return intersectedObject; | ||
}; | ||
} | ||
module.exports = exports['default']; |
@@ -15,6 +15,2 @@ 'use strict'; | ||
var _StatelessWrapper = require('./StatelessWrapper'); | ||
var _StatelessWrapper2 = _interopRequireDefault(_StatelessWrapper); | ||
var _CofluxContainer = require('./CofluxContainer'); | ||
@@ -21,0 +17,0 @@ |
{ | ||
"name": "coflux", | ||
"version": "0.2.0-beta1", | ||
"version": "0.2.0", | ||
"description": "Component-based Flux", | ||
@@ -54,2 +54,3 @@ "main": "lib/index.js", | ||
"istanbul": "^0.4.0", | ||
"jasmine-enzyme": "^1.0.0", | ||
"jest-cli": "^12.0.0", | ||
@@ -67,2 +68,3 @@ "mocha": "^2.2.5", | ||
"collectCoverage": true, | ||
"setupTestFrameworkScriptFile": "node_modules/jasmine-enzyme/lib/jest.js", | ||
"testPathDirs": [ | ||
@@ -69,0 +71,0 @@ "src" |
# coflux | ||
Flux at the Component Level. | ||
[![Circle | ||
CI](https://circleci.com/gh/blainekasten/coflux.svg?style=svg)](https://circleci.com/gh/blainekasten/coflux) | ||
Flux at the Component Level. | ||
[![npm version](https://img.shields.io/npm/v/coflux.svg)](https://www.npmjs.com/package/coflux) | ||
Coflux was built to make your components COMPLETELY autonomous | ||
in both appearance and data. This steals from the ideas of Relay and | ||
Redux and brings new performance benefits previously not possible. | ||
App state is simply a dependency of your components. Coflux was built to make your components define it's own dependencies, and handle it's own UI and actions. This steals from some ideas of Redux with a different implementation and brings new performance benefits previously not possible. | ||
### [Documentation](https://github.com/blainekasten/coflux/tree/master/docs) | ||
@@ -11,0 +13,0 @@ |
@@ -29,2 +29,3 @@ /* | ||
for (const actionName in actions) { | ||
/* istanbul ignore if */ | ||
if (!actions.hasOwnProperty(actionName)) { | ||
@@ -31,0 +32,0 @@ continue; |
import wrap from './wrapComponent'; | ||
import Provider from './Provider'; | ||
import unwrap from './test'; | ||
import unwrap from './unwrapComponent'; | ||
@@ -5,0 +5,0 @@ export { |
@@ -10,6 +10,7 @@ /** | ||
export default (dominantObject: Object, slaveObject: Object) => { | ||
const intersectedObject: Object = {}; | ||
for (const key: string in slaveObject) { | ||
/* | ||
* Tells us, on a nested basis, if objects are the same, or differ at some level | ||
*/ | ||
function objectsAreDifferent(dominantObject: Object, slaveObject: Object) : boolean { | ||
for (const key:string in dominantObject) { | ||
if (!dominantObject.hasOwnProperty(key)) { | ||
@@ -20,4 +21,95 @@ continue; | ||
const dominantKeyValue: any = dominantObject[key]; | ||
const slaveKeyValue: any = slaveObject[key]; | ||
if (dominantKeyValue !== slaveObject[key]) { | ||
if (!slaveKeyValue) { | ||
return true; | ||
} | ||
if (typeof dominantKeyValue === 'object') { | ||
return objectsAreDifferent(dominantKeyValue, slaveKeyValue); | ||
} | ||
if (dominantKeyValue !== slaveKeyValue) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
/* | ||
* compares arrays in a nested basis | ||
*/ | ||
function arraysAreDifferent(dominantArray: Array<any>, slaveArray: Array<any>) : boolean { | ||
// if array has been `push`ed to, it is different | ||
if (slaveArray.length !== dominantArray.length) { | ||
return true; | ||
} | ||
const responseValues = dominantArray.map((dominantIndexValue, index) => { | ||
const slaveIndexValue: any = slaveArray[index]; | ||
if (Array.isArray(dominantIndexValue)) { | ||
return arraysAreDifferent(dominantIndexValue, slaveIndexValue); | ||
} else if (typeof dominantIndexValue === 'object') { | ||
return objectsAreDifferent(dominantIndexValue, slaveIndexValue); | ||
} | ||
return dominantIndexValue !== slaveIndexValue; | ||
}); | ||
return responseValues.indexOf(true) !== -1; | ||
} | ||
/* | ||
* Validates object comparisons and returns the deep nested object that | ||
* is unique. | ||
* | ||
* For example, | ||
* if you compared these to objects: | ||
* | ||
* ```js | ||
* { | ||
* foo: { bar: 1 } | ||
* baz: { bax: 2 } | ||
* } | ||
* { | ||
* foo: { bar: -1 }, | ||
* baz: { bax: 2 }, | ||
* } | ||
* ``` | ||
* | ||
* These two have the same `baz` value, but unique `foo` values. Thus | ||
* our expected result would be to include the foo object. | ||
* | ||
* ```js | ||
* { foo: { bar: -1 } } | ||
* ``` | ||
*/ | ||
export default function intersection(dominantObject: Object, slaveObject: Object) : Object { | ||
const intersectedObject: Object = {}; | ||
for (const key:string in dominantObject) { | ||
if (!slaveObject.hasOwnProperty(key)) { | ||
continue; | ||
} | ||
const dominantKeyValue:any = dominantObject[key]; | ||
const slaveKeyValue:any = slaveObject[key]; | ||
if (Array.isArray(dominantKeyValue)) { | ||
if (arraysAreDifferent(dominantKeyValue, slaveKeyValue)) { | ||
intersectedObject[key] = dominantKeyValue; | ||
} | ||
continue; | ||
} else if (typeof dominantKeyValue === 'object') { | ||
if (typeof dominantKeyValue.then === 'function') { | ||
intersectedObject[key] = dominantKeyValue; | ||
} else if (objectsAreDifferent(dominantKeyValue, slaveKeyValue)) { // check to see if nested object is different | ||
intersectedObject[key] = dominantKeyValue; | ||
} | ||
continue; | ||
} else if (dominantKeyValue !== slaveKeyValue) { | ||
intersectedObject[key] = dominantKeyValue; | ||
@@ -28,2 +120,3 @@ } | ||
return intersectedObject; | ||
}; | ||
} | ||
@@ -5,3 +5,2 @@ /* | ||
import React, { Children } from 'react'; | ||
import StatelessWrapper from './StatelessWrapper'; | ||
import CofluxContainer from './CofluxContainer'; | ||
@@ -8,0 +7,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
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
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
62882
33
1747
80
0
33