Skip to content

Commit a4bc3eb

Browse files
committed
Refactor geographic data fetching functions and update version to 1.1.13
1 parent bfeb018 commit a4bc3eb

File tree

5 files changed

+61
-30
lines changed

5 files changed

+61
-30
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,16 +172,16 @@ If you prefer not to install the package and want to include the ECMAScript modu
172172
project, you can use the following script tag:
173173

174174
- CDN (
175-
jsDelivr): [`https://cdn.jsdelivr.net/npm/use-postal-ph@1.1.12/dist/index.mjs`](https://cdn.jsdelivr.net/npm/use-postal-ph@1.1.10/dist/index.mjs)
175+
jsDelivr): [`https://cdn.jsdelivr.net/npm/use-postal-ph@1.1.13/dist/index.mjs`](https://cdn.jsdelivr.net/npm/use-postal-ph@1.1.10/dist/index.mjs)
176176

177-
- NPM: [`https://unpkg.com/use-postal-ph@1.1.12/dist/index.mjs`](https://unpkg.com/use-postal-ph@1.1.10/dist/index.mjs)
177+
- NPM: [`https://unpkg.com/use-postal-ph@1.1.13/dist/index.mjs`](https://unpkg.com/use-postal-ph@1.1.10/dist/index.mjs)
178178

179179
Import Statement:
180180

181181
```html
182182

183183
<script type="module">
184-
import usePostalPH from 'https://unpkg.com/use-postal-ph@1.1.12/dist/index.mjs';
184+
import usePostalPH from 'https://unpkg.com/use-postal-ph@1.1.13/dist/index.mjs';
185185
186186
const {
187187
fetchDataLists,

package.json

Lines changed: 51 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "use-postal-ph",
3-
"version": "1.1.12",
3+
"version": "1.1.13",
44
"description": "This utility library is specifically designed for the Philippines, providing comprehensive information on postal codes,\nmunicipalities, locations, and regions. Moreover, searching within the library is case insensitive.",
55
"main": "./dist/index.js",
66
"module": "./dist/index.mjs",
@@ -11,21 +11,55 @@
1111
"use-ph",
1212
"use-postal-ph",
1313
"postal-ph",
14-
"postal",
15-
"postcode",
16-
"post-code",
14+
"philippines",
1715
"zipcode",
18-
"zip-code",
16+
"postal-code",
1917
"address",
2018
"municipality",
21-
"philippines",
22-
"utility",
23-
"library",
24-
"utility-library",
19+
"region",
2520
"geolocation",
26-
"offline",
27-
"phil",
28-
"hooks"
21+
"utility-library",
22+
"hooks",
23+
"use-postal-ph",
24+
"use-ph",
25+
"philippine-postal-codes",
26+
"location-data",
27+
"offline-geolocation",
28+
"philippine-zipcode",
29+
"ph-postal-codes",
30+
"filipino-zipcode",
31+
"postal-address",
32+
"region-data",
33+
"location-hooks",
34+
"philippine-utility",
35+
"geospatial-data",
36+
"localization",
37+
"city-postal-codes",
38+
"zip-code-lookup",
39+
"address-lookup",
40+
"ph-zipcode",
41+
"localization-library",
42+
"geo-data",
43+
"address-validation",
44+
"philippine-address",
45+
"address-format",
46+
"postcode-lookup",
47+
"philippine-geo-data",
48+
"location-based",
49+
"address-search",
50+
"geospatial-library",
51+
"postal-system",
52+
"location-services",
53+
"filipino-address",
54+
"postal-code-utility",
55+
"country-postal-codes",
56+
"address-utility",
57+
"geolocation-hooks",
58+
"location-utils",
59+
"city-lookup",
60+
"area-codes",
61+
"zipcode-validation",
62+
"postal-code-search"
2963
],
3064
"author": "blckclov3r",
3165
"license": "MIT",
@@ -48,11 +82,11 @@
4882
"access": "public"
4983
},
5084
"scripts": {
51-
"test": "pnpm playwright test",
52-
"test-headed": "pnpm playwright test --headed",
53-
"test-web": "pnpm playwright test --ui web",
54-
"codegen": "pnpm playwright codegen",
55-
"debug-web": "pnpm playwright test web --debug",
85+
"test": "npx playwright test",
86+
"test-headed": "npx playwright test --headed",
87+
"test-web": "npx playwright test --ui web",
88+
"codegen": "npx playwright codegen",
89+
"debug-web": "npx playwright test web --debug",
5690
"report": "playwright show-report",
5791
"build": "tsup",
5892
"start": "node dist/index.js"

src/logic/geographicDataFetcher.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {PlaceListCriteriaProps, PlaceProps, SearchCriteriaProps} from "../types/
99

1010
export default function geographicDataFetcher() {
1111
const {placeDataProvider} = placeDataArray();
12-
const data = placeDataProvider ? placeDataProvider().data : [];
12+
const data = (placeDataProvider ? placeDataProvider().data : []) as PlaceProps[];
1313
let municipalityList: string[] = [];
1414
let postCodeList: number[] = [];
1515
let locationList: string[] = [];
@@ -66,7 +66,7 @@ export default function geographicDataFetcher() {
6666
if (error instanceof Error) {
6767
const errorMessage = `An error occurred in ${name}: ${error.message}`;
6868
console.error(errorMessage);
69-
throw error; // Re-throw the error
69+
throw error;
7070
} else {
7171
const unknownErrorMessage = `An unknown error occurred in ${name}: ${error}`;
7272
console.error(unknownErrorMessage);
@@ -94,7 +94,7 @@ export default function geographicDataFetcher() {
9494
};
9595
};
9696

97-
const fetchMunicipalities = ({search, limit}: SearchCriteriaProps = {search: "", limit: 0}) => {
97+
const fetchMunicipalities = ({search, limit}: SearchCriteriaProps = {search: ""}) => {
9898
try {
9999
if (search) {
100100
return filterData('municipality', search, limit, true);
@@ -110,7 +110,7 @@ export default function geographicDataFetcher() {
110110
}
111111
};
112112

113-
const fetchPostCodes = ({search, limit}: SearchCriteriaProps = {search: "", limit: 0}) => {
113+
const fetchPostCodes = ({search, limit}: SearchCriteriaProps = {search: ""}) => {
114114
try {
115115
if (search) {
116116
return findData('post_code', search);
@@ -126,7 +126,7 @@ export default function geographicDataFetcher() {
126126
}
127127
};
128128

129-
const fetchLocations = ({search, limit}: SearchCriteriaProps = {search: "", limit: 0}) => {
129+
const fetchLocations = ({search, limit}: SearchCriteriaProps = {search: ""}) => {
130130
try {
131131
if (search) {
132132
return filterData('location', search, limit, true);
@@ -142,7 +142,7 @@ export default function geographicDataFetcher() {
142142
}
143143
};
144144

145-
const fetchRegions = ({search, limit}: SearchCriteriaProps = {}) => {
145+
const fetchRegions = ({search, limit}: SearchCriteriaProps = {search: ""}) => {
146146
try {
147147
if (search) {
148148
return filterData('region', search, limit, false);

src/types/placeTypes.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ export type PlaceProps = {
55
region?: string;
66
};
77

8-
export type PlaceDataProps = {
9-
data: PlaceProps[];
10-
};
11-
128
export type SearchCriteriaProps = {
139
search?: string | number;
1410
limit?: number;

tsup.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export default defineConfig({
3131
evaluate: true,
3232
join_vars: true,
3333
if_return: true,
34+
defaults: true,
3435
},
3536
ecma: 5,
3637
},

0 commit comments

Comments
 (0)