all files / semantic-graphql/src/utils/ castArrayShape.js

100% Statements 4/4
100% Branches 6/6
100% Functions 1/1
100% Lines 4/4
1 2 3 4 5 6 7 8 9 10            
function castArrayShape(value, shouldBeArray = true) {
  const isArray = Array.isArray(value);
 
  return shouldBeArray ?
    isArray ? value : [value] :
    isArray ? value[0] : value;
}
 
module.exports = castArrayShape;