index.js 504 B

12345678910111213141516171819
  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;