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.

19 lines
504 B

4 years ago
  1. 'use strict';
  2. const propertyToValueAliases = require('./data/mappings.js');
  3. const matchPropertyValue = function(property, value) {
  4. const aliasToValue = propertyToValueAliases.get(property);
  5. if (!aliasToValue) {
  6. throw new Error(`Unknown property \`${ property }\`.`);
  7. }
  8. const canonicalValue = aliasToValue.get(value);
  9. if (canonicalValue) {
  10. return canonicalValue;
  11. }
  12. throw new Error(
  13. `Unknown value \`${ value }\` for property \`${ property }\`.`
  14. );
  15. };
  16. module.exports = matchPropertyValue;