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

@shopify/address

Package Overview
Dependencies
Maintainers
24
Versions
128
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@shopify/address - npm Package Compare versions

Comparing version 0.0.0-snapshot-20230727180041 to 0.0.0-snapshot-20240506151112

14

build/cjs/AddressFormatter.js

@@ -17,3 +17,2 @@ 'use strict';

}
constructor(locale) {

@@ -23,7 +22,5 @@ this.locale = locale;

}
updateLocale(locale) {
this.locale = locale;
}
async getCountry(countryCode, {

@@ -38,3 +35,2 @@ includeHiddenZones = false

}
async getCountries({

@@ -52,3 +48,2 @@ includeHiddenZones = false

}
async getZoneName(countryCode, zoneCode) {

@@ -60,2 +55,3 @@ const country = await this.getCountry(countryCode);

}
/* Returns the address ordered in an array based based on the country code

@@ -73,4 +69,2 @@ * Eg.:

*/
async format(address) {

@@ -80,2 +74,3 @@ const country = await this.getCountry(address.country);

}
/* Returns an array that shows how to order fields based on the country code

@@ -93,4 +88,2 @@ * Eg.:

*/
async getOrderedFields(countryCode) {

@@ -100,3 +93,2 @@ const country = await this.getCountry(countryCode);

}
cacheKey(locale, includeHiddenZones) {

@@ -106,3 +98,2 @@ /* Cache list of countries per locale, both with and without hidden zones included */

}
loadCountryFromCache(countryCode, includeHiddenZones) {

@@ -115,5 +106,4 @@ const cachedCountries = ORDERED_COUNTRIES_CACHE.get(this.cacheKey(this.locale, includeHiddenZones));

}
}
exports["default"] = AddressFormatter;

6

build/cjs/format.js

@@ -10,2 +10,3 @@ 'use strict';

const DEFAULT_SHOW_LAYOUT = '{lastName} {firstName}_{company}_{address1} {address2}_{city} {province} {zip}_{country}_{phone}';
/**

@@ -20,3 +21,2 @@ * When it's time to render any address, use this function so that it's properly

*/
function formatAddress(address, country) {

@@ -26,2 +26,3 @@ const layout = country.formatting.show || DEFAULT_SHOW_LAYOUT;

}
/**

@@ -43,3 +44,2 @@ * In an edit form, this function can be used to properly order all the input

*/
function buildOrderedFields(country) {

@@ -49,7 +49,5 @@ const format = country ? country.formatting.edit : DEFAULT_FORM_LAYOUT;

const result = lineTemplate.match(utilities.FIELD_REGEXP);
if (!result) {
return [];
}
return result.map(field => utilities.FIELDS_MAPPING[field]);

@@ -56,0 +54,0 @@ });

@@ -24,7 +24,5 @@ 'use strict';

const countries = await response.json();
if (!('data' in countries) && 'errors' in countries) {
throw new CountryLoaderError(countries);
}
return countries.data.countries;

@@ -49,7 +47,5 @@ });

const country = await response.json();
if (!('data' in country) && 'errors' in country) {
throw new CountryLoaderError(country);
}
return country.data.country;

@@ -62,5 +58,3 @@ });

}
}
function memoizeAsync(asyncFunction) {

@@ -70,7 +64,5 @@ const cache = {};

const stringifiedArgs = JSON.stringify(args);
if (!cache[stringifiedArgs]) {
cache[stringifiedArgs] = asyncFunction.apply(this, args);
}
return cache[stringifiedArgs];

@@ -77,0 +69,0 @@ };

@@ -9,3 +9,2 @@ 'use strict';

/* eslint-disable @typescript-eslint/naming-convention */
const FIELDS_MAPPING = {

@@ -28,19 +27,14 @@ '{firstName}': addressConsts.FieldName.FirstName,

*/
function renderLineTemplate(country, template, address) {
const result = template.match(FIELD_REGEXP);
let line = template;
if (!result) {
return '';
}
let lineIsEmpty = true;
result.forEach(key => {
const addressKey = key.replace('{', '').replace('}', '');
if (address[addressKey]) {
lineIsEmpty = false;
}
switch (addressKey) {

@@ -50,7 +44,5 @@ case addressConsts.FieldName.Country:

break;
case addressConsts.FieldName.Zone:
line = line.replace(`{${addressConsts.FieldName.Zone}}`, address.province ? getZone(country.zones, address.province).name : '');
break;
default:

@@ -61,3 +53,2 @@ line = line.replace(key, address[addressKey] || '');

});
if (lineIsEmpty) {

@@ -69,3 +60,2 @@ return '';

}
function getZone(zones, zoneCode) {

@@ -72,0 +62,0 @@ return zones.find(zone => zone.code === zoneCode) || {

{
"name": "@shopify/address",
"version": "0.0.0-snapshot-20230727180041",
"version": "0.0.0-snapshot-20240506151112",
"license": "MIT",

@@ -26,4 +26,4 @@ "description": "Address utilities for formatting addresses",

"devDependencies": {
"@shopify/address-mocks": "^3.2.2",
"@shopify/jest-dom-mocks": "^5.0.0"
"@shopify/address-mocks": "^3.2.3",
"@shopify/jest-dom-mocks": "^5.0.1"
},

@@ -30,0 +30,0 @@ "sideEffects": false,

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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