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

@ideal-postcodes/jsutil

Package Overview
Dependencies
Maintainers
0
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ideal-postcodes/jsutil - npm Package Compare versions

Comparing version 7.1.0 to 7.1.1

18

dist/assets.d.ts

@@ -7,9 +7,2 @@ declare global {

}
import { LoadState, Config } from "./types";
export declare const downloadAutocompleteStyle: (d?: Document) => HTMLStyleElement;
export declare const autocompletePresent: (w: Window) => boolean;
export declare const loadAutocomplete: (config: Config) => LoadState;
export declare const jQueryPresent: (w: Window) => boolean;
export declare const postcodeLookupPresent: (w: Window) => boolean;
export declare const loadPostcodeLookup: (config: Config) => LoadState;
export declare const clearCache: () => void;

@@ -20,16 +13,5 @@ interface Downloader {

export declare const downloadScript: (url: string, integrity: string) => Downloader;
export declare const downloadJQuery: Downloader;
export declare const downloadPostcodeLookup: Downloader;
export declare const downloadAutocomplete: Downloader;
export declare const loadStyle: (href: string, document: Document) => HTMLLinkElement;
export declare const loadScript: (src: string, integrity: string, document: Document) => HTMLScriptElement;
interface AssetsOptions {
config: Config;
window: Window;
}
interface ReadyAssets {
(options: AssetsOptions): boolean;
}
export declare const readyAssets: ReadyAssets;
export declare const injectStyle: (css: string, document: Document) => HTMLStyleElement;
export {};

70

dist/assets.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.injectStyle = exports.readyAssets = exports.loadScript = exports.loadStyle = exports.downloadAutocomplete = exports.downloadPostcodeLookup = exports.downloadJQuery = exports.downloadScript = exports.clearCache = exports.loadPostcodeLookup = exports.postcodeLookupPresent = exports.jQueryPresent = exports.loadAutocomplete = exports.autocompletePresent = exports.downloadAutocompleteStyle = void 0;
let autocompleteLink;
const downloadAutocompleteStyle = (d) => {
if (autocompleteLink !== undefined)
return autocompleteLink;
const document = d || window.document;
autocompleteLink = (0, exports.loadStyle)("https://cdn.jsdelivr.net/npm/ideal-postcodes-autocomplete@0.2.1/css/ideal-postcodes-autocomplete.css", document);
document.head.appendChild(autocompleteLink);
return autocompleteLink;
};
exports.downloadAutocompleteStyle = downloadAutocompleteStyle;
const autocompletePresent = (w) => {
if (w.IdealPostcodes === undefined)
return false;
if (w.IdealPostcodes.Autocomplete === undefined)
return false;
if (w.IdealPostcodes.Autocomplete.Controller === undefined)
return false;
return true;
};
exports.autocompletePresent = autocompletePresent;
const loadAutocomplete = (config) => {
if (config.autocomplete !== true)
return "complete";
if ((0, exports.autocompletePresent)(window))
return "complete";
(0, exports.downloadAutocompleteStyle)();
(0, exports.downloadAutocomplete)();
return "loading";
};
exports.loadAutocomplete = loadAutocomplete;
const jQueryPresent = (w) => w.jQuery !== undefined;
exports.jQueryPresent = jQueryPresent;
const postcodeLookupPresent = (w) => {
if ((0, exports.jQueryPresent)(w) === false)
return false;
return w.jQuery.prototype.setupPostcodeLookup !== undefined;
};
exports.postcodeLookupPresent = postcodeLookupPresent;
const loadPostcodeLookup = (config) => {
if (config.postcodeLookup !== true)
return "complete";
if ((0, exports.postcodeLookupPresent)(window))
return "complete";
(0, exports.downloadJQuery)();
if ((0, exports.jQueryPresent)(window))
(0, exports.downloadPostcodeLookup)();
return "loading";
};
exports.loadPostcodeLookup = loadPostcodeLookup;
exports.injectStyle = exports.loadScript = exports.loadStyle = exports.downloadScript = exports.clearCache = void 0;
const cache = {};

@@ -58,3 +9,2 @@ const clearCache = () => {

}
autocompleteLink = undefined;
};

@@ -72,5 +22,2 @@ exports.clearCache = clearCache;

exports.downloadScript = downloadScript;
exports.downloadJQuery = (0, exports.downloadScript)("https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js", "sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=");
exports.downloadPostcodeLookup = (0, exports.downloadScript)("https://cdn.jsdelivr.net/npm/jquery-postcodes@3.0.8/dist/postcodes.min.js", "sha256-JZSN3ZEXOFlpSMFjQkHjbKnjHlsFVf8N7p1SbCI0XHI=");
exports.downloadAutocomplete = (0, exports.downloadScript)("https://cdn.jsdelivr.net/npm/ideal-postcodes-autocomplete@0.2.1/dist/ideal-postcodes-autocomplete.min.js", "sha256-lZPaPHBx7V2Gj9iAc8QfVcW02KlWB2gbrqXpGfiEGgo=");
const loadStyle = (href, document) => {

@@ -93,17 +40,2 @@ const link = document.createElement("link");

exports.loadScript = loadScript;
const readyAssets = ({ config, window }) => {
let ready = true;
if (config.autocomplete) {
(0, exports.loadAutocomplete)(config);
if (!(0, exports.autocompletePresent)(window))
ready = false;
}
if (config.postcodeLookup) {
(0, exports.loadPostcodeLookup)(config);
if (!(0, exports.postcodeLookupPresent)(window))
ready = false;
}
return ready;
};
exports.readyAssets = readyAssets;
const injectStyle = (css, document) => {

@@ -110,0 +42,0 @@ const style = document.createElement("style");

@@ -7,9 +7,2 @@ declare global {

}
import { LoadState, Config } from "./types";
export declare const downloadAutocompleteStyle: (d?: Document) => HTMLStyleElement;
export declare const autocompletePresent: (w: Window) => boolean;
export declare const loadAutocomplete: (config: Config) => LoadState;
export declare const jQueryPresent: (w: Window) => boolean;
export declare const postcodeLookupPresent: (w: Window) => boolean;
export declare const loadPostcodeLookup: (config: Config) => LoadState;
export declare const clearCache: () => void;

@@ -20,16 +13,5 @@ interface Downloader {

export declare const downloadScript: (url: string, integrity: string) => Downloader;
export declare const downloadJQuery: Downloader;
export declare const downloadPostcodeLookup: Downloader;
export declare const downloadAutocomplete: Downloader;
export declare const loadStyle: (href: string, document: Document) => HTMLLinkElement;
export declare const loadScript: (src: string, integrity: string, document: Document) => HTMLScriptElement;
interface AssetsOptions {
config: Config;
window: Window;
}
interface ReadyAssets {
(options: AssetsOptions): boolean;
}
export declare const readyAssets: ReadyAssets;
export declare const injectStyle: (css: string, document: Document) => HTMLStyleElement;
export {};

@@ -1,44 +0,1 @@

let autocompleteLink;
export const downloadAutocompleteStyle = (d) => {
if (autocompleteLink !== undefined)
return autocompleteLink;
const document = d || window.document;
autocompleteLink = loadStyle("https://cdn.jsdelivr.net/npm/ideal-postcodes-autocomplete@0.2.1/css/ideal-postcodes-autocomplete.css", document);
document.head.appendChild(autocompleteLink);
return autocompleteLink;
};
export const autocompletePresent = (w) => {
if (w.IdealPostcodes === undefined)
return false;
if (w.IdealPostcodes.Autocomplete === undefined)
return false;
if (w.IdealPostcodes.Autocomplete.Controller === undefined)
return false;
return true;
};
export const loadAutocomplete = (config) => {
if (config.autocomplete !== true)
return "complete";
if (autocompletePresent(window))
return "complete";
downloadAutocompleteStyle();
downloadAutocomplete();
return "loading";
};
export const jQueryPresent = (w) => w.jQuery !== undefined;
export const postcodeLookupPresent = (w) => {
if (jQueryPresent(w) === false)
return false;
return w.jQuery.prototype.setupPostcodeLookup !== undefined;
};
export const loadPostcodeLookup = (config) => {
if (config.postcodeLookup !== true)
return "complete";
if (postcodeLookupPresent(window))
return "complete";
downloadJQuery();
if (jQueryPresent(window))
downloadPostcodeLookup();
return "loading";
};
const cache = {};

@@ -49,3 +6,2 @@ export const clearCache = () => {

}
autocompleteLink = undefined;
};

@@ -61,5 +17,2 @@ export const downloadScript = (url, integrity) => (d) => {

};
export const downloadJQuery = downloadScript("https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js", "sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=");
export const downloadPostcodeLookup = downloadScript("https://cdn.jsdelivr.net/npm/jquery-postcodes@3.0.8/dist/postcodes.min.js", "sha256-JZSN3ZEXOFlpSMFjQkHjbKnjHlsFVf8N7p1SbCI0XHI=");
export const downloadAutocomplete = downloadScript("https://cdn.jsdelivr.net/npm/ideal-postcodes-autocomplete@0.2.1/dist/ideal-postcodes-autocomplete.min.js", "sha256-lZPaPHBx7V2Gj9iAc8QfVcW02KlWB2gbrqXpGfiEGgo=");
export const loadStyle = (href, document) => {

@@ -80,16 +33,2 @@ const link = document.createElement("link");

};
export const readyAssets = ({ config, window }) => {
let ready = true;
if (config.autocomplete) {
loadAutocomplete(config);
if (!autocompletePresent(window))
ready = false;
}
if (config.postcodeLookup) {
loadPostcodeLookup(config);
if (!postcodeLookupPresent(window))
ready = false;
}
return ready;
};
export const injectStyle = (css, document) => {

@@ -96,0 +35,0 @@ const style = document.createElement("style");

20

package.json
{
"name": "@ideal-postcodes/jsutil",
"version": "7.1.0",
"version": "7.1.1",
"description": "Browser Address Autocomplete for api.ideal-postcodes.co.uk",

@@ -31,3 +31,4 @@ "author": {

"test:browsers:latest": "karma start .config/latest.conf.ts",
"test:browsers:legacy": "karma start .config/legacy.conf.ts"
"test:browsers:legacy": "karma start .config/legacy.conf.ts",
"cypress:open": "cypress open"
},

@@ -123,10 +124,10 @@ "browserslist": [

"dotenv": "~16.0.0",
"karma": "~6.3.1",
"karma-babel-preprocessor": "~8.0.1",
"karma-chrome-launcher": "~3.1.0",
"karma": "~6.4.3",
"karma-babel-preprocessor": "~8.0.2",
"karma-chrome-launcher": "~3.2.0",
"karma-cli": "~2.0.0",
"karma-mocha": "~2.0.1",
"karma-typescript": "~5.5.4",
"karma-typescript-es6-transform": "~5.5.2",
"mocha": "~9.2.0",
"karma-typescript-es6-transform": "~5.5.4",
"mocha": "~10.4.0",
"nyc": "~15.1.0",

@@ -138,5 +139,6 @@ "prettier": "~2.7.1",

"source-map-support": "~0.5.19",
"ts-node": "~10.7.0",
"typescript": "~5.2.0"
"ts-node": "~10.9.2",
"typescript": "~5.4.5",
"cypress": "~13.10.0"
}
}
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