aswi2020vldc-gitlab/templetes/node_modules/lcid/index.js @ 4605a44b
1 |
'use strict'; |
---|---|
2 |
const invertKv = require('invert-kv'); |
3 |
const all = require('./lcid.json'); |
4 |
|
5 |
const inverted = invertKv(all); |
6 |
|
7 |
exports.from = lcidCode => { |
8 |
if (typeof lcidCode !== 'number') { |
9 |
throw new TypeError('Expected a number'); |
10 |
}
|
11 |
|
12 |
return inverted[lcidCode]; |
13 |
};
|
14 |
|
15 |
exports.to = localeId => { |
16 |
if (typeof localeId !== 'string') { |
17 |
throw new TypeError('Expected a string'); |
18 |
}
|
19 |
|
20 |
return all[localeId]; |
21 |
};
|
22 |
|
23 |
exports.all = all; |