US State Capitals and Names
US state capitals and names.
Installation
npm install @stdlib/datasets-us-states-capitals-names
Usage
var table = require( '@stdlib/datasets-us-states-capitals-names' );
table()
Returns an object mapping US state capitals to state names.
var t = table();
Examples
var capitalize = require( '@stdlib/string-capitalize' );
var table = require( '@stdlib/datasets-us-states-capitals-names' );
var tbl = table();
function getState( capital ) {
var state;
var parts;
var i;
parts = capital.split( ' ' );
for ( i = 0; i < parts.length; i++ ) {
parts[ i ] = capitalize( parts[ i ] );
}
state = tbl[ parts.join( ' ' ) ];
if ( state === void 0 ) {
throw new Error( 'unrecognized capital. Value: `' + capital + '`.' );
}
return state;
}
console.log( getState( 'Jefferson City' ) );
console.log( getState( 'Trenton' ) );
console.log( getState( 'Sacramento' ) );
CLI
Installation
To use the module as a general utility, install the module globally
npm install -g @stdlib/datasets-us-states-capitals-names
Usage
Usage: us-states-capitals-names [options]
Options:
-h, --help Print this message.
-V, --version Print the package version.
Notes
- Data is written to
stdout
as comma-separated values (CSV), where the first line is a header line.
Examples
$ us-states-capitals-names
capital,name
Montgomery,Alabama
Juneau,Alaska
Phoenix,Arizona
...
License
The data files (databases) are licensed under an Open Data Commons Public Domain Dedication & License 1.0 and their contents are licensed under Creative Commons Zero v1.0 Universal. The software is licensed under Apache License, Version 2.0.
Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Copyright
Copyright © 2016-2021. The Stdlib Authors.