i18n-postal-address
Advanced tools
Comparing version 0.4.3 to 0.5.0
@@ -1,3 +0,3 @@ | ||
import { AddressFormats } from './types/address-format'; | ||
import type { AddressFormats } from './types/address-format'; | ||
declare const addressFormats: AddressFormats; | ||
export default addressFormats; |
@@ -1,5 +0,6 @@ | ||
import { ParserInterface } from './types/address-format'; | ||
import type { ParserInterface } from './types/address-format'; | ||
declare const addressParsers: { | ||
array: ParserInterface; | ||
array: ParserInterface<"array">; | ||
string: null; | ||
}; | ||
export default addressParsers; |
@@ -1,3 +0,3 @@ | ||
import { TransformFunction } from './types/address-format'; | ||
import type { TransformFunction } from './types/address-format'; | ||
export declare const addCommaAfter: TransformFunction; | ||
export declare const capitalize: TransformFunction; |
@@ -1,3 +0,3 @@ | ||
import { AddressObject } from './types/address-format'; | ||
import type { AddressObject } from './types/address-format'; | ||
declare const objectInitialState: AddressObject; | ||
export default objectInitialState; |
@@ -1,3 +0,3 @@ | ||
import PostalAddressInterface from './types/postal-address'; | ||
import { AddressFormatPart, AddressObject } from './types/address-format'; | ||
import type PostalAddressInterface from './types/postal-address'; | ||
import type { AddFormatArgs, AddressObject, AddressOutputFormat, AddressOutputFormats, FormatTypes, OutputFormat } from './types/address-format'; | ||
declare class PostalAddress implements PostalAddressInterface { | ||
@@ -13,7 +13,6 @@ private outputFormat; | ||
private addressParsers; | ||
constructor(); | ||
private validator; | ||
constructor(presetState?: Partial<AddressObject>); | ||
private getFormat; | ||
private getParser; | ||
output(overrideFormat?: string): string[][] | string | null; | ||
output<T extends OutputFormat>(overrideFormat: T): AddressOutputFormats[T] | null; | ||
private setProperty; | ||
@@ -45,14 +44,11 @@ setAddress(newValue: string): this; | ||
setTitle(newValue: string): this; | ||
setOutputFormat(string: string): this; | ||
setOutputFormat(format: OutputFormat): this; | ||
setFormat({ country, type, useTransforms, }: { | ||
country?: string; | ||
type?: string; | ||
type?: FormatTypes; | ||
useTransforms?: boolean; | ||
}): this; | ||
addFormat({ country, format, parser, type, }: { | ||
country: string; | ||
format: AddressFormatPart[][]; | ||
parser: string; | ||
type: string; | ||
}): this; | ||
addFormat({ country, format, parser, type, }: AddFormatArgs): this; | ||
toArray(): AddressOutputFormat; | ||
toObject(): AddressObject; | ||
toString(): string; | ||
@@ -59,0 +55,0 @@ raw(): AddressObject; |
@@ -0,2 +1,33 @@ | ||
export interface AddFormatArgs { | ||
country: string; | ||
format: AddressFormatPart[][]; | ||
parser?: string; | ||
type?: string; | ||
} | ||
export interface AddressObject { | ||
address1: string; | ||
address2: string; | ||
addressNum: string; | ||
city: string; | ||
companyName: string; | ||
country: string; | ||
countryAlpha2: string; | ||
do: string; | ||
dong: string; | ||
firstLastName: string; | ||
firstName: string; | ||
gu: string; | ||
honorific: string; | ||
jobTitle: string; | ||
lastName: string; | ||
postalCode: string; | ||
prefecture: string; | ||
province: string; | ||
region: string; | ||
republic: string; | ||
secondLastName: string; | ||
secondName: string; | ||
si: string; | ||
state: string; | ||
title: string; | ||
[key: string]: string; | ||
@@ -8,6 +39,6 @@ } | ||
export interface AddressFormatOptions { | ||
attribute: string; | ||
attribute: keyof AddressObject; | ||
transforms?: TransformFunction[]; | ||
} | ||
export declare type AddressFormatPart = string | AddressFormatOptions; | ||
export declare type AddressFormatPart = keyof AddressObject | AddressFormatOptions; | ||
export interface AddressFormat { | ||
@@ -22,10 +53,21 @@ array?: AddressFormatPart[][]; | ||
export declare type AddressOutputFormat = string[][]; | ||
export declare type AddressOutputFormats = { | ||
array: AddressOutputFormat; | ||
string: string; | ||
}; | ||
export interface Countries { | ||
[key: string]: string; | ||
} | ||
export interface ParserInterface { | ||
(object: AddressObject, format: AddressFormatPart[][], useTransforms: boolean): AddressOutputFormat; | ||
export interface ParserInterface<T extends keyof AddressOutputFormats> { | ||
(object: AddressObject, format: AddressFormatPart[][], useTransforms: boolean): AddressOutputFormats[T]; | ||
} | ||
export interface Validator { | ||
(string: string): boolean; | ||
export interface Validator<K = string> { | ||
(string: K): boolean; | ||
} | ||
export declare type OutputFormat = keyof AddressOutputFormats; | ||
export declare type FormatTypes = 'business' | 'default' | 'english' | 'french' | 'personal'; | ||
export declare type ClassProperties = { | ||
formatForCountry: string; | ||
formatForType: FormatTypes; | ||
outputFormat: OutputFormat; | ||
}; |
@@ -1,9 +0,4 @@ | ||
import { AddressFormatPart, AddressObject } from './address-format'; | ||
import type { AddFormatArgs, AddressObject, AddressOutputFormat, AddressOutputFormats, FormatTypes, OutputFormat } from './address-format'; | ||
export default interface PostalAddressInterface { | ||
addFormat({ country, format, parser, type, }: { | ||
country: string; | ||
format: AddressFormatPart[][]; | ||
parser: string; | ||
type: string; | ||
}): this; | ||
addFormat({ country, format, parser, type }: AddFormatArgs): this; | ||
setAddress(newValue: string): this; | ||
@@ -34,11 +29,13 @@ setAddress1(newValue: string): this; | ||
setTitle(newValue: string): this; | ||
setOutputFormat(string: string): this; | ||
setOutputFormat(string: OutputFormat): this; | ||
setFormat({ country, type, useTransforms, }: { | ||
country?: string; | ||
type?: string; | ||
type?: FormatTypes; | ||
useTransforms?: boolean; | ||
}): this; | ||
output(overrideFormat: string): string[][] | string | null; | ||
output<T extends OutputFormat>(overrideFormat: T): AddressOutputFormats[T] | null; | ||
raw(): AddressObject; | ||
toArray(): AddressOutputFormat; | ||
toObject(): AddressObject; | ||
toString(): string; | ||
raw(): AddressObject; | ||
} |
@@ -1,4 +0,6 @@ | ||
import { AddressFormatPart } from './types/address-format'; | ||
import type { AddressFormatPart, AddressObject, Validator } from './types/address-format'; | ||
export declare const allowedTokens: string[]; | ||
export declare const constructInitialObject: (presetState?: Partial<AddressObject> | undefined) => AddressObject; | ||
export declare const parseValidator: <K = string>(oldValue: K, newValue: K, validatorFn: Validator<K>) => K; | ||
export declare const containsValidTokens: (format: AddressFormatPart[][], parser?: string) => boolean; | ||
export declare const isValidFormat: (format: AddressFormatPart[][], parser?: string) => boolean; |
{ | ||
"name": "i18n-postal-address", | ||
"version": "0.4.3", | ||
"description": "A JavaScript library to produce international postal addresses formatted by region", | ||
"version": "0.5.0", | ||
"description": "A JavaScript library to produce international postal addresses formatted by region for node and the web", | ||
"main": "./dist/postal-address.js", | ||
@@ -16,12 +16,9 @@ "exports": { | ||
], | ||
"browserslist": [ | ||
"last 2 version", | ||
"not dead" | ||
], | ||
"scripts": { | ||
"build:types": "tsc -p tsconfig.declaration.json", | ||
"build": "NODE_ENV=production webpack --mode production", | ||
"build": "NODE_ENV=production webpack", | ||
"clean": "rm -rf ./dist/ && rm -rf ./node_modules/.cache/", | ||
"lint:fix": "eslint . --fix", | ||
"lint": "eslint .", | ||
"prepare": "husky install", | ||
"pretty:fix": "prettier --write .", | ||
@@ -31,5 +28,12 @@ "pretty": "prettier --check .", | ||
"test:unit": "jest", | ||
"test": "jest", | ||
"type-check:watch": "yarn type-check -- --watch", | ||
"type-check": "tsc --noEmit" | ||
}, | ||
"lint-staged": { | ||
"*.{js,ts}": [ | ||
"eslint --cache --fix", | ||
"prettier --write" | ||
] | ||
}, | ||
"repository": { | ||
@@ -44,9 +48,10 @@ "type": "git", | ||
"keywords": [ | ||
"address", | ||
"formatter", | ||
"i18n", | ||
"node", | ||
"postal", | ||
"address", | ||
"formatter", | ||
"web" | ||
], | ||
"author": "Joao Carmo", | ||
"author": "João Carmo", | ||
"license": "MIT", | ||
@@ -57,29 +62,33 @@ "bugs": { | ||
"homepage": "https://github.com/joaocarmo/i18n-postal-address#readme", | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"@babel/core": "^7.13.10", | ||
"@babel/plugin-transform-runtime": "^7.13.10", | ||
"@babel/preset-env": "^7.13.10", | ||
"@babel/preset-typescript": "^7.13.0", | ||
"@babel/runtime": "^7.13.10", | ||
"@types/jest": "^26.0.21", | ||
"@typescript-eslint/eslint-plugin": "^4.18.0", | ||
"@typescript-eslint/parser": "^4.18.0", | ||
"babel-core": "^7.0.0-bridge.0", | ||
"babel-jest": "^26.6.3", | ||
"babel-loader": "^8.2.2", | ||
"core-js": "^3.9.1", | ||
"eslint": "^7.22.0", | ||
"eslint-config-airbnb-base": "^14.2.1", | ||
"eslint-config-prettier": "^8.1.0", | ||
"eslint-plugin-import": "^2.22.1", | ||
"eslint-plugin-jest": "^24.3.2", | ||
"eslint-plugin-prettier": "^3.3.1", | ||
"jest": "^26.6.3", | ||
"prettier": "^2.2.1", | ||
"regenerator-runtime": "^0.13.3", | ||
"typescript": "^4.2.3", | ||
"webpack": "^5.27.1", | ||
"webpack-cli": "^4.5.0" | ||
}, | ||
"dependencies": {} | ||
"@babel/core": "^7.17.8", | ||
"@babel/plugin-transform-runtime": "^7.17.0", | ||
"@babel/preset-env": "^7.16.11", | ||
"@babel/preset-typescript": "^7.16.7", | ||
"@babel/runtime": "^7.17.8", | ||
"@types/jest": "^27.4.1", | ||
"@types/node": "^17.0.23", | ||
"@typescript-eslint/eslint-plugin": "^5.16.0", | ||
"@typescript-eslint/parser": "^5.16.0", | ||
"babel-eslint": "^10.1.0", | ||
"babel-jest": "^27.5.1", | ||
"babel-loader": "^8.2.4", | ||
"core-js": "^3.21.1", | ||
"eslint": "^8.12.0", | ||
"eslint-config-airbnb-base": "^15.0.0", | ||
"eslint-config-airbnb-typescript": "^16.1.4", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-plugin-import": "^2.25.4", | ||
"eslint-plugin-jest": "^26.1.3", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"husky": ">=6", | ||
"jest": "^27.5.1", | ||
"lint-staged": ">=12.3.7", | ||
"prettier": "^2.6.1", | ||
"ts-jest": "^27.1.4", | ||
"typescript": "^4.6.3", | ||
"webpack": "^5.70.0", | ||
"webpack-cli": "^4.9.2" | ||
} | ||
} |
# i18n-postal-address | ||
[](https://badge.fury.io/js/i18n-postal-address) | ||
[](https://github.com/facebook/jest) | ||
 | ||
 | ||
[](https://lgtm.com/projects/g/joaocarmo/i18n-postal-address/alerts/) | ||
@@ -10,3 +9,3 @@ [](https://lgtm.com/projects/g/joaocarmo/i18n-postal-address/context:javascript) | ||
A JavaScript library to produce international postal addresses formatted by | ||
region. | ||
region for Node.js and the web. | ||
@@ -13,0 +12,0 @@ ## Installation |
Sorry, the diff of this file is too big to display
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
80635
20
198
0
28
272