You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

36 lines
621 B

'use strict';
const invertKv = require('invert-kv');
const all = require('./lcid.json');
const inverted = invertKv(all);
exports.from = lcidCode => {
if (typeof lcidCode !== 'number') {
throw new TypeError('Expected a number');
}
return all[lcidCode];
};
exports.to = localeId => {
if (typeof localeId !== 'string') {
throw new TypeError('Expected a string');
}
const lcidCode = inverted[localeId];
if (lcidCode) {
return Number(inverted[localeId]);
}
};
exports.all = new Proxy(
inverted,
{
get(target, name) {
const lcid = target[name];
if (lcid) {
return Number(lcid);
}
}
}
);