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

i18n-iso-countries

Package Overview
Dependencies
Maintainers
1
Versions
112
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

i18n-iso-countries - npm Package Compare versions

Comparing version 0.7.1 to 0.8.0

sv.js

29

index.js

@@ -9,3 +9,4 @@ var fs = require("fs"),

"fr" : require("./fr"),
"nl" : require("./nl")
"nl" : require("./nl"),
"sv" : require("./sv")
};

@@ -19,3 +20,4 @@

alpha3 = {},
numeric = {};
numeric = {},
invertedNumeric = {};
/*jslint stupid: true */

@@ -29,3 +31,4 @@

alpha3[s[1]] = s[0];
numeric[parseInt(s[2], 10)] = s[0];
numeric[parseInt(s[2], 10)] = s[0];
invertedNumeric[s[0]] = parseInt(s[2], 10);
});

@@ -55,2 +58,22 @@ /*jslint stupid: false */

/*
* @param code Alpha-3 code
* @return Numeric code or undefined
*/
function alpha3ToNumeric(code) {
"use strict";
return invertedNumeric[alpha3ToAlpha2(code)];
}
exports.alpha3ToNumeric = alpha3ToNumeric;
/*
* @param code Alpha-2 code
* @return Numeric code or undefined
*/
function alpha2ToNumeric(code) {
"use strict";
return invertedNumeric[code];
}
exports.alpha2ToNumeric = alpha2ToNumeric;
/*
* @param code Numeric code

@@ -57,0 +80,0 @@ * @return Alpha-3 code or undefined

5

package.json
{
"name": "i18n-iso-countries",
"version": "0.7.1",
"version": "0.8.0",
"description": "i18n for ISO 3166-1 country codes",

@@ -20,3 +20,4 @@ "keywords": [

"nl",
"fr"
"fr",
"sv"
],

@@ -23,0 +24,0 @@ "author": {

@@ -33,2 +33,3 @@ [![Build Status](https://secure.travis-ci.org/michaelwittig/node-i18n-iso-countries.png)](http://travis-ci.org/michaelwittig/node-i18n-iso-countries)

* `fr`: french
* `sv`: swedish

@@ -71,2 +72,16 @@ ### Country to Code

### Convert Alpha-3 to Numeric code
`````javascript
var countries = require("i18n-iso-countries");
console.log(countries.alpha3ToNumeric("SWE")); // 752
`````
### Convert Alpha-2 to Numeric code
`````javascript
var countries = require("i18n-iso-countries");
console.log(countries.alpha2ToNumeric("SE")); // 752
`````
### Get all Alpha-2 codes

@@ -73,0 +88,0 @@

@@ -22,2 +22,18 @@ var assert = require("assert-plus"),

});
describe("Alpha-3 to Numeric code", function() {
it("alpha3ToNumeric SWE => 752", function() {
assert.equal(i18niso.alpha3ToNumeric("SWE"), 752);
});
it("alpha3ToNumeric DJI => 262", function() {
assert.equal(i18niso.alpha3ToNumeric("DJI"), 262);
});
});
describe("Alpha-2 to Numeric code", function() {
it("alpha2ToNumeric SE => 752", function() {
assert.equal(i18niso.alpha2ToNumeric("SE"), 752);
});
it("alpha2ToNumeric DJ => 262", function() {
assert.equal(i18niso.alpha2ToNumeric("DJ"), 262);
});
});
describe("Numeric to Alpha-2 code", function() {

@@ -157,2 +173,15 @@ it("toAlpha2 '276' => DE", function() {

});
describe("sv", function () {
var lang = "sv";
it("complete (to less)", function() {
Object.keys(i18niso.getAlpha2Codes()).forEach(function(code) {
assert.notEqual(i18niso.getName(code, lang), undefined, "missing entry for " + code);
});
});
it("complete (too much)", function() {
Object.keys(i18niso.getNames(lang)).forEach(function(code) {
assert.notEqual(i18niso.getAlpha2Codes()[code], -1, "entry for " + code + " is too much");
});
});
});
describe("unsupported language", function () {

@@ -159,0 +188,0 @@ var lang = "unsupported";

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