@garfish/loader
Usage
import Loader from '@garfish/loader';
const loader = new Loader({
maxSize: 10 * 1024 * 1024,
});
loader.lifecycle.beforeLoad.add(({ url, config }) => {
if (url.includes('xx')) {
url = url.replace('xx', '');
}
return { url, config };
});
loader.lifecycle.loaded.add((data) => {
const { result, value } = data;
data.n = 1;
return data;
});
loader.lifecycle.loaded.add((data) => {
console.log(data.n);
return data;
});
loader.load('appName', 'https://xxx').then((result) => {
console.log(result);
});
Clear cache
const loader = new Loader();
loader.clear('appName');
loader.clear('appName', 'js');
loader.clearAll();
loader.clearAll('css');