New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

covid19-us

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

covid19-us - npm Package Compare versions

Comparing version 1.0.3 to 1.1.0

17

built/src/covid19-map-cases-us.d.ts
export interface ICovid19MapCases {
data: {
Name: string;
Range: string;
"Cases Reported": string;
}[];
dataTable: {
Title: string;
};
Name: string;
Range: string;
"Cases Reported": string;
}

@@ -19,11 +14,13 @@ export interface ICovid19MapCasesRow {

MAP_CASES_URI: string;
MAP_CASES_CSV_URI: string;
debug: any;
constructor();
getURI(): string;
getCDCMapCases(): Promise<ICovid19MapCases>;
getCSVURI(): string;
getCDCMapCases(): Promise<ICovid19MapCases[]>;
correctCasesReportedCaseCount(casesReported: string): number;
isEstimatedNumber(casesReported: string): boolean;
formatCDCMapCasesData(rawCDCData: ICovid19MapCases): ICovid19MapCasesRow[];
formatCDCMapCasesData(rawCDCData: ICovid19MapCases[]): ICovid19MapCasesRow[];
getCDCMapCasesData(): Promise<ICovid19MapCasesRow[]>;
}
//# sourceMappingURL=covid19-map-cases-us.d.ts.map

@@ -8,2 +8,3 @@ "use strict";

var StateUtils = require('states-utils');
var csvtojson = require("csvtojson");
var https_1 = __importDefault(require("https"));

@@ -13,2 +14,3 @@ var Covid19MapCasesUS = /** @class */ (function () {

this.MAP_CASES_URI = "https://www.cdc.gov/coronavirus/2019-ncov/map-cases-us.json";
this.MAP_CASES_CSV_URI = "https://www.cdc.gov/coronavirus/2019-ncov/map-data-cases.csv";
this.debug = Debug("Covid19MapCasesUS");

@@ -19,6 +21,9 @@ }

};
Covid19MapCasesUS.prototype.getCSVURI = function () {
return this.MAP_CASES_CSV_URI;
};
Covid19MapCasesUS.prototype.getCDCMapCases = function () {
var _this = this;
return new Promise(function (resolve, reject) {
https_1.default.get(_this.getURI(), function (res) {
https_1.default.get(_this.getCSVURI(), function (res) {
var body = "";

@@ -30,5 +35,6 @@ _this.debug("status code", res.statusCode);

res.on("end", function () {
var cdcData = JSON.parse(body);
_this.debug("Body response", cdcData);
resolve(cdcData);
csvtojson().fromString(body).then(function (cdcRawData) {
_this.debug("Body response", cdcRawData);
resolve(cdcRawData);
});
});

@@ -77,3 +83,3 @@ }).on('error', function (e) {

var covid19MapCasesData = [];
rawCDCData.data.forEach(function (record) {
rawCDCData.forEach(function (record) {
// if it is not a US state, skipping it.

@@ -80,0 +86,0 @@ if (!StateUtils.getUSPSCode(record.Name)) {

@@ -14,3 +14,3 @@ "use strict";

//console.log(cdcData);
expect(cdcData).to.be.an("object");
expect(cdcData).to.be.an("array");
});

@@ -17,0 +17,0 @@ });

{
"name": "covid19-us",
"version": "1.0.3",
"version": "1.1.0",
"description": "covid-19 CDC US data extractor",

@@ -34,2 +34,3 @@ "main": "built/src/index.js",

"chai": "^4.2.0",
"csvtojson": "^2.0.10",
"debug": "^4.1.1",

@@ -36,0 +37,0 @@ "states-utils": "^1.0.10"

const Debug: any = require('debug');
const StateUtils: any = require('states-utils');
const csvtojson: any = require("csvtojson");

@@ -7,4 +8,5 @@ import https from 'https';

export interface ICovid19MapCases {
data: {Name: string, Range: string, "Cases Reported": string}[];
dataTable: {Title: string};
Name: string,
Range: string,
"Cases Reported": string
}

@@ -21,2 +23,3 @@

MAP_CASES_URI: string = "https://www.cdc.gov/coronavirus/2019-ncov/map-cases-us.json";
MAP_CASES_CSV_URI: string = "https://www.cdc.gov/coronavirus/2019-ncov/map-data-cases.csv";
debug: any;

@@ -32,6 +35,10 @@

getCDCMapCases(): Promise<ICovid19MapCases> {
getCSVURI(): string {
return this.MAP_CASES_CSV_URI;
}
getCDCMapCases(): Promise<ICovid19MapCases[]> {
return new Promise<ICovid19MapCases>((resolve, reject) => {
https.get(this.getURI(), (res) => {
return new Promise<ICovid19MapCases[]>((resolve, reject) => {
https.get(this.getCSVURI(), (res) => {
let body: string = "";

@@ -43,5 +50,6 @@ this.debug("status code", res.statusCode);

res.on("end", () => {
let cdcData: ICovid19MapCases = JSON.parse(body);
this.debug("Body response", cdcData);
resolve(cdcData);
csvtojson().fromString(body).then((cdcRawData: ICovid19MapCases[]) => {
this.debug("Body response", cdcRawData);
resolve(cdcRawData);
});
});

@@ -53,2 +61,3 @@ }).on('error', (e) => {

});
}

@@ -88,5 +97,5 @@

formatCDCMapCasesData(rawCDCData: ICovid19MapCases): ICovid19MapCasesRow[] {
formatCDCMapCasesData(rawCDCData: ICovid19MapCases[]): ICovid19MapCasesRow[] {
let covid19MapCasesData: ICovid19MapCasesRow[] = [];
rawCDCData.data.forEach((record) => {
rawCDCData.forEach((record) => {
// if it is not a US state, skipping it.

@@ -111,3 +120,3 @@ if (!StateUtils.getUSPSCode(record.Name)) {

return new Promise<ICovid19MapCasesRow[]>((resolve, reject) => {
this.getCDCMapCases().then((cdcData: ICovid19MapCases) => {
this.getCDCMapCases().then((cdcData: ICovid19MapCases[]) => {

@@ -114,0 +123,0 @@ resolve(this.formatCDCMapCasesData(cdcData));

@@ -16,5 +16,5 @@ var expect = require('chai').expect;

let covid19MapCasesUS = new Covid19MapCasesUS();
covid19MapCasesUS.getCDCMapCases().then((cdcData: ICovid19MapCases) => {
covid19MapCasesUS.getCDCMapCases().then((cdcData: ICovid19MapCases[]) => {
//console.log(cdcData);
expect(cdcData).to.be.an("object");
expect(cdcData).to.be.an("array");
});

@@ -21,0 +21,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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