UNPKG

@codelet/core

Version:
20 lines (19 loc) 563 B
import { isFunction } from '@daysnap/utils'; import { definePlugin, promisify } from '../utils'; const exclude = ['getFileSystemManager', 'base64ToArrayBuffer']; export const apiProxy = definePlugin((col) => { Object.entries(wx).forEach(([key, fn]) => { if (exclude.includes(key) || key.endsWith('Sync')) { ; col[key] = fn.bind(wx); } else if (isFunction(fn)) { ; col[key] = promisify(fn).bind(wx); } else { ; col[key] = fn; } }); });