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 6.0.0 to 6.1.0

9

CHANGELOG.md

@@ -5,2 +5,11 @@ # Changelog

# [6.1.0](https://github.com/dmnsgn/async-preloader/compare/v6.0.0...v6.1.0) (2022-01-14)
### Features
* compute font name from src if no id is present ([6703830](https://github.com/dmnsgn/async-preloader/commit/6703830085a40a360e5ce6539614d2361c1c38ec))
# [6.0.0](https://github.com/dmnsgn/async-preloader/compare/v5.2.1...v6.0.0) (2021-12-04)

@@ -7,0 +16,0 @@

30

lib/index.js

@@ -59,3 +59,3 @@ import FontFaceObserver from "fontfaceobserver-es";

this.loadItem = async (item) => {
const extension = AsyncPreloader.getFileExtension(item.src);
const extension = AsyncPreloader.getFileExtension(item.src || "");
const loaderKey = item.loader || AsyncPreloader.getLoaderKey(extension);

@@ -260,3 +260,4 @@ const loadedItem = await this[`load` + loaderKey](item);

this.loadFont = async (item) => {
const fontName = item.id;
const fontName = (item.id ||
AsyncPreloader.getFileName(item.src));
const options = (item.fontOptions || {});

@@ -305,11 +306,30 @@ if (!item.src) {

/**
* Get file extension from path
* Get file extension
*
* @param {(RequestInfo | string)} path
* @param {string} path
* @returns {string}
*/
static getFileExtension(path) {
return (path && (path.match(/[^\\/]\.([^.\\/]+)$/) || [null]).pop());
return (path?.match(/[^\\/]\.([^.\\/]+)$/) || [null]).pop();
}
/**
* Get file base name
*
* @param {string} path
* @returns {string}
*/
static getFileBaseName(path) {
return path.split(/[\\/]/).pop();
}
/**
* Get file name
*
* @param {string} path
* @returns {string}
*/
static getFileName(path) {
return (AsyncPreloader.getFileBaseName(path).split(".").slice(0, -1).join(".") ||
path);
}
/**
* Retrieve loader key from extension (when the loader option isn't specified in the LoadItem)

@@ -316,0 +336,0 @@ *

2

package.json
{
"name": "async-preloader",
"version": "6.0.0",
"version": "6.1.0",
"description": "Assets preloader using ES2017 async/await and fetch.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -104,3 +104,5 @@ import FontFaceObserver from "fontfaceobserver-es";

public loadItem = async (item: LoadItem): Promise<LoadedValue> => {
const extension: string = AsyncPreloader.getFileExtension(item.src);
const extension: string = AsyncPreloader.getFileExtension(
(item.src as string) || ""
);
const loaderKey: LoaderKey =

@@ -318,3 +320,5 @@ item.loader || AsyncPreloader.getLoaderKey(extension);

if (!item.mimeType) {
const extension: string = AsyncPreloader.getFileExtension(item.src);
const extension: string = AsyncPreloader.getFileExtension(
item.src as string
);
item = {

@@ -339,3 +343,4 @@ ...item,

public loadFont = async (item: LoadItem): Promise<FontFace | string> => {
const fontName = item.id as string;
const fontName = (item.id ||
AsyncPreloader.getFileName(item.src as string)) as string;
const options = (item.fontOptions || {}) as FontOptions;

@@ -396,10 +401,31 @@

/**
* Get file extension from path
* Get file extension
*
* @param {(RequestInfo | string)} path
* @param {string} path
* @returns {string}
*/
private static getFileExtension(path?: RequestInfo | string): string {
private static getFileExtension(path: string): string {
return (path?.match(/[^\\/]\.([^.\\/]+)$/) || [null]).pop();
}
/**
* Get file base name
*
* @param {string} path
* @returns {string}
*/
private static getFileBaseName(path: string): string {
return path.split(/[\\/]/).pop();
}
/**
* Get file name
*
* @param {string} path
* @returns {string}
*/
private static getFileName(path: string): string {
return (
path && ((path as string).match(/[^\\/]\.([^.\\/]+)$/) || [null]).pop()
AsyncPreloader.getFileBaseName(path).split(".").slice(0, -1).join(".") ||
path
);

@@ -406,0 +432,0 @@ }

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

/**
* Get file extension from path
* Get file extension
*
* @param {(RequestInfo | string)} path
* @param {string} path
* @returns {string}

@@ -175,2 +175,16 @@ */

/**
* Get file base name
*
* @param {string} path
* @returns {string}
*/
private static getFileBaseName;
/**
* Get file name
*
* @param {string} path
* @returns {string}
*/
private static getFileName;
/**
* Retrieve loader key from extension (when the loader option isn't specified in the LoadItem)

@@ -177,0 +191,0 @@ *

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