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.1 to 7.2.0

6

dist/address.d.ts
import { AnyAddress, GbrAddress } from "./types";
import { Targets, OutputFields, LineCount, NamedFields } from "./types";
import { SelectorNode, Targets, OutputFields, UsaOutputFields, LineCount, NamedFields } from "./types";
export declare const numberOfLines: (targets: Targets) => LineCount;

@@ -50,2 +50,6 @@ export declare const join: (list: unknown[]) => string;

export declare const removeOrganisation: (address: GbrAddress) => GbrAddress;
export declare const getCountyIsoSelector: (a: OutputFields | UsaOutputFields) => SelectorNode | null;
export declare const getCountySelector: (a: OutputFields | UsaOutputFields) => SelectorNode | null;
export declare const getCountyIso: (a: AnyAddress) => string;
export declare const getCounty: (a: AnyAddress) => string;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.removeOrganisation = exports.populateAddress = exports.mutateAddress = exports.searchLabels = exports.searchNames = exports.searchFields = exports.getFields = exports.extract = exports.toAddressLines = exports.toMaxLengthLines = exports.charArrayLength = exports.join = exports.numberOfLines = void 0;
exports.getCounty = exports.getCountyIso = exports.getCountySelector = exports.getCountyIsoSelector = exports.removeOrganisation = exports.populateAddress = exports.mutateAddress = exports.searchLabels = exports.searchNames = exports.searchFields = exports.getFields = exports.extract = exports.toAddressLines = exports.toMaxLengthLines = exports.charArrayLength = exports.join = exports.numberOfLines = void 0;
const input_1 = require("./input");

@@ -229,2 +229,14 @@ const dom_1 = require("./dom");

(0, input_1.update)(iso3Elem, address.country_iso || "");
const countyIso = (0, dom_1.toElem)((0, exports.getCountyIsoSelector)(fields), scope);
const countyIsoValue = (0, exports.getCountyIso)(address);
const countyValue = (0, exports.getCounty)(address);
if ((0, input_1.isSelect)(countyIso)) {
if ((0, input_1.hasValue)(countyIso, countyIsoValue))
(0, input_1.change)({ e: countyIso, value: countyIsoValue });
if ((0, input_1.hasValue)(countyIso, countyValue || ""))
(0, input_1.change)({ e: countyIso, value: countyValue || "" });
}
if ((0, input_1.isInput)(countyIso)) {
(0, input_1.update)(countyIso, countyIsoValue);
}
let e;

@@ -258,1 +270,26 @@ for (e in fields) {

exports.removeOrganisation = removeOrganisation;
const isUsaOutputFields = (a) => a.hasOwnProperty("state_abbreviation");
const getCountyIsoSelector = (a) => {
if (isUsaOutputFields(a))
return a.state_abbreviation || null;
return a.county_code || null;
};
exports.getCountyIsoSelector = getCountyIsoSelector;
const getCountySelector = (a) => {
if (isUsaOutputFields(a))
return a.state || null;
return a.county || null;
};
exports.getCountySelector = getCountySelector;
const getCountyIso = (a) => {
if ((0, types_1.isGbrAddress)(a))
return a.county_code;
return a.state_abbreviation;
};
exports.getCountyIso = getCountyIso;
const getCounty = (a) => {
if ((0, types_1.isGbrAddress)(a))
return a.county;
return a.state;
};
exports.getCounty = getCounty;

2

dist/types.d.ts

@@ -71,5 +71,5 @@ import { components } from "@ideal-postcodes/openapi";

export type OutputFields = Partial<Record<keyof GbrAddress, SelectorNode>>;
export type UsaOutputFields = Partial<Record<keyof GbrAddress, SelectorNode>>;
export type UsaOutputFields = Partial<Record<keyof UsaAddress, SelectorNode>>;
export type NamedFields = Partial<Record<keyof GbrAddress, string>>;
export type SelectorNode = string | HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement;
export declare const isGbrAddress: (address: AnyAddress) => address is GbrAddress;
import { AnyAddress, GbrAddress } from "./types";
import { Targets, OutputFields, LineCount, NamedFields } from "./types";
import { SelectorNode, Targets, OutputFields, UsaOutputFields, LineCount, NamedFields } from "./types";
export declare const numberOfLines: (targets: Targets) => LineCount;

@@ -50,2 +50,6 @@ export declare const join: (list: unknown[]) => string;

export declare const removeOrganisation: (address: GbrAddress) => GbrAddress;
export declare const getCountyIsoSelector: (a: OutputFields | UsaOutputFields) => SelectorNode | null;
export declare const getCountySelector: (a: OutputFields | UsaOutputFields) => SelectorNode | null;
export declare const getCountyIso: (a: AnyAddress) => string;
export declare const getCounty: (a: AnyAddress) => string;
export {};

@@ -215,2 +215,14 @@ import { isInputElem, update, change, isSelect, isInput, hasValue, } from "./input";

update(iso3Elem, address.country_iso || "");
const countyIso = toElem(getCountyIsoSelector(fields), scope);
const countyIsoValue = getCountyIso(address);
const countyValue = getCounty(address);
if (isSelect(countyIso)) {
if (hasValue(countyIso, countyIsoValue))
change({ e: countyIso, value: countyIsoValue });
if (hasValue(countyIso, countyValue || ""))
change({ e: countyIso, value: countyValue || "" });
}
if (isInput(countyIso)) {
update(countyIso, countyIsoValue);
}
let e;

@@ -242,1 +254,22 @@ for (e in fields) {

};
const isUsaOutputFields = (a) => a.hasOwnProperty("state_abbreviation");
export const getCountyIsoSelector = (a) => {
if (isUsaOutputFields(a))
return a.state_abbreviation || null;
return a.county_code || null;
};
export const getCountySelector = (a) => {
if (isUsaOutputFields(a))
return a.state || null;
return a.county || null;
};
export const getCountyIso = (a) => {
if (isGbrAddress(a))
return a.county_code;
return a.state_abbreviation;
};
export const getCounty = (a) => {
if (isGbrAddress(a))
return a.county;
return a.state;
};

@@ -71,5 +71,5 @@ import { components } from "@ideal-postcodes/openapi";

export type OutputFields = Partial<Record<keyof GbrAddress, SelectorNode>>;
export type UsaOutputFields = Partial<Record<keyof GbrAddress, SelectorNode>>;
export type UsaOutputFields = Partial<Record<keyof UsaAddress, SelectorNode>>;
export type NamedFields = Partial<Record<keyof GbrAddress, string>>;
export type SelectorNode = string | HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement;
export declare const isGbrAddress: (address: AnyAddress) => address is GbrAddress;
{
"name": "@ideal-postcodes/jsutil",
"version": "7.1.1",
"version": "7.2.0",
"description": "Browser Address Autocomplete for api.ideal-postcodes.co.uk",

@@ -28,6 +28,4 @@ "author": {

"prepublishOnly": "npm run build",
"test": "karma start",
"test": "cypress run",
"test:treeshakeable": "agadoo esm/index.js",
"test:browsers:latest": "karma start .config/latest.conf.ts",
"test:browsers:legacy": "karma start .config/legacy.conf.ts",
"cypress:open": "cypress open"

@@ -34,0 +32,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