Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

async-preloader

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-preloader - npm Package Compare versions

Comparing version 8.0.2 to 8.0.3

6

CHANGELOG.md
# Changelog
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
## [8.0.3](https://github.com/dmnsgn/async-preloader/compare/v8.0.2...v8.0.3) (2023-11-02)
## [8.0.2](https://github.com/dmnsgn/async-preloader/compare/v8.0.1...v8.0.2) (2023-02-09)

@@ -6,0 +10,0 @@

86

lib/index.js

@@ -45,4 +45,4 @@ import FontFaceObserver from "fontfaceobserver-es";

*
* @param {(LoadItem[] | string[])} items Items to load
* @returns {Promise<LoadedValue[]>} Resolve when all items are loaded, reject for any error
* @param items Items to load
* @returns Resolve when all items are loaded, reject for any error
*/

@@ -55,4 +55,4 @@ this.loadItems = async (items) => {

*
* @param {(LoadItem | string)} item Item to load
* @returns {Promise<LoadedValue>} Resolve when item is loaded, reject for any error
* @param item Item to load
* @returns Resolve when item is loaded, reject for any error
*/

@@ -72,5 +72,5 @@ this.loadItem = async (item) => {

*
* @param {string} src Manifest src url
* @param {string} [key="items"] Manifest key in the JSON object containing the array of LoadItem.
* @returns {Promise<LoadedValue[]>}
* @param src Manifest src url
* @param key Manifest key in the JSON object containing the array of LoadItem.
* @returns
*/

@@ -88,4 +88,4 @@ this.loadManifest = async (src, key = "items") => {

*
* @param {LoadItem} item Item to load
* @returns {Promise<string>} Fulfilled value of parsed Response
* @param item Item to load
* @returns Fulfilled value of parsed Response
*/

@@ -99,4 +99,4 @@ this.loadText = async (item) => {

*
* @param {LoadItem} item Item to load
* @returns {Promise<JSON>} Fulfilled value of parsed Response
* @param item Item to load
* @returns Fulfilled value of parsed Response
*/

@@ -110,4 +110,4 @@ this.loadJson = async (item) => {

*
* @param {LoadItem} item Item to load
* @returns {Promise<ArrayBuffer>} Fulfilled value of parsed Response
* @param item Item to load
* @returns Fulfilled value of parsed Response
*/

@@ -121,4 +121,4 @@ this.loadArrayBuffer = async (item) => {

*
* @param {LoadItem} item Item to load
* @returns {Promise<Blob>} Fulfilled value of parsed Response
* @param item Item to load
* @returns Fulfilled value of parsed Response
*/

@@ -132,4 +132,4 @@ this.loadBlob = async (item) => {

*
* @param {LoadItem} item Item to load
* @returns {Promise<FormData>} Fulfilled value of parsed Response
* @param item Item to load
* @returns Fulfilled value of parsed Response
*/

@@ -147,4 +147,4 @@ this.loadFormData = async (item) => {

*
* @param {LoadItem} item Item to load
* @returns {Promise<LoadedValue>} Fulfilled value with a decoded HTMLImageElement instance of or a parsed Response according to the "body" option. Defaults to a decoded HTMLImageElement.
* @param item Item to load
* @returns Fulfilled value with a decoded HTMLImageElement instance of or a parsed Response according to the "body" option. Defaults to a decoded HTMLImageElement.
*/

@@ -181,4 +181,4 @@ this.loadImage = async (item) => {

*
* @param {LoadItem} item Item to load
* @returns {Promise<LoadedValue>} Fulfilled value of parsed Response according to the "body" option. Defaults to an HTMLVideoElement with a blob as srcObject or src.
* @param item Item to load
* @returns Fulfilled value of parsed Response according to the "body" option. Defaults to an HTMLVideoElement with a blob as srcObject or src.
*/

@@ -217,4 +217,4 @@ this.loadVideo = async (item) => {

*
* @param {LoadItem} item Item to load
* @returns {Promise<LoadedValue>} Fulfilled value of parsed Response according to the "body" option. Defaults to an HTMLAudioElement with a blob as srcObject or src.
* @param item Item to load
* @returns Fulfilled value of parsed Response according to the "body" option. Defaults to an HTMLAudioElement with a blob as srcObject or src.
*/

@@ -255,4 +255,4 @@ this.loadAudio = async (item) => {

*
* @param {LoadItem} item Item to load (need a mimeType specified or default to "application/xml")
* @returns {Promise<LoadedXMLValue>} Result of Response parsed as a document.
* @param item Item to load (need a mimeType specified or default to "application/xml")
* @returns Result of Response parsed as a document.
*/

@@ -277,4 +277,4 @@ this.loadXml = async (item) => {

*
* @param {LoadItem} item Item to load (id correspond to the font family name).
* @returns {Promise<FontFace | string>} Fulfilled value with FontFace instance or initial id if no src provided.
* @param item Item to load (id correspond to the font family name).
* @returns Fulfilled value with FontFace instance or initial id if no src provided.
*/

@@ -304,4 +304,4 @@ this.loadFont = async (item) => {

*
* @param {LoadItem} item Item to fetch
* @returns {Promise<Response>} Fetch response
* @param item Item to fetch
* @returns Fetch response
*/

@@ -315,5 +315,5 @@ static fetchItem(item) {

*
* @param {any} object Object with nested properties
* @param {(string | string[])} path Path to the desired property
* @returns {any} The returned object property
* @param object Object with nested properties
* @param path Path to the desired property
* @returns The returned object property
*/

@@ -331,4 +331,4 @@ static getProp(object, path) {

*
* @param {string} path
* @returns {string}
* @param path
* @returns
*/

@@ -341,4 +341,4 @@ static getFileExtension(path) {

*
* @param {string} path
* @returns {string}
* @param path
* @returns
*/

@@ -351,4 +351,4 @@ static getFileBaseName(path) {

*
* @param {string} path
* @returns {string}
* @param path
* @returns
*/

@@ -362,4 +362,4 @@ static getFileName(path) {

*
* @param {string} extension
* @returns {LoaderKey}
* @param extension
* @returns
*/

@@ -373,5 +373,5 @@ static getLoaderKey(extension) {

*
* @param {LoaderKey} loaderKey
* @param {string} extension
* @returns {string}
* @param loaderKey
* @param extension
* @returns
*/

@@ -378,0 +378,0 @@ static getMimeType(loaderKey, extension) {

{
"name": "async-preloader",
"version": "8.0.2",
"version": "8.0.3",
"description": "Assets preloader using async/await and fetch for usage both in the browser and Node.js.",

@@ -63,15 +63,15 @@ "keywords": [

"fontfaceobserver-es": "^3.3.3",
"tslib": "^2.5.0"
"tslib": "^2.6.2"
},
"devDependencies": {
"@types/css-font-loading-module": "^0.0.7",
"@types/expect-puppeteer": "^5.0.2",
"@types/jest": "^29.4.0",
"@types/jest-environment-puppeteer": "^5.0.3",
"@types/node": "^18.13.0",
"@types/css-font-loading-module": "^0.0.10",
"@types/expect-puppeteer": "^5.0.5",
"@types/jest": "^29.5.7",
"@types/jest-environment-puppeteer": "^5.0.5",
"@types/node": "^20.8.10",
"@types/puppeteer": "^5.4.7",
"@xmldom/xmldom": "^0.8.6",
"es-module-shims": "^1.6.3",
"jest": "^29.4.2",
"jest-puppeteer": "^7.0.0",
"@xmldom/xmldom": "^0.8.10",
"es-module-shims": "^1.8.1",
"jest": "^29.7.0",
"jest-puppeteer": "^9.0.1",
"jest-ts-webcompat-resolver": "^1.0.0",

@@ -81,18 +81,23 @@ "mime-types": "^2.1.35",

"portfinder": "^1.0.32",
"puppeteer": "^19.6.3",
"puppeteer": "^21.4.1",
"puppeteer-to-istanbul": "^1.4.0",
"snowdev": "^1.14.0",
"ts-jest": "^29.0.5",
"typescript": "^4.9.5"
"snowdev": "^2.0.0-alpha.20",
"ts-jest": "^29.1.1",
"typescript": "^5.2.2"
},
"engines": {
"node": ">=16.0.0",
"npm": ">=7.0.0"
"node": ">=20.0.0",
"npm": ">=9.6.4"
},
"jest-puppeteer": {
"launch": {
"headless": "new"
}
},
"snowdev": {
"dependencies": [
"fontfaceobserver-es",
"es-module-shims"
"es-module-shims",
"fontfaceobserver-es"
]
}
}

@@ -89,7 +89,7 @@ import FontFaceObserver from "fontfaceobserver-es";

*
* @param {(LoadItem[] | string[])} items Items to load
* @returns {Promise<LoadedValue[]>} Resolve when all items are loaded, reject for any error
* @param items Items to load
* @returns Resolve when all items are loaded, reject for any error
*/
public loadItems = async (
items: LoadItem[] | string[]
items: LoadItem[] | string[],
): Promise<LoadedValue[]> => {

@@ -102,4 +102,4 @@ return await Promise.all(items.map(this.loadItem));

*
* @param {(LoadItem | string)} item Item to load
* @returns {Promise<LoadedValue>} Resolve when item is loaded, reject for any error
* @param item Item to load
* @returns Resolve when item is loaded, reject for any error
*/

@@ -110,3 +110,3 @@ public loadItem = async (item: LoadItem | string): Promise<LoadedValue> => {

const extension: string = AsyncPreloader.getFileExtension(
(item.src as string) || ""
(item.src as string) || "",
);

@@ -127,9 +127,9 @@ const loaderKey: LoaderKey =

*
* @param {string} src Manifest src url
* @param {string} [key="items"] Manifest key in the JSON object containing the array of LoadItem.
* @returns {Promise<LoadedValue[]>}
* @param src Manifest src url
* @param key Manifest key in the JSON object containing the array of LoadItem.
* @returns
*/
public loadManifest = async (
src: string,
key = "items"
key = "items",
): Promise<LoadedValue[]> => {

@@ -148,4 +148,4 @@ const loadedManifest: JSON = await this.loadJson({

*
* @param {LoadItem} item Item to load
* @returns {Promise<string>} Fulfilled value of parsed Response
* @param item Item to load
* @returns Fulfilled value of parsed Response
*/

@@ -160,4 +160,4 @@ public loadText = async (item: LoadItem): Promise<string> => {

*
* @param {LoadItem} item Item to load
* @returns {Promise<JSON>} Fulfilled value of parsed Response
* @param item Item to load
* @returns Fulfilled value of parsed Response
*/

@@ -172,4 +172,4 @@ public loadJson = async (item: LoadItem): Promise<JSON> => {

*
* @param {LoadItem} item Item to load
* @returns {Promise<ArrayBuffer>} Fulfilled value of parsed Response
* @param item Item to load
* @returns Fulfilled value of parsed Response
*/

@@ -184,4 +184,4 @@ public loadArrayBuffer = async (item: LoadItem): Promise<ArrayBuffer> => {

*
* @param {LoadItem} item Item to load
* @returns {Promise<Blob>} Fulfilled value of parsed Response
* @param item Item to load
* @returns Fulfilled value of parsed Response
*/

@@ -196,4 +196,4 @@ public loadBlob = async (item: LoadItem): Promise<Blob> => {

*
* @param {LoadItem} item Item to load
* @returns {Promise<FormData>} Fulfilled value of parsed Response
* @param item Item to load
* @returns Fulfilled value of parsed Response
*/

@@ -212,4 +212,4 @@ public loadFormData = async (item: LoadItem): Promise<FormData> => {

*
* @param {LoadItem} item Item to load
* @returns {Promise<LoadedValue>} Fulfilled value with a decoded HTMLImageElement instance of or a parsed Response according to the "body" option. Defaults to a decoded HTMLImageElement.
* @param item Item to load
* @returns Fulfilled value with a decoded HTMLImageElement instance of or a parsed Response according to the "body" option. Defaults to a decoded HTMLImageElement.
*/

@@ -251,10 +251,9 @@ public loadImage = async (item: LoadItem): Promise<LoadedValue> => {

*
* @param {LoadItem} item Item to load
* @returns {Promise<LoadedValue>} Fulfilled value of parsed Response according to the "body" option. Defaults to an HTMLVideoElement with a blob as srcObject or src.
* @param item Item to load
* @returns Fulfilled value of parsed Response according to the "body" option. Defaults to an HTMLVideoElement with a blob as srcObject or src.
*/
public loadVideo = async (item: LoadItem): Promise<LoadedValue> => {
const response: Response = await AsyncPreloader.fetchItem(item);
const data: LoadedValue = await response[
item.body || this.defaultBodyMethod
]();
const data: LoadedValue =
await response[item.body || this.defaultBodyMethod]();

@@ -292,10 +291,9 @@ if (item.body) return data;

*
* @param {LoadItem} item Item to load
* @returns {Promise<LoadedValue>} Fulfilled value of parsed Response according to the "body" option. Defaults to an HTMLAudioElement with a blob as srcObject or src.
* @param item Item to load
* @returns Fulfilled value of parsed Response according to the "body" option. Defaults to an HTMLAudioElement with a blob as srcObject or src.
*/
public loadAudio = async (item: LoadItem): Promise<LoadedValue> => {
const response: Response = await AsyncPreloader.fetchItem(item);
const data: LoadedValue = await response[
item.body || this.defaultBodyMethod
]();
const data: LoadedValue =
await response[item.body || this.defaultBodyMethod]();

@@ -335,4 +333,4 @@ if (item.body) return data;

*
* @param {LoadItem} item Item to load (need a mimeType specified or default to "application/xml")
* @returns {Promise<LoadedXMLValue>} Result of Response parsed as a document.
* @param item Item to load (need a mimeType specified or default to "application/xml")
* @returns Result of Response parsed as a document.
*/

@@ -342,3 +340,3 @@ public loadXml = async (item: LoadItem): Promise<LoadedXMLValue> => {

const extension: string = AsyncPreloader.getFileExtension(
item.src as string
item.src as string,
);

@@ -364,4 +362,4 @@ item = {

*
* @param {LoadItem} item Item to load (id correspond to the font family name).
* @returns {Promise<FontFace | string>} Fulfilled value with FontFace instance or initial id if no src provided.
* @param item Item to load (id correspond to the font family name).
* @returns Fulfilled value with FontFace instance or initial id if no src provided.
*/

@@ -376,3 +374,3 @@ public loadFont = async (item: LoadItem): Promise<FontFace | string> => {

fontName,
(options.variant as FontFaceObserver.FontVariant) || {}
(options.variant as FontFaceObserver.FontVariant) || {},
);

@@ -401,4 +399,4 @@ await font.load(options.testString, options.timeout);

*
* @param {LoadItem} item Item to fetch
* @returns {Promise<Response>} Fetch response
* @param item Item to fetch
* @returns Fetch response
*/

@@ -413,5 +411,5 @@ private static fetchItem(item: LoadItem): Promise<Response> {

*
* @param {any} object Object with nested properties
* @param {(string | string[])} path Path to the desired property
* @returns {any} The returned object property
* @param object Object with nested properties
* @param path Path to the desired property
* @returns The returned object property
*/

@@ -431,4 +429,4 @@ private static getProp(object: unknown, path: string | string[]) {

*
* @param {string} path
* @returns {string}
* @param path
* @returns
*/

@@ -442,4 +440,4 @@ private static getFileExtension(path: string): string {

*
* @param {string} path
* @returns {string}
* @param path
* @returns
*/

@@ -453,4 +451,4 @@ private static getFileBaseName(path: string): string {

*
* @param {string} path
* @returns {string}
* @param path
* @returns
*/

@@ -467,8 +465,8 @@ private static getFileName(path: string): string {

*
* @param {string} extension
* @returns {LoaderKey}
* @param extension
* @returns
*/
private static getLoaderKey(extension: string): LoaderKey {
const loader = Array.from(AsyncPreloader.loaders).find((loader) =>
loader[1].extensions.includes(extension)
loader[1].extensions.includes(extension),
);

@@ -481,9 +479,9 @@ return loader ? loader[0] : LoaderKey.Text;

*
* @param {LoaderKey} loaderKey
* @param {string} extension
* @returns {string}
* @param loaderKey
* @param extension
* @returns
*/
private static getMimeType(
loaderKey: LoaderKey,
extension: string
extension: string,
): DOMParserSupportedType {

@@ -490,0 +488,0 @@ const loader: LoaderValue = AsyncPreloader.loaders.get(loaderKey);

@@ -49,4 +49,4 @@ import { BodyMethod, LoadItem, LoadedValue, LoadedXMLValue, LoaderKey } from "./types.js";

*
* @param {(LoadItem[] | string[])} items Items to load
* @returns {Promise<LoadedValue[]>} Resolve when all items are loaded, reject for any error
* @param items Items to load
* @returns Resolve when all items are loaded, reject for any error
*/

@@ -57,4 +57,4 @@ loadItems: (items: LoadItem[] | string[]) => Promise<LoadedValue[]>;

*
* @param {(LoadItem | string)} item Item to load
* @returns {Promise<LoadedValue>} Resolve when item is loaded, reject for any error
* @param item Item to load
* @returns Resolve when item is loaded, reject for any error
*/

@@ -65,5 +65,5 @@ loadItem: (item: LoadItem | string) => Promise<LoadedValue>;

*
* @param {string} src Manifest src url
* @param {string} [key="items"] Manifest key in the JSON object containing the array of LoadItem.
* @returns {Promise<LoadedValue[]>}
* @param src Manifest src url
* @param key Manifest key in the JSON object containing the array of LoadItem.
* @returns
*/

@@ -74,4 +74,4 @@ loadManifest: (src: string, key?: string) => Promise<LoadedValue[]>;

*
* @param {LoadItem} item Item to load
* @returns {Promise<string>} Fulfilled value of parsed Response
* @param item Item to load
* @returns Fulfilled value of parsed Response
*/

@@ -82,4 +82,4 @@ loadText: (item: LoadItem) => Promise<string>;

*
* @param {LoadItem} item Item to load
* @returns {Promise<JSON>} Fulfilled value of parsed Response
* @param item Item to load
* @returns Fulfilled value of parsed Response
*/

@@ -90,4 +90,4 @@ loadJson: (item: LoadItem) => Promise<JSON>;

*
* @param {LoadItem} item Item to load
* @returns {Promise<ArrayBuffer>} Fulfilled value of parsed Response
* @param item Item to load
* @returns Fulfilled value of parsed Response
*/

@@ -98,4 +98,4 @@ loadArrayBuffer: (item: LoadItem) => Promise<ArrayBuffer>;

*
* @param {LoadItem} item Item to load
* @returns {Promise<Blob>} Fulfilled value of parsed Response
* @param item Item to load
* @returns Fulfilled value of parsed Response
*/

@@ -106,4 +106,4 @@ loadBlob: (item: LoadItem) => Promise<Blob>;

*
* @param {LoadItem} item Item to load
* @returns {Promise<FormData>} Fulfilled value of parsed Response
* @param item Item to load
* @returns Fulfilled value of parsed Response
*/

@@ -117,4 +117,4 @@ loadFormData: (item: LoadItem) => Promise<FormData>;

*
* @param {LoadItem} item Item to load
* @returns {Promise<LoadedValue>} Fulfilled value with a decoded HTMLImageElement instance of or a parsed Response according to the "body" option. Defaults to a decoded HTMLImageElement.
* @param item Item to load
* @returns Fulfilled value with a decoded HTMLImageElement instance of or a parsed Response according to the "body" option. Defaults to a decoded HTMLImageElement.
*/

@@ -128,4 +128,4 @@ loadImage: (item: LoadItem) => Promise<LoadedValue>;

*
* @param {LoadItem} item Item to load
* @returns {Promise<LoadedValue>} Fulfilled value of parsed Response according to the "body" option. Defaults to an HTMLVideoElement with a blob as srcObject or src.
* @param item Item to load
* @returns Fulfilled value of parsed Response according to the "body" option. Defaults to an HTMLVideoElement with a blob as srcObject or src.
*/

@@ -139,4 +139,4 @@ loadVideo: (item: LoadItem) => Promise<LoadedValue>;

*
* @param {LoadItem} item Item to load
* @returns {Promise<LoadedValue>} Fulfilled value of parsed Response according to the "body" option. Defaults to an HTMLAudioElement with a blob as srcObject or src.
* @param item Item to load
* @returns Fulfilled value of parsed Response according to the "body" option. Defaults to an HTMLAudioElement with a blob as srcObject or src.
*/

@@ -150,4 +150,4 @@ loadAudio: (item: LoadItem) => Promise<LoadedValue>;

*
* @param {LoadItem} item Item to load (need a mimeType specified or default to "application/xml")
* @returns {Promise<LoadedXMLValue>} Result of Response parsed as a document.
* @param item Item to load (need a mimeType specified or default to "application/xml")
* @returns Result of Response parsed as a document.
*/

@@ -158,4 +158,4 @@ loadXml: (item: LoadItem) => Promise<LoadedXMLValue>;

*
* @param {LoadItem} item Item to load (id correspond to the font family name).
* @returns {Promise<FontFace | string>} Fulfilled value with FontFace instance or initial id if no src provided.
* @param item Item to load (id correspond to the font family name).
* @returns Fulfilled value with FontFace instance or initial id if no src provided.
*/

@@ -166,4 +166,4 @@ loadFont: (item: LoadItem) => Promise<FontFace | string>;

*
* @param {LoadItem} item Item to fetch
* @returns {Promise<Response>} Fetch response
* @param item Item to fetch
* @returns Fetch response
*/

@@ -175,5 +175,5 @@ private static fetchItem;

*
* @param {any} object Object with nested properties
* @param {(string | string[])} path Path to the desired property
* @returns {any} The returned object property
* @param object Object with nested properties
* @param path Path to the desired property
* @returns The returned object property
*/

@@ -184,4 +184,4 @@ private static getProp;

*
* @param {string} path
* @returns {string}
* @param path
* @returns
*/

@@ -192,4 +192,4 @@ private static getFileExtension;

*
* @param {string} path
* @returns {string}
* @param path
* @returns
*/

@@ -200,4 +200,4 @@ private static getFileBaseName;

*
* @param {string} path
* @returns {string}
* @param path
* @returns
*/

@@ -208,4 +208,4 @@ private static getFileName;

*
* @param {string} extension
* @returns {LoaderKey}
* @param extension
* @returns
*/

@@ -216,5 +216,5 @@ private static getLoaderKey;

*
* @param {LoaderKey} loaderKey
* @param {string} extension
* @returns {string}
* @param loaderKey
* @param extension
* @returns
*/

@@ -221,0 +221,0 @@ private static getMimeType;

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc