File: README.md

package info (click to toggle)
node-unicode-loose-match 2.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 192 kB
  • sloc: makefile: 24; sh: 7
file content (49 lines) | stat: -rw-r--r-- 2,054 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# unicode-loose-match [![Build status](https://travis-ci.org/mathiasbynens/unicode-loose-match.svg?branch=master)](https://travis-ci.org/mathiasbynens/unicode-loose-match)

unicode-loose-match is a JavaScript implementation of [UAX44-LM3](http://unicode.org/reports/tr44/tr44-16.html#Matching_Symbolic), i.e. the loose matching algorithm for symbolic values as defined in the Unicode Standard.

It’s based on [the data for Unicode v11.0.0](https://github.com/mathiasbynens/unicode-11.0.0) and recognizes [property aliases](https://github.com/mathiasbynens/unicode-property-aliases) and [property value aliases](https://github.com/mathiasbynens/unicode-property-value-aliases).

## Installation

To use _unicode-loose-match_ programmatically, install it as a dependency via [npm](https://www.npmjs.com/):

```bash
$ npm install unicode-loose-match
```

Then, `require` it:

```js
const matchLoosely = require('unicode-loose-match');
```

## API

This module exports a single function named `matchLoosely`.

### `matchLoosely(propertyInput, [valueInput])`

This function takes two strings `propertyInput` and `valueInput` and applies loose matching on the property-value pair within the list of all Unicode property values. `valueInput` is optional.

The return value is an object containing containing the canonical property name `property` and the canonical property value name `value`. If an unknown `propertyInput` is given, an exception is thrown.

```js
// Find the canonical property name and property value name:
matchLoosely('blk', 'Arabic_PF_B')
// → { 'property': 'Block', 'value': 'Arabic_Presentation_Forms_B' }

// Find the canonical property name:
matchLoosely('compex')
// → { 'property': 'Full_Composition_Exclusion' }
```

## 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-loose-match_ is available under the [MIT](https://mths.be/mit) license.