penguinmod-editor / src /lib /libraries /tw-async-libraries.js
soiz1's picture
Upload 1525 files
f2bee8a verified
raw
history blame contribute delete
701 Bytes
const asyncLibrary = callback => {
let data = null;
return () => {
if (data) return data;
return callback()
.then(mod => (data = mod.default));
};
};
export const getBackdropLibrary = asyncLibrary(
() => import(/* webpackChunkName: "library-backdrops" */ './backdrops.json')
);
export const getCostumeLibrary = asyncLibrary(
() => import(/* webpackChunkName: "library-costumes" */ './costumes.json')
);
export const getSoundLibrary = asyncLibrary(
() => import(/* webpackChunkName: "library-sounds" */ './sounds.json')
);
export const getSpriteLibrary = asyncLibrary(
() => import(/* webpackChunkName: "library-sprites" */ './sprites.json')
);