utils.js 468 B

12345678910111213141516171819202122
  1. export function objectOrFunction(x) {
  2. let type = typeof x;
  3. return x !== null && (type === 'object' || type === 'function');
  4. }
  5. export function isFunction(x) {
  6. return typeof x === 'function';
  7. }
  8. export function isMaybeThenable(x) {
  9. return x !== null && typeof x === 'object';
  10. }
  11. let _isArray;
  12. if (Array.isArray) {
  13. _isArray = Array.isArray;
  14. } else {
  15. _isArray = x => Object.prototype.toString.call(x) === '[object Array]';
  16. }
  17. export const isArray = _isArray;