Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
unicode-match-property-value-ecmascript
Advanced tools
Match a Unicode property or property alias to its canonical property name per the algorithm used for RegExp Unicode property escapes in ECMAScript.
The unicode-match-property-value-ecmascript npm package is designed for matching Unicode property values in a given input according to the ECMAScript specification. It is primarily used in the context of regular expressions that involve Unicode property escapes, providing a way to ensure that input strings conform to expected Unicode property values.
Matching Unicode Property Values
This feature allows you to match a given Unicode property (e.g., 'Script') and value (e.g., 'Hani') to check if it conforms to the ECMAScript specification. It's useful for validating and transforming Unicode property values in JavaScript regular expressions.
"use strict";
const matchPropertyValue = require('unicode-match-property-value-ecmascript');
try {
const result = matchPropertyValue('Script', 'Hani');
console.log(result); // Expected output: 'Han'
} catch (error) {
console.error(error);
}
regexpu-core is a package that transforms Unicode-aware regular expressions into equivalent ES5-compatible versions. While it focuses on transforming regular expressions, unicode-match-property-value-ecmascript specifically matches property values according to the ECMAScript specification. Both packages are useful for dealing with Unicode in JavaScript regular expressions, but they serve slightly different purposes.
unicode-property-aliases-ecmascript provides the aliases of Unicode property names and values as per the ECMAScript specification. It complements unicode-match-property-value-ecmascript by offering the aliases for property names and values, whereas unicode-match-property-value-ecmascript focuses on matching the property values themselves. Together, they can be used to enhance handling of Unicode properties in JavaScript.
unicode-match-property-value-ecmascript matches a given Unicode property value or property value alias to its canonical property value without applying loose matching, per the algorithm used for RegExp Unicode property escapes in ECMAScript. Consider it a strict alternative to loose matching.
To use unicode-match-property-value-ecmascript programmatically, install it as a dependency via npm:
$ npm install unicode-match-property-value-ecmascript
Then, require
it:
const matchPropertyValue = require('unicode-match-property-value-ecmascript');
This module exports a single function named matchPropertyValue
.
matchPropertyValue(property, value)
This function takes a string property
that is a canonical/unaliased Unicode property name, and a string value
. It attemps to match value
to a canonical Unicode property value for the given property. If there’s a match, it returns the canonical property value. Otherwise, it throws an exception.
// Find the canonical property value:
matchPropertyValue('Script_Extensions', 'Aghb')
// → 'Caucasian_Albanian'
matchPropertyValue('Script_Extensions', 'Caucasian_Albanian')
// → 'Caucasian_Albanian'
matchPropertyValue('script_extensions', 'Caucasian_Albanian') // Note: incorrect casing.
// → throws
matchPropertyValue('Script_Extensions', 'caucasian_albanian') // Note: incorrect casing.
// → throws
On the main
branch, bump the version number in package.json
:
npm version patch -m 'Release v%s'
Instead of patch
, use minor
or major
as needed.
Note that this produces a Git commit + tag.
Push the release commit and tag:
git push && git push --tags
Our CI then automatically publishes the new release to npm.
Mathias Bynens |
unicode-match-property-value-ecmascript is available under the MIT license.
FAQs
Match a Unicode property or property alias to its canonical property name per the algorithm used for RegExp Unicode property escapes in ECMAScript.
We found that unicode-match-property-value-ecmascript demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.