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

zip-to-timezone

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zip-to-timezone - npm Package Compare versions

Comparing version 1.0.25 to 1.0.26

44

index.js
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
var service_1 = require("./service");
Object.defineProperty(exports, "ZipToTz", { enumerable: true, get: function () { return service_1.ZipToTz; } });
exports.ZipToTz = void 0;
const fs = require('fs');
const yaml = require('js-yaml');
class ZipToTz {
short(zip) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.getTimeZone(zip, 'timezones_to_zipcodes');
});
}
full(zip) {
return __awaiter(this, void 0, void 0, function* () {
return yield this.getTimeZone(zip, 'timezones_to_zipcodes(full name)');
});
}
getTimeZone(zip, fileName) {
return __awaiter(this, void 0, void 0, function* () {
const value = zip.replace(/\s/g, '');
if (!Number.isInteger(Number(value)) || value.length != 5) {
console.log('Invalid format or zipCode length');
}
const filePath = process.cwd();
let fileContents = yield fs.readFileSync(`${filePath}/node_modules/zip-to-timezone/src/.${fileName}.yml`, 'utf8');
let data = yaml.safeLoad(fileContents);
for (const [timezone] of Object.entries(data)) {
const found = data[timezone].find(element => element === value);
if (found)
return timezone;
}
return 'Not found';
});
}
}
exports.ZipToTz = ZipToTz;
//# sourceMappingURL=index.js.map

@@ -1,1 +0,28 @@

export {ZipToTz} from './service';
const fs = require('fs');
const yaml = require('js-yaml');
export class ZipToTz {
async short(zip: string): Promise<string> {
return await this.getTimeZone(zip, 'timezones_to_zipcodes');
}
async full(zip: string): Promise<any> {
return await this.getTimeZone(zip, 'timezones_to_zipcodes(full name)');
}
private async getTimeZone(zip: string, fileName: string): Promise<string> {
const value = zip.replace(/\s/g, '');
if (!Number.isInteger(Number(value)) || value.length != 5) {
console.log('Invalid format or zipCode length')
}
const filePath = process.cwd();
let fileContents = await fs.readFileSync(`${filePath}/node_modules/zip-to-timezone/src/.${fileName}.yml`, 'utf8');
let data = yaml.safeLoad(fileContents);
for (const [timezone] of Object.entries(data)) {
const found = data[timezone].find(element => element === value)
if (found)
return timezone
}
return 'Not found'
}
}

2

package.json
{
"name": "zip-to-timezone",
"version": "1.0.25",
"version": "1.0.26",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

Sorry, the diff of this file is not supported yet

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