pax_global_header00006660000000000000000000000064141201027150014503gustar00rootroot0000000000000052 comment=53be375cfb78a107da07410a43bba52db8fae534 unicode-match-property-ecmascript-2.0.0/000077500000000000000000000000001412010271500202345ustar00rootroot00000000000000unicode-match-property-ecmascript-2.0.0/.editorconfig000066400000000000000000000003161412010271500227110ustar00rootroot00000000000000root = true [*] charset = utf-8 indent_style = tab end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true [{README.md,package.json,.travis.yml}] indent_style = space indent_size = 2 unicode-match-property-ecmascript-2.0.0/.gitattributes000066400000000000000000000000141412010271500231220ustar00rootroot00000000000000* text=auto unicode-match-property-ecmascript-2.0.0/.github/000077500000000000000000000000001412010271500215745ustar00rootroot00000000000000unicode-match-property-ecmascript-2.0.0/.github/workflows/000077500000000000000000000000001412010271500236315ustar00rootroot00000000000000unicode-match-property-ecmascript-2.0.0/.github/workflows/publish-on-tag.yml000066400000000000000000000010471412010271500272070ustar00rootroot00000000000000name: publish-on-tag on: push: tags: - '*' jobs: publish: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 - name: Install dependencies run: npm install - name: Test run: npm test - name: Publish env: NPM_TOKEN: ${{secrets.NPM_TOKEN}} run: | npm config set registry 'https://wombat-dressing-room.appspot.com/' npm config set '//wombat-dressing-room.appspot.com/:_authToken' '${NPM_TOKEN}' npm publish unicode-match-property-ecmascript-2.0.0/.gitignore000066400000000000000000000003351412010271500222250ustar00rootroot00000000000000# Installed npm modules node_modules package-lock.json # Folder view configuration files .DS_Store Desktop.ini # Thumbnail cache files ._* Thumbs.db # Files that might appear on external disks .Spotlight-V100 .Trashes unicode-match-property-ecmascript-2.0.0/.travis.yml000066400000000000000000000001131412010271500223400ustar00rootroot00000000000000language: node_js node_js: - '4' - '5' - '6' - '7' git: depth: 1 unicode-match-property-ecmascript-2.0.0/LICENSE-MIT.txt000066400000000000000000000020651412010271500225110ustar00rootroot00000000000000Copyright Mathias Bynens Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. unicode-match-property-ecmascript-2.0.0/README.md000066400000000000000000000046061412010271500215210ustar00rootroot00000000000000# unicode-match-property-ecmascript [![Build status](https://travis-ci.org/mathiasbynens/unicode-match-property-ecmascript.svg?branch=main)](https://travis-ci.org/mathiasbynens/unicode-match-property-ecmascript) [![unicode-match-property-ecmascript on npm](https://img.shields.io/npm/v/unicode-match-property-ecmascript)](https://www.npmjs.com/package/unicode-match-property-ecmascript) _unicode-match-property-ecmascript_ matches a given Unicode property or [property alias](https://github.com/mathiasbynens/unicode-property-aliases-ecmascript) to its canonical property name without applying [loose matching](https://github.com/mathiasbynens/unicode-loose-match) per the algorithm used for [RegExp Unicode property escapes in ECMAScript](https://github.com/tc39/proposal-regexp-unicode-property-escapes). Consider it a strict alternative to loose matching. ## Installation To use _unicode-match-property-ecmascript_ programmatically, install it as a dependency via [npm](https://www.npmjs.com/): ```bash $ npm install unicode-match-property-ecmascript ``` Then, `require` it: ```js const matchProperty = require('unicode-match-property-ecmascript'); ``` ## API This module exports a single function named `matchProperty`. ### `matchProperty(value)` This function takes a string `value` and attempts to match it to a canonical Unicode property name. If there’s a match, it returns the canonical property name. Otherwise, it throws an exception. ```js // Find the canonical property name: matchProperty('sc') // → 'Script' matchProperty('Script') // → 'Script' matchProperty('script') // Note: incorrect casing. // → throws ``` ## For maintainers ### How to publish a new release 1. On the `main` branch, bump the version number in `package.json`: ```sh npm version patch -m 'Release v%s' ``` Instead of `patch`, use `minor` or `major` [as needed](https://semver.org/). Note that this produces a Git commit + tag. 1. Push the release commit and tag: ```sh git push && git push --tags ``` Our CI then automatically publishes the new release to npm. ## Author | [![twitter/mathias](https://gravatar.com/avatar/24e08a9ea84deb17ae121074d0f17125?s=70)](https://twitter.com/mathias "Follow @mathias on Twitter") | |---| | [Mathias Bynens](https://mathiasbynens.be/) | ## License _unicode-match-property-ecmascript_ is available under the [MIT](https://mths.be/mit) license. unicode-match-property-ecmascript-2.0.0/index.js000077500000000000000000000007011412010271500217020ustar00rootroot00000000000000'use strict'; const canonicalProperties = require('unicode-canonical-property-names-ecmascript'); const propertyAliases = require('unicode-property-aliases-ecmascript'); const matchProperty = function(property) { if (canonicalProperties.has(property)) { return property; } if (propertyAliases.has(property)) { return propertyAliases.get(property); } throw new Error(`Unknown property: ${ property }`); }; module.exports = matchProperty; unicode-match-property-ecmascript-2.0.0/package.json000066400000000000000000000020731412010271500225240ustar00rootroot00000000000000{ "name": "unicode-match-property-ecmascript", "version": "2.0.0", "description": "Match a Unicode property or property alias to its canonical property name per the algorithm used for RegExp Unicode property escapes in ECMAScript.", "homepage": "https://github.com/mathiasbynens/unicode-match-property-ecmascript", "main": "index.js", "engines": { "node": ">=4" }, "files": [ "LICENSE-MIT.txt", "index.js" ], "keywords": [ "unicode", "unicode properties", "unicode property aliases" ], "license": "MIT", "author": { "name": "Mathias Bynens", "url": "https://mathiasbynens.be/" }, "repository": { "type": "git", "url": "https://github.com/mathiasbynens/unicode-match-property-ecmascript.git" }, "bugs": "https://github.com/mathiasbynens/unicode-match-property-ecmascript/issues", "dependencies": { "unicode-canonical-property-names-ecmascript": "^2.0.0", "unicode-property-aliases-ecmascript": "^2.0.0" }, "devDependencies": { "ava": "*" }, "scripts": { "test": "ava ./tests/*" } } unicode-match-property-ecmascript-2.0.0/tests/000077500000000000000000000000001412010271500213765ustar00rootroot00000000000000unicode-match-property-ecmascript-2.0.0/tests/tests.js000066400000000000000000000052551412010271500231050ustar00rootroot00000000000000const test = require('ava'); const matchProperty = require('../index.js'); test('unicode-match-property-ecmascript', t => { t.deepEqual( matchProperty('gc'), 'General_Category' ); t.deepEqual( matchProperty('General_Category'), 'General_Category' ); t.deepEqual( matchProperty('sc'), 'Script' ); t.deepEqual( matchProperty('Script'), 'Script' ); t.deepEqual( matchProperty('scx'), 'Script_Extensions' ); t.deepEqual( matchProperty('Script_Extensions'), 'Script_Extensions' ); t.throws( () => matchProperty('Script Extensions'), { instanceOf: Error }, ); t.deepEqual( matchProperty('ASCII'), 'ASCII' ); t.deepEqual( matchProperty('Any'), 'Any' ); t.deepEqual( matchProperty('Assigned'), 'Assigned' ); t.deepEqual( matchProperty('AHex'), 'ASCII_Hex_Digit' ); t.deepEqual( matchProperty('Emoji_Modifier'), 'Emoji_Modifier' ); t.throws( () => matchProperty('emojimodifier'), { instanceOf: Error }, ); t.deepEqual( matchProperty('Emoji_Component'), 'Emoji_Component' ); t.throws( () => matchProperty('emojicomponent'), { instanceOf: Error }, ); t.throws( () => matchProperty('Composition_Exclusion'), { instanceOf: Error }, ); t.throws( () => matchProperty('Expands_On_NFC'), { instanceOf: Error }, ); t.throws( () => matchProperty('Expands_On_NFD'), { instanceOf: Error }, ); t.throws( () => matchProperty('Expands_On_NFKC'), { instanceOf: Error }, ); t.throws( () => matchProperty('Expands_On_NFKD'), { instanceOf: Error }, ); t.throws( () => matchProperty('FC_NFKC_Closure'), { instanceOf: Error }, ); t.throws( () => matchProperty('Full_Composition_Exclusion'), { instanceOf: Error }, ); t.throws( () => matchProperty('Grapheme_Link'), { instanceOf: Error }, ); t.throws( () => matchProperty('Hyphen'), { instanceOf: Error }, ); t.throws( () => matchProperty('Other_Alphabetic'), { instanceOf: Error }, ); t.throws( () => matchProperty('Other_Default_Ignorable_Code_Point'), { instanceOf: Error }, ); t.throws( () => matchProperty('Other_Grapheme_Extend'), { instanceOf: Error }, ); t.throws( () => matchProperty('Other_ID_Continue'), { instanceOf: Error }, ); t.throws( () => matchProperty('Other_ID_Start'), { instanceOf: Error }, ); t.throws( () => matchProperty('Other_Lowercase'), { instanceOf: Error }, ); t.throws( () => matchProperty('Other_Math'), { instanceOf: Error }, ); t.throws( () => matchProperty('Other_Uppercase'), { instanceOf: Error }, ); t.throws( () => matchProperty('Prepended_Concatenation_Mark'), { instanceOf: Error }, ); t.throws( () => matchProperty('unknown property'), { instanceOf: Error }, ); });