You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
zapdb-kv/src/lookup-timezone-name.js

20 lines
521 B
JavaScript

"use strict";
const syncpipe = require("syncpipe");
const timezoneNames = require("./data/timezone-names");
let inverseMapping = syncpipe(timezoneNames, [
_ => _.map((name, i) => [ name, i ]),
_ => new Map(_)
]);
module.exports = function lookupTimezoneName(name) {
if (inverseMapping.has(name)) {
return inverseMapping.get(name);
} else {
// FIXME: Error type, clearer instructions for end users since this may also happen when our timezone list is outdated
throw new Error(`Unknown timezone name`);
}
};