package.index.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of unicode-match-property-value-ecmascript Show documentation
Show all versions of unicode-match-property-value-ecmascript Show documentation
Match a Unicode property or property alias to its canonical property name per the algorithm used for RegExp Unicode property escapes in ECMAScript.
The newest version!
'use strict';
const propertyToValueAliases = require('./data/mappings.js');
const matchPropertyValue = function(property, value) {
const aliasToValue = propertyToValueAliases.get(property);
if (!aliasToValue) {
throw new Error(`Unknown property \`${ property }\`.`);
}
const canonicalValue = aliasToValue.get(value);
if (canonicalValue) {
return canonicalValue;
}
throw new Error(
`Unknown value \`${ value }\` for property \`${ property }\`.`
);
};
module.exports = matchPropertyValue;