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

@omnicar/sam-zip-city

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@omnicar/sam-zip-city - npm Package Compare versions

Comparing version 0.0.11 to 0.0.12

48

dist/index.js

@@ -6,9 +6,13 @@ "use strict";

var node_fetch_1 = require("node-fetch");
// const isFetchJsonLocally = false // Default is 'false'.
/**
* NOTE:
* JSON-files needs to be uploaded to "SAM-admin-v2/public/data/zip-codes/"
* 1. Create a new JSON-file with postal numbers for the new country + create
* tests for it.
* 2. Place the new JSON-file into the directory "countries/" under "src/", so
* it can be tested locally.
* 3. Also upload the new JSON-file to "SAM-admin-v2/public/data/zip-codes/"
* so it will work properly on remote clients.
*/
var searchDataLocations = [/*'./countries/',*/ 'https://admin.omnicar.io/data/zip-codes/'];
var isAllowOnlySupportedCounties = false;
var searchDataLocations = ['./countries/', 'https://admin.omnicar.io/data/zip-codes/'];
var isOnlySupportedCounties = false;
var supportedCountries = ['DK', 'SE', 'FI', 'NO'];

@@ -77,5 +81,6 @@ var zipcodeCache = {};

return tslib_1.__generator(this, function (_a) {
var _b;
switch (_a.label) {
case 0:
if (isAllowOnlySupportedCounties && !supportedCountries.includes(country)) {
if (isOnlySupportedCounties && !supportedCountries.includes(country)) {
console.warn("Warning: This country with isoCode '" + country + "' is not supported");

@@ -89,27 +94,30 @@ return [2 /*return*/, false];

case 1:
if (!(_i < searchDataLocations_1.length)) return [3 /*break*/, 6];
if (!(_i < searchDataLocations_1.length)) return [3 /*break*/, 9];
path = searchDataLocations_1[_i];
_a.label = 2;
case 2:
_a.trys.push([2, 4, , 5]);
return [4 /*yield*/, loadFile(path + country.toLowerCase() + '.json')
// }
];
_a.trys.push([2, 7, , 8]);
if (!path.startsWith('http')) return [3 /*break*/, 4];
return [4 /*yield*/, loadFile(path + country.toLowerCase() + '.json')];
case 3:
// if (isFetchJsonLocally) {
// response = await import('./countries/' + country + '.json')
// } else {
response = _a.sent();
// }
_a.label = 4;
case 4:
if (!!response) return [3 /*break*/, 6];
return [4 /*yield*/, (_b = path + country.toLowerCase() + '.json', Promise.resolve().then(function () { return require(_b); }))];
case 5:
response = _a.sent();
_a.label = 6;
case 6:
zipcodeMap = response.zipcodeMap;
return [2 /*return*/, zipcodeMap];
case 4:
case 7:
err_1 = _a.sent();
console.warn('Warning: Failed importing zip-codes for isoCountry: ' + country + ', from: ' + path + ', ' + (err_1 === null || err_1 === void 0 ? void 0 : err_1.message));
console.warn('Warning: Failed loading zip-codes for isoCountry: ' + country + ', from: ' + path + ', ' + (err_1 === null || err_1 === void 0 ? void 0 : err_1.message));
response = false;
return [3 /*break*/, 5];
case 5:
return [3 /*break*/, 8];
case 8:
_i++;
return [3 /*break*/, 1];
case 6: return [2 /*return*/, false];
case 9: return [2 /*return*/, false];
}

@@ -127,2 +135,4 @@ });

response = _a.sent();
if (!response)
return [2 /*return*/, false];
if (!response.ok) {

@@ -129,0 +139,0 @@ throw new Error("Error! status: ".concat(response.status));

{
"name": "@omnicar/sam-zip-city",
"description": "A simple tool for looking up city names based on zipcode inputs.",
"version": "0.0.11",
"version": "0.0.12",
"main": "dist/index.js",

@@ -6,0 +6,0 @@ "typings": "dist/index.d.ts",

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