Files
todo-frontend/node_modules/lcid/index.js
Agent d12eea7693
Some checks failed
continuous-integration/drone/push Build is failing
fix: 微信登录补充保存username和role
2026-04-04 07:35:21 +00:00

37 lines
621 B
JavaScript

'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);
}
}
}
);