Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (record.signalType) continue;
if (record.fStory) {
const [tempState, pathStr] = rxStory(state, record, options);
state = tempState;
if (pathStr) newStories.push(pathStr);
} else {
state = rxLog(state, record, options);
}
}
// Don't expand stories that are already closed upon reception
for (let j = 0, len1 = newStories.length; j < len1; j++) {
const pathStr = newStories[j];
const fOpen = timm.getIn(state, (`mainStory/${pathStr}/fOpen`).split('/'));
if (fOpen) continue;
state = timm.setIn(state, (`mainStory/${pathStr}/fExpanded`).split('/'), false);
}
return state;
};
const forgetRecords = (state0, action, settings) => {
let state = state0;
const { pathStr } = action;
const { maxRecords, forgetHysteresis } = settings;
const path = `mainStory/${pathStr}`.split('/');
const prevStory = timm.getIn(state, path);
const { numRecords } = prevStory;
const targetForget = Math.ceil((numRecords - maxRecords) + (maxRecords * forgetHysteresis));
const { nextStory, numForgotten, updatedStoryPaths } =
forgetRecursively(prevStory, targetForget, {}, prevStory.pathStr);
nextStory.numRecords = numRecords - numForgotten;
state = timm.setIn(state, path, nextStory);
const openStories = updateStoryPaths(state.openStories, updatedStoryPaths);
const closedStories = updateStoryPaths(state.closedStories, updatedStoryPaths);
state = timm.merge(state, { openStories, closedStories });
return state;
};
const updateStory = (state0, pathStr, record) => {
let state = state0;
const { fOpen, title, status, action, storyId } = record;
const path = `mainStory/${pathStr}`.split('/');
const prevStory = timm.getIn(state, path);
const nextStory = timm.merge(prevStory, { fOpen, title, status, lastAction: action });
state = timm.setIn(state, path, nextStory);
if (!nextStory.fOpen) {
state = timm.setIn(state, ['openStories', storyId], undefined);
state = timm.setIn(state, ['closedStories', storyId], pathStr);
}
return state;
};
const getPopulationColor = (populationColor, type, value) => {
if (value.isChanged === "hex") {
const newValue = setIn(populationColor, [type, "hex"], value.hex);
return encodeToString(setIn(newValue, [type, "colorPalette"], null));
}
if (value.isChanged === "opacity") {
return encodeToString(
setIn(populationColor, [type, "opacity"], value.opacity)
);
}
const newValue = setIn(
populationColor,
[type, "colorPalette"],
value.palette
);
return encodeToString(setIn(newValue, [type, "hex"], null));
};
Object.keys(nextSpecs[type] || {}).forEach(depName => {
if (!isLinked(pkgNames, linkPattern, depName)) return;
let depVersion = targetVersions[depName];
if (!depVersion && allSpecs[depName]) {
depVersion = `^${allSpecs[depName].specs.version}`;
}
nextSpecs = setIn(nextSpecs, [type, depName], depVersion);
});
});
const getPopulationColor = (populationColor, type, value) => {
if (value.isChanged === "hex") {
const newValue = setIn(populationColor, [type, "hex"], value.hex);
return encodeToString(setIn(newValue, [type, "colorPalette"], null));
}
if (value.isChanged === "opacity") {
return encodeToString(
setIn(populationColor, [type, "opacity"], value.opacity)
);
}
const newValue = setIn(
populationColor,
[type, "colorPalette"],
value.palette
);
return encodeToString(setIn(newValue, [type, "hex"], null));
};
const removeIn = (object, [...path]) => {
let index = path.pop();
index = Number(index) ? Number(index) : index;
let newObj = getIn(object, path);
newObj = removeAt(newObj, index);
return setIn(object, path, newObj);
};