All files / style9/src list-dynamic-keys.js

100% Statements 11/11
100% Branches 6/6
100% Functions 1/1
100% Lines 9/9

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 208x     58x   58x 48x   46x 11x   10x       55x     8x  
const { isDynamicKey, getStaticKey } = require('./utils/ast');
 
function listDynamicKeys(references, allKeys) {
  const dynamicKeys = [];
 
  for (const ref of references) {
    if (ref.parentPath.isSpreadElement()) return allKeys;
 
    if (ref.parentPath.isMemberExpression()) {
      if (isDynamicKey(ref.parentPath)) return allKeys;
 
      dynamicKeys.push(getStaticKey(ref.parentPath));
    }
  }
 
  return dynamicKeys;
}
 
module.exports = listDynamicKeys;