MCPcopy
hub / github.com/reflux/refluxjs / filterByStoreKeys

Function filterByStoreKeys

src/defineReact.js:432–449  ·  view source on GitHub ↗
(storeKeys, obj)

Source from the content-addressed store, hash-verified

430// filters a state object by storeKeys array (if it exists)
431// if filtering and obj contains no properties to use, returns false to let the component know not to update
432function filterByStoreKeys(storeKeys, obj)
433{
434 // if there are not storeKeys defined then simply return the whole original object
435 if (!storeKeys) {
436 return obj;
437 }
438 // otherwise go through and only update properties that are in the storeKeys array, and return straight false if there are none
439 var doUpdate = false;
440 var updateObj = {};
441 for (var i = 0, ii = storeKeys.length; i < ii; i++) {
442 var prop = storeKeys[i];
443 if (obj.hasOwnProperty(prop)) {
444 doUpdate = true;
445 updateObj[prop] = obj[prop];
446 }
447 }
448 return doUpdate ? updateObj : false;
449}
450
451// this is utilized by some of the global state functionality in order to get a clone that will
452// not continue to be modified as the GlobalState mutates

Callers 1

defineReactFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected