MCPcopy Create free account
hub / github.com/melonjs/melonJS / unload

Function unload

packages/melonjs/src/loader/loader.js:608–710  ·  view source on GitHub ↗
(asset)

Source from the content-addressed store, hash-verified

606 * @category Assets
607 */
608export function unload(asset) {
609 switch (asset.type) {
610 case "binary":
611 if (!(asset.name in binList)) {
612 return false;
613 }
614
615 delete binList[asset.name];
616 return true;
617
618 case "image":
619 if (!(asset.name in imgList)) {
620 return false;
621 }
622 delete imgList[asset.name];
623 return true;
624
625 case "json":
626 if (!(asset.name in jsonList)) {
627 return false;
628 }
629
630 delete jsonList[asset.name];
631 return true;
632
633 case "js":
634 // ??
635 return true;
636
637 case "fontface":
638 if (
639 typeof typeof globalThis.document !== "undefined" &&
640 typeof globalThis.document.fonts !== "undefined"
641 ) {
642 globalThis.document.fonts.delete(fontList[asset.name]);
643 delete fontList[asset.name];
644 return true;
645 }
646 return false;
647
648 case "tmx":
649 case "tsx":
650 if (!(asset.name in tmxList)) {
651 return false;
652 }
653
654 delete tmxList[asset.name];
655 return true;
656
657 case "audio":
658 return audio.unload(asset.name);
659
660 case "video":
661 if (!(asset.name in videoList)) {
662 return false;
663 }
664
665 delete videoList[asset.name];

Callers 3

#cleanupMethod · 0.90
reloadFunction · 0.70
unloadAllFunction · 0.70

Calls 1

deleteMethod · 0.45

Tested by

no test coverage detected