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

canada-sgc-codes

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

canada-sgc-codes - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

16

index.js
const data = require("./data/canada-sgc-codes-v2");
/**
* Look up a third-level division by its friendly name and return its SGC code.
* Look up a third-level division by its friendly name and parent province, then return its SGC code.
* @param {string} cd - The third-level division's human-readable name (e.g. "Belleville").
* @param {string} province - The second-level division's abbreviation (e.g. "ON").
* @return {string} The SGC code.
*/
const cdToCode = (cd) => {
if (!cd) throw new Error("Please provide an administrative division");
return data.find(entry => entry.level === "3" && entry.censusDivisionName === cd);
const cdToCode = (cd, province) => {
if (!cd) throw new Error("Please provide a third-level division!");
if (!province) throw new Error("Please provide a second-level division!");
const { provincialCode } = provinceToCode(province);
return data.find(entry => entry.level === "3" && entry.provincialCode === provincialCode && entry.censusDivisionName === cd);
};
const provinceToCode = (province) => {
if (!province) throw new Error("Please provide a second-level division!");
return data.find(entry => entry.level === "2" && entry.provinceName === province);
}
/**

@@ -14,0 +22,0 @@ * Look up a division by its SGC code and return its friendly name.

{
"name": "canada-sgc-codes",
"version": "0.0.1",
"version": "0.0.2",
"description": "A repository of Canadian Standard Geographical Classification codes at the provincial/territorial and census division levels.",

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

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