Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
country-fns
Advanced tools
Useful country data for forms and stuff.
npm install country-fns --save
Each country in country-fns is represented by an object with the following keys:
name
: Common name and native name in parentheses if available.iso2
: 2 character ISO2 code. Lowercase.dial
: International calling code.format
: Telephone format.Imagine you need to make a "Select Country" input.
import React from 'react'
import { getCountries } from 'country-fns'
const SelectCountry = (props) =>
<select {...props}>
{getCountries().map((c) =>
<option value={c.iso2}>{c.name}</option>
)}
</select>
export default SelectCountry
tel:
and sms:
<a>
elementsgetCountry(code: string): Country
getCountries(): Country[]
countries = { [code: string]: Country }
iso2Codes = string[]
getCountry(code: string): Country
Returns a single country by its ISO2 code.
const { getCountry } = require('country-fns')
const hockeyLand = getCountry('ca')
console.log(hockeyLand.name) // => Canada
console.log(hockeyLand.format) // => Canada
getCountries(): Country[]
Returns an array of all countries
const { getCountries } = require('country-fns')
const allCountries = getCountries()
console.log(allCountries)
/*
[
{
name: 'Afghanistan (افغانستان)',
iso2: 'af',
dial: '93',
format: '+..-..-...-....',
},
{
name: 'Albania (Shqipëri)',
iso2: 'al',
dial: '355',
format: '+...(...)...-...',
},
{
name: 'Algeria (الجزائر)',
iso2: 'dz',
dial: '213',
format: '+...-..-...-....',
},
...
]
*/
countries = { [code: string]: Country }
An object containing all countries, keyed by lowercase ISO2 code.
const { countries } = require('country-fns')
console.log(countries)
/*
{
af: {
name: 'Afghanistan (افغانستان)',
iso2: 'af',
dial: '93',
format: '+..-..-...-....',
},
al: {
name: 'Albania (Shqipëri)',
iso2: 'al',
dial: '355',
format: '+...(...)...-...',
},
dz: {
name: 'Algeria (الجزائر)',
iso2: 'dz',
dial: '213',
format: '+...-..-...-....',
},
...
}
*/
iso2Codes = string[]
An array of all ISO2 Codes (lowercase).
const { iso2Codes } = require('country-fns')
console.log(iso2Codes)
/*
['af', 'al', 'dz', 'as', 'ad', 'ao', ... ]
*/
MIT LICENSE.
FAQs
Useful country data for forms and stuff.
The npm package country-fns receives a total of 399 weekly downloads. As such, country-fns popularity was classified as not popular.
We found that country-fns demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.