@therms/web-js
Advanced tools
Comparing version 1.3.5 to 1.4.0
@@ -0,1 +1,8 @@ | ||
# [1.4.0](http://bitbucket.org/thermsio/web-js/compare/v1.3.5...v1.4.0) (2022-01-09) | ||
### Features | ||
* **formatAddress:** add util for formatting addresses ([a4a3ff2](http://bitbucket.org/thermsio/web-js/commits/a4a3ff2e3e3e16443970b44098d756258f15c710)) | ||
## [1.3.5](http://bitbucket.org/thermsio/web-js/compare/v1.3.4...v1.3.5) (2021-12-28) | ||
@@ -2,0 +9,0 @@ |
@@ -222,2 +222,51 @@ 'use strict'; | ||
/** | ||
* This helper will format a JSON-schema "like" address (https://schema.org/PostalAddress). THERMS addresses are | ||
* stored in this schema that this func accepts as the param. | ||
* | ||
* @param address | ||
* @param inline | ||
*/ | ||
const formatAddress = (address = { | ||
country: '', | ||
locality: '', | ||
region: '', | ||
postalCode: '', | ||
streetAddress: '', | ||
}, inline = true) => { | ||
let value = ``; | ||
if (inline) { | ||
if (address.streetAddress) { | ||
value += `${address.streetAddress}, `; | ||
} | ||
if (address.locality) { | ||
value += `${address.locality}, `; | ||
} | ||
if (address.region) { | ||
value += `${address.region} `; | ||
} | ||
if (address.postalCode) { | ||
value += `${address.postalCode}`; | ||
} | ||
} | ||
else { | ||
if (address.streetAddress) { | ||
value += `${address.streetAddress} | ||
`; | ||
} | ||
if (address.locality) { | ||
value += `${address.locality}, `; | ||
} | ||
if (address.region) { | ||
value += `${address.region} `; | ||
} | ||
if (address.postalCode) { | ||
value += `${address.postalCode}`; | ||
} | ||
} | ||
if (value.replace(' ', '').length === 0) | ||
return ''; | ||
return value; | ||
}; | ||
const calculatedMap = {}; | ||
@@ -362,2 +411,3 @@ /** | ||
type: 'browser', | ||
// todo: needs to be implemented - should look for sessionStorage, localStorage & cookie for a value | ||
uuid: '', | ||
@@ -416,2 +466,3 @@ }; | ||
exports.flashBrowserTitle = flashBrowserTitle; | ||
exports.formatAddress = formatAddress; | ||
exports.getColorContrast = getColorContrast; | ||
@@ -418,0 +469,0 @@ exports.getCookie = getCookie; |
export * from './services/browser-focus'; | ||
export * from './services/browser-title'; | ||
export * from './services/browser-to-browser-communications'; | ||
export * from './utils/address'; | ||
export * from './utils/color'; | ||
@@ -5,0 +6,0 @@ export * from './services/cookies'; |
export { checkIsBrowserVisible, onBrowserFocusChange } from './services/browser-focus.js'; | ||
export { flashBrowserTitle, setBrowserTitle } from './services/browser-title.js'; | ||
export { b2bComms } from './services/browser-to-browser-communications.js'; | ||
export { formatAddress } from './utils/address.js'; | ||
export { getColorContrast } from './utils/color.js'; | ||
@@ -5,0 +6,0 @@ export { deleteCookie, getCookie, setCookie } from './services/cookies.js'; |
@@ -29,2 +29,3 @@ import Browser from 'bowser'; | ||
type: 'browser', | ||
// todo: needs to be implemented - should look for sessionStorage, localStorage & cookie for a value | ||
uuid: '', | ||
@@ -31,0 +32,0 @@ }; |
{ | ||
"name": "@therms/web-js", | ||
"version": "1.3.5", | ||
"version": "1.4.0", | ||
"description": "Common web/JS tools & utilities", | ||
@@ -5,0 +5,0 @@ "main": "dist/cjs.js", |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
66789
41
1042
0