toArrayIfNot.js 215 B

123456789101112131415
  1. // converts non-array item to array
  2. const toArrayIfNot = (item) => {
  3. if (item == null) {
  4. return [];
  5. }
  6. if (Array.isArray(item)) {
  7. return item;
  8. }
  9. return [item];
  10. };
  11. module.exports = toArrayIfNot;