This commit is contained in:
36
node_modules/lcid/index.js
generated
vendored
Normal file
36
node_modules/lcid/index.js
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
'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);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user