Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | import { toStateValue } from './utils'; import { STATE_DELIMITER } from './constants'; export function matchesState(parentStateId, childStateId, delimiter) { if (delimiter === void 0) { delimiter = STATE_DELIMITER; } var parentStateValue = toStateValue(parentStateId, delimiter); var childStateValue = toStateValue(childStateId, delimiter); if (typeof childStateValue === 'string') { if (typeof parentStateValue === 'string') { return childStateValue === parentStateValue; } // Parent more specific than child return false; } if (typeof parentStateValue === 'string') { return parentStateValue in childStateValue; } return Object.keys(parentStateValue).every(function (key) { if (!(key in childStateValue)) { return false; } return matchesState(parentStateValue[key], childStateValue[key]); }); } |