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.6 to 0.0.7

8

dist/index.d.ts
import { IsoLocale } from '@omnicar/sam-types';
export declare type Country = 'DK' | 'SE';
export type Country = 'DK' | 'SE';
export interface IZipCodes {
[key: string]: string;
}
export declare type ZipCodeMap = {
export type ZipCodeMap = {
[key in Country]?: IZipCodes;

@@ -15,5 +15,5 @@ };

}
export declare type CityConf = Pick<ICityLookup, 'locale' | 'fileLocation' | 'global'>;
export type CityConf = Pick<ICityLookup, 'locale' | 'fileLocation' | 'global'>;
export declare const getCountryFromLocale: (locale: IsoLocale) => Country;
export declare const initZipCityCountry: (cityLookup: Pick<ICityLookup, "locale" | "fileLocation" | "global">) => Promise<IZipCodes | undefined>;
export declare const initZipCityCountry: (cityLookup: CityConf) => Promise<IZipCodes | undefined>;
export declare const getCityFromZip: (cityLookup: ICityLookup) => Promise<string | false>;
"use strict";
var _this = this;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCityFromZip = exports.initZipCityCountry = exports.getCountryFromLocale = void 0;
var tslib_1 = require("tslib");
var zipcodeCache = {};
var defaultFileLocation = 'https://cdn.jsdelivr.net/gh/omnicar/sam-zip-city/dist/countries/';
exports.getCountryFromLocale = function (locale) { return locale.split('-')[1]; };
exports.initZipCityCountry = function (cityLookup) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
var getCountryFromLocale = function (locale) { return locale.split('-')[1]; };
exports.getCountryFromLocale = getCountryFromLocale;
var initZipCityCountry = function (cityLookup) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
var locale, _a, fileLocation, global, country, myGlobal, zipcodeCountryMap, scriptPath;

@@ -14,3 +15,3 @@ return tslib_1.__generator(this, function (_b) {

locale = cityLookup.locale, _a = cityLookup.fileLocation, fileLocation = _a === void 0 ? defaultFileLocation : _a, global = cityLookup.global;
country = exports.getCountryFromLocale(locale);
country = (0, exports.getCountryFromLocale)(locale);
if (zipcodeCache[country]) {

@@ -24,4 +25,4 @@ return [2 /*return*/, zipcodeCache[country]];

}
scriptPath = "" + fileLocation + country.toLowerCase() + ".js";
return [4 /*yield*/, loadScript(scriptPath, "zipCity-" + country)
scriptPath = "".concat(fileLocation).concat(country.toLowerCase(), ".js");
return [4 /*yield*/, loadScript(scriptPath, "zipCity-".concat(country))
// Check again if the variable is available

@@ -40,3 +41,4 @@ ];

}); };
exports.getCityFromZip = function (cityLookup) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
exports.initZipCityCountry = initZipCityCountry;
var getCityFromZip = function (cityLookup) { return tslib_1.__awaiter(void 0, void 0, void 0, function () {
var zipcode, countryMap, zipKey, cityName;

@@ -47,3 +49,3 @@ return tslib_1.__generator(this, function (_a) {

zipcode = cityLookup.zipcode;
return [4 /*yield*/, exports.initZipCityCountry(cityLookup)];
return [4 /*yield*/, (0, exports.initZipCityCountry)(cityLookup)];
case 1:

@@ -54,3 +56,3 @@ countryMap = _a.sent();

}
zipKey = ("" + zipcode).replace(' ', '');
zipKey = "".concat(zipcode).replace(' ', '');
cityName = countryMap.hasOwnProperty(zipKey) ? countryMap[zipKey] : false;

@@ -61,4 +63,5 @@ return [2 /*return*/, cityName];

}); };
exports.getCityFromZip = getCityFromZip;
var getZipcodeMapFromGlobal = function (global, country) {
var zipcodeCountryMap = global["zipcodeMap" + country];
var zipcodeCountryMap = global["zipcodeMap".concat(country)];
if (zipcodeCountryMap) {

@@ -88,5 +91,5 @@ zipcodeCache[country] = zipcodeCountryMap;

else {
resolve();
resolve(existingScript);
}
});
};

@@ -10,3 +10,3 @@ {

],
"author": "Erik Beuschau",
"author": "Erik Beuschau, Marko K. Seppänen",
"license": "MIT",

@@ -17,3 +17,3 @@ "dependencies": {

"devDependencies": {
"@omnicar/sam-types": "0.0.156",
"@omnicar/sam-types": "0.0.641",
"@types/jest": "24.0.11",

@@ -23,3 +23,3 @@ "@types/node": "^11.13.0",

"ts-jest": "^24.0.1",
"typescript": "^3.4.1"
"typescript": "^4.1.6"
},

@@ -54,3 +54,3 @@ "jest": {

},
"version": "0.0.6"
"version": "0.0.7"
}

@@ -10,3 +10,3 @@ # SAM zip-city

Yes, but they are in .npmignore and are fetched with [jsdelivr.com](https://www.jsdelivr.com/) directly from Github.
The zip-code are fetched from admin.omnicar.io/data/zip-codes/

@@ -37,2 +37,2 @@ ## How to install

}
```
```
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