How to use the unicode-match-property-value-ecmascript/data/mappings.get function in unicode-match-property-value-ecmascript

To help you get started, we’ve selected a few unicode-match-property-value-ecmascript examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github shapesecurity / shift-regexp-acceptor-js / src / index.js View on Github external
}
  return { matched: characters.length > 0, data: characters.join('') };
};

// excluding nonbinary properties from mathias' list
// https://www.ecma-international.org/ecma-262/9.0/index.html#table-nonbinary-unicode-properties
const illegalLoneUnicodePropertyNames = [
  'General_Category',
  'Script',
  'Script_Extensions',
  'scx',
  'sc',
  'gc',
];

const generalCategoryValues = matchPropertyValueMappings.get('General_Category');

const acceptLoneUnicodePropertyNameOrValue = state => {
  let loneValue = acceptUnicodePropertyValue(state);
  if (!loneValue.matched || illegalLoneUnicodePropertyNames.includes(loneValue.data)) {
    return { matched: false };
  }

  return { matched: catchIsFalse(() => matchProperty(loneValue.data)) || generalCategoryValues.get(loneValue.data) != null };
};

const acceptUnicodePropertyValueExpression = state =>
  anyOf(backtrackOnFailure(subState => {
    let name = acceptUnicodePropertyName(subState);
    if (!name.matched || !subState.eat('=')) {
      return { matched: false };
    }

unicode-match-property-value-ecmascript

Match a Unicode property or property alias to its canonical property name per the algorithm used for RegExp Unicode property escapes in ECMAScript.

MIT
Latest version published 2 years ago

Package Health Score

68 / 100
Full package analysis