index.js 436 B

12345678910111213141516171819202122
  1. 'use strict';
  2. var invertKv = require('invert-kv');
  3. var all = require('./lcid.json');
  4. var inverted = invertKv(all);
  5. exports.from = function (lcidCode) {
  6. if (typeof lcidCode !== 'number') {
  7. throw new TypeError('Expected a number');
  8. }
  9. return inverted[lcidCode];
  10. };
  11. exports.to = function (localeId) {
  12. if (typeof localeId !== 'string') {
  13. throw new TypeError('Expected a string');
  14. }
  15. return all[localeId];
  16. };
  17. exports.all = all;