@codelet/core
Version:
mini core
20 lines (19 loc) • 563 B
JavaScript
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;
}
});
});