index.js 333 B

1234567891011121314151617181920212223
  1. 'use strict';
  2. const arrify = value => {
  3. if (value === null || value === undefined) {
  4. return [];
  5. }
  6. if (Array.isArray(value)) {
  7. return value;
  8. }
  9. if (typeof value === 'string') {
  10. return [value];
  11. }
  12. if (typeof value[Symbol.iterator] === 'function') {
  13. return [...value];
  14. }
  15. return [value];
  16. };
  17. module.exports = arrify;