UNPKG

@supabase/storage-js

Version:

Isomorphic storage client for Supabase.

60 lines 2.4 kB
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; export const resolveFetch = (customFetch) => { let _fetch; if (customFetch) { _fetch = customFetch; } else if (typeof fetch === 'undefined') { _fetch = (...args) => import('@supabase/node-fetch').then(({ default: fetch }) => fetch(...args)); } else { _fetch = fetch; } return (...args) => _fetch(...args); }; export const resolveResponse = () => __awaiter(void 0, void 0, void 0, function* () { if (typeof Response === 'undefined') { // @ts-ignore return (yield import('@supabase/node-fetch')).Response; } return Response; }); export const recursiveToCamel = (item) => { if (Array.isArray(item)) { return item.map((el) => recursiveToCamel(el)); } else if (typeof item === 'function' || item !== Object(item)) { return item; } const result = {}; Object.entries(item).forEach(([key, value]) => { const newKey = key.replace(/([-_][a-z])/gi, (c) => c.toUpperCase().replace(/[-_]/g, '')); result[newKey] = recursiveToCamel(value); }); return result; }; /** * Determine if input is a plain object * An object is plain if it's created by either {}, new Object(), or Object.create(null) * source: https://github.com/sindresorhus/is-plain-obj */ export const isPlainObject = (value) => { if (typeof value !== 'object' || value === null) { return false; } const prototype = Object.getPrototypeOf(value); return ((prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value)); }; //# sourceMappingURL=helpers.js.map