[backend] fix: 修复异常处理和类型转换问题

This commit is contained in:
xsl
2026-01-26 11:53:40 +08:00
parent 7ccc2a6ac6
commit 83e05bf85f
28639 changed files with 2506458 additions and 93 deletions
+30
View File
@@ -0,0 +1,30 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [1.3.0] - 2021-12-13
### Added
- Updated to include support for Unicode 14
## [1.2.0] - 2021-01-29
### Updated
- Refactored to increase speed
## [1.1.0] - 2020-09-14
### Added
- Updated to include support for Unicode 13
## [1.0.0] - 2020-09-13
- Forked from work by @JLHwung on original `Grapheme-Splitter` library: https://github.com/JLHwung/grapheme-splitter/tree/next
- Converted to Typescript
- Added development and build tooling
+132
View File
@@ -0,0 +1,132 @@
# Graphemer: Unicode Character Splitter 🪓
## Introduction
This library continues the work of [Grapheme Splitter](https://github.com/orling/grapheme-splitter) and supports the following unicode versions:
- Unicode 15 and below `[v1.4.0]`
- Unicode 14 and below `[v1.3.0]`
- Unicode 13 and below `[v1.1.0]`
- Unicode 11 and below `[v1.0.0]` (Unicode 10 supported by `grapheme-splitter`)
In JavaScript there is not always a one-to-one relationship between string characters and what a user would call a separate visual "letter". Some symbols are represented by several characters. This can cause issues when splitting strings and inadvertently cutting a multi-char letter in half, or when you need the actual number of letters in a string.
For example, emoji characters like "🌷","🎁","💩","😜" and "👍" are represented by two JavaScript characters each (high surrogate and low surrogate). That is,
```javascript
'🌷'.length == 2;
```
The combined emoji are even longer:
```javascript
'🏳️‍🌈'.length == 6;
```
What's more, some languages often include combining marks - characters that are used to modify the letters before them. Common examples are the German letter ü and the Spanish letter ñ. Sometimes they can be represented alternatively both as a single character and as a letter + combining mark, with both forms equally valid:
```javascript
var two = 'ñ'; // unnormalized two-char n+◌̃, i.e. "\u006E\u0303";
var one = 'ñ'; // normalized single-char, i.e. "\u00F1"
console.log(one != two); // prints 'true'
```
Unicode normalization, as performed by the popular punycode.js library or ECMAScript 6's String.normalize, can **sometimes** fix those differences and turn two-char sequences into single characters. But it is **not** enough in all cases. Some languages like Hindi make extensive use of combining marks on their letters, that have no dedicated single-codepoint Unicode sequences, due to the sheer number of possible combinations.
For example, the Hindi word "अनुच्छेद" is comprised of 5 letters and 3 combining marks:
अ + न + ु + च + ् + छ + े + द
which is in fact just 5 user-perceived letters:
अ + नु + च् + छे + द
and which Unicode normalization would not combine properly.
There are also the unusual letter+combining mark combinations which have no dedicated Unicode codepoint. The string Z͑ͫ̓ͪ̂ͫ̽͏̴̙̤̞͉͚̯̞̠͍A̴̵̜̰͔ͫ͗͢L̠ͨͧͩ͘G̴̻͈͍͔̹̑͗̎̅͛́Ǫ̵̹̻̝̳͂̌̌͘ obviously has 5 separate letters, but is in fact comprised of 58 JavaScript characters, most of which are combining marks.
Enter the `graphemer` library. It can be used to properly split JavaScript strings into what a human user would call separate letters (or "extended grapheme clusters" in Unicode terminology), no matter what their internal representation is. It is an implementation on the [Default Grapheme Cluster Boundary](http://unicode.org/reports/tr29/#Default_Grapheme_Cluster_Table) of [UAX #29](http://www.unicode.org/reports/tr29/).
## Installation
Install `graphemer` using the NPM command below:
```
$ npm i graphemer
```
## Usage
If you're using [Typescript](https://www.typescriptlang.org/) or a compiler like [Babel](https://babeljs.io/) (or something like Create React App) things are pretty simple; just import, initialize and use!
```javascript
import Graphemer from 'graphemer';
const splitter = new Graphemer();
// split the string to an array of grapheme clusters (one string each)
const graphemes = splitter.splitGraphemes(string);
// iterate the string to an iterable iterator of grapheme clusters (one string each)
const graphemeIterator = splitter.iterateGraphemes(string);
// or do this if you just need their number
const graphemeCount = splitter.countGraphemes(string);
```
If you're using vanilla Node you can use the `require()` method.
```javascript
const Graphemer = require('graphemer').default;
const splitter = new Graphemer();
const graphemes = splitter.splitGraphemes(string);
```
## Examples
```javascript
import Graphemer from 'graphemer';
const splitter = new Graphemer();
// plain latin alphabet - nothing spectacular
splitter.splitGraphemes('abcd'); // returns ["a", "b", "c", "d"]
// two-char emojis and six-char combined emoji
splitter.splitGraphemes('🌷🎁💩😜👍🏳️‍🌈'); // returns ["🌷","🎁","💩","😜","👍","🏳️‍🌈"]
// diacritics as combining marks, 10 JavaScript chars
splitter.splitGraphemes('Ĺo͂řȩm̅'); // returns ["Ĺ","o͂","ř","ȩ","m̅"]
// individual Korean characters (Jamo), 4 JavaScript chars
splitter.splitGraphemes('뎌쉐'); // returns ["뎌","쉐"]
// Hindi text with combining marks, 8 JavaScript chars
splitter.splitGraphemes('अनुच्छेद'); // returns ["अ","नु","च्","छे","द"]
// demonic multiple combining marks, 75 JavaScript chars
splitter.splitGraphemes('Z͑ͫ̓ͪ̂ͫ̽͏̴̙̤̞͉͚̯̞̠͍A̴̵̜̰͔ͫ͗͢L̠ͨͧͩ͘G̴̻͈͍͔̹̑͗̎̅͛́Ǫ̵̹̻̝̳͂̌̌͘!͖̬̰̙̗̿̋ͥͥ̂ͣ̐́́͜͞'); // returns ["Z͑ͫ̓ͪ̂ͫ̽͏̴̙̤̞͉͚̯̞̠͍","A̴̵̜̰͔ͫ͗͢","L̠ͨͧͩ͘","G̴̻͈͍͔̹̑͗̎̅͛́","Ǫ̵̹̻̝̳͂̌̌͘","!͖̬̰̙̗̿̋ͥͥ̂ͣ̐́́͜͞"]
```
## TypeScript
Graphemer is built with TypeScript and, of course, includes type declarations.
```javascript
import Graphemer from 'graphemer';
const splitter = new Graphemer();
const split: string[] = splitter.splitGraphemes('Z͑ͫ̓ͪ̂ͫ̽͏̴̙̤̞͉͚̯̞̠͍A̴̵̜̰͔ͫ͗͢L̠ͨͧͩ͘G̴̻͈͍͔̹̑͗̎̅͛́Ǫ̵̹̻̝̳͂̌̌͘!͖̬̰̙̗̿̋ͥͥ̂ͣ̐́́͜͞');
```
## Contributing
See [Contribution Guide](./CONTRIBUTING.md).
## Acknowledgements
This library is a fork of the incredible work done by Orlin Georgiev and Huáng Jùnliàng at https://github.com/orling/grapheme-splitter.
The original library was heavily influenced by Devon Govett's excellent [grapheme-breaker](https://github.com/devongovett/grapheme-breaker) CoffeeScript library.
+41
View File
@@ -0,0 +1,41 @@
import GraphemerIterator from './GraphemerIterator';
export default class Graphemer {
/**
* Returns the next grapheme break in the string after the given index
* @param string {string}
* @param index {number}
* @returns {number}
*/
static nextBreak(string: string, index: number): number;
/**
* Breaks the given string into an array of grapheme clusters
* @param str {string}
* @returns {string[]}
*/
splitGraphemes(str: string): string[];
/**
* Returns an iterator of grapheme clusters in the given string
* @param str {string}
* @returns {GraphemerIterator}
*/
iterateGraphemes(str: string): GraphemerIterator;
/**
* Returns the number of grapheme clusters in the given string
* @param str {string}
* @returns {number}
*/
countGraphemes(str: string): number;
/**
* Given a Unicode code point, determines this symbol's grapheme break property
* @param code {number} Unicode code point
* @returns {number}
*/
static getGraphemeBreakProperty(code: number): number;
/**
* Given a Unicode code point, returns if symbol is an extended pictographic or some other break
* @param code {number} Unicode code point
* @returns {number}
*/
static getEmojiProperty(code: number): number;
}
//# sourceMappingURL=Graphemer.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"Graphemer.d.ts","sourceRoot":"","sources":["../src/Graphemer.ts"],"names":[],"mappings":"AAEA,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AAEpD,MAAM,CAAC,OAAO,OAAO,SAAS;IAC5B;;;;;OAKG;IACH,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;IA2CvD;;;;OAIG;IACH,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE;IAcrC;;;;OAIG;IACH,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB;IAIhD;;;;OAIG;IACH,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAcnC;;;;OAIG;IACH,MAAM,CAAC,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAoySrD;;;;OAIG;IACH,MAAM,CAAC,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CA47B9C"}
+11497 -1
View File
File diff suppressed because it is too large Load Diff
+32
View File
@@ -0,0 +1,32 @@
declare class GraphemerHelper {
/**
* Check if the the character at the position {pos} of the string is surrogate
* @param str {string}
* @param pos {number}
* @returns {boolean}
*/
static isSurrogate(str: string, pos: number): boolean;
/**
* The String.prototype.codePointAt polyfill
* Private function, gets a Unicode code point from a JavaScript UTF-16 string
* handling surrogate pairs appropriately
* @param str {string}
* @param idx {number}
* @returns {number}
*/
static codePointAt(str: string, idx: number): number;
/**
* Private function, returns whether a break is allowed between the two given grapheme breaking classes
* Implemented the UAX #29 3.1.1 Grapheme Cluster Boundary Rules on extended grapheme clusters
* @param start {number}
* @param mid {Array<number>}
* @param end {number}
* @param startEmoji {number}
* @param midEmoji {Array<number>}
* @param endEmoji {number}
* @returns {number}
*/
static shouldBreak(start: number, mid: number[], end: number, startEmoji: number, midEmoji: number[], endEmoji: number): number;
}
export default GraphemerHelper;
//# sourceMappingURL=GraphemerHelper.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"GraphemerHelper.d.ts","sourceRoot":"","sources":["../src/GraphemerHelper.ts"],"names":[],"mappings":"AAUA,cAAM,eAAe;IACnB;;;;;OAKG;IACH,MAAM,CAAC,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO;IASrD;;;;;;;OAOG;IACH,MAAM,CAAC,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM;IAgCpD;;;;;;;;;;OAUG;IACH,MAAM,CAAC,WAAW,CAChB,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,EAAE,EACb,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAAE,EAClB,QAAQ,EAAE,MAAM,GACf,MAAM;CAyHV;AAED,eAAe,eAAe,CAAC"}
+169
View File
@@ -0,0 +1,169 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const boundaries_1 = require("./boundaries");
// BreakTypes
// @type {BreakType}
const NotBreak = 0;
const BreakStart = 1;
const Break = 2;
const BreakLastRegional = 3;
const BreakPenultimateRegional = 4;
class GraphemerHelper {
/**
* Check if the the character at the position {pos} of the string is surrogate
* @param str {string}
* @param pos {number}
* @returns {boolean}
*/
static isSurrogate(str, pos) {
return (0xd800 <= str.charCodeAt(pos) &&
str.charCodeAt(pos) <= 0xdbff &&
0xdc00 <= str.charCodeAt(pos + 1) &&
str.charCodeAt(pos + 1) <= 0xdfff);
}
/**
* The String.prototype.codePointAt polyfill
* Private function, gets a Unicode code point from a JavaScript UTF-16 string
* handling surrogate pairs appropriately
* @param str {string}
* @param idx {number}
* @returns {number}
*/
static codePointAt(str, idx) {
if (idx === undefined) {
idx = 0;
}
const code = str.charCodeAt(idx);
// if a high surrogate
if (0xd800 <= code && code <= 0xdbff && idx < str.length - 1) {
const hi = code;
const low = str.charCodeAt(idx + 1);
if (0xdc00 <= low && low <= 0xdfff) {
return (hi - 0xd800) * 0x400 + (low - 0xdc00) + 0x10000;
}
return hi;
}
// if a low surrogate
if (0xdc00 <= code && code <= 0xdfff && idx >= 1) {
const hi = str.charCodeAt(idx - 1);
const low = code;
if (0xd800 <= hi && hi <= 0xdbff) {
return (hi - 0xd800) * 0x400 + (low - 0xdc00) + 0x10000;
}
return low;
}
// just return the char if an unmatched surrogate half or a
// single-char codepoint
return code;
}
//
/**
* Private function, returns whether a break is allowed between the two given grapheme breaking classes
* Implemented the UAX #29 3.1.1 Grapheme Cluster Boundary Rules on extended grapheme clusters
* @param start {number}
* @param mid {Array<number>}
* @param end {number}
* @param startEmoji {number}
* @param midEmoji {Array<number>}
* @param endEmoji {number}
* @returns {number}
*/
static shouldBreak(start, mid, end, startEmoji, midEmoji, endEmoji) {
const all = [start].concat(mid).concat([end]);
const allEmoji = [startEmoji].concat(midEmoji).concat([endEmoji]);
const previous = all[all.length - 2];
const next = end;
const nextEmoji = endEmoji;
// Lookahead terminator for:
// GB12. ^ (RI RI)* RI ? RI
// GB13. [^RI] (RI RI)* RI ? RI
const rIIndex = all.lastIndexOf(boundaries_1.CLUSTER_BREAK.REGIONAL_INDICATOR);
if (rIIndex > 0 &&
all.slice(1, rIIndex).every(function (c) {
return c === boundaries_1.CLUSTER_BREAK.REGIONAL_INDICATOR;
}) &&
[boundaries_1.CLUSTER_BREAK.PREPEND, boundaries_1.CLUSTER_BREAK.REGIONAL_INDICATOR].indexOf(previous) === -1) {
if (all.filter(function (c) {
return c === boundaries_1.CLUSTER_BREAK.REGIONAL_INDICATOR;
}).length %
2 ===
1) {
return BreakLastRegional;
}
else {
return BreakPenultimateRegional;
}
}
// GB3. CR × LF
if (previous === boundaries_1.CLUSTER_BREAK.CR && next === boundaries_1.CLUSTER_BREAK.LF) {
return NotBreak;
}
// GB4. (Control|CR|LF) ÷
else if (previous === boundaries_1.CLUSTER_BREAK.CONTROL ||
previous === boundaries_1.CLUSTER_BREAK.CR ||
previous === boundaries_1.CLUSTER_BREAK.LF) {
return BreakStart;
}
// GB5. ÷ (Control|CR|LF)
else if (next === boundaries_1.CLUSTER_BREAK.CONTROL ||
next === boundaries_1.CLUSTER_BREAK.CR ||
next === boundaries_1.CLUSTER_BREAK.LF) {
return BreakStart;
}
// GB6. L × (L|V|LV|LVT)
else if (previous === boundaries_1.CLUSTER_BREAK.L &&
(next === boundaries_1.CLUSTER_BREAK.L ||
next === boundaries_1.CLUSTER_BREAK.V ||
next === boundaries_1.CLUSTER_BREAK.LV ||
next === boundaries_1.CLUSTER_BREAK.LVT)) {
return NotBreak;
}
// GB7. (LV|V) × (V|T)
else if ((previous === boundaries_1.CLUSTER_BREAK.LV || previous === boundaries_1.CLUSTER_BREAK.V) &&
(next === boundaries_1.CLUSTER_BREAK.V || next === boundaries_1.CLUSTER_BREAK.T)) {
return NotBreak;
}
// GB8. (LVT|T) × (T)
else if ((previous === boundaries_1.CLUSTER_BREAK.LVT || previous === boundaries_1.CLUSTER_BREAK.T) &&
next === boundaries_1.CLUSTER_BREAK.T) {
return NotBreak;
}
// GB9. × (Extend|ZWJ)
else if (next === boundaries_1.CLUSTER_BREAK.EXTEND || next === boundaries_1.CLUSTER_BREAK.ZWJ) {
return NotBreak;
}
// GB9a. × SpacingMark
else if (next === boundaries_1.CLUSTER_BREAK.SPACINGMARK) {
return NotBreak;
}
// GB9b. Prepend ×
else if (previous === boundaries_1.CLUSTER_BREAK.PREPEND) {
return NotBreak;
}
// GB11. \p{Extended_Pictographic} Extend* ZWJ × \p{Extended_Pictographic}
const previousNonExtendIndex = allEmoji
.slice(0, -1)
.lastIndexOf(boundaries_1.EXTENDED_PICTOGRAPHIC);
if (previousNonExtendIndex !== -1 &&
allEmoji[previousNonExtendIndex] === boundaries_1.EXTENDED_PICTOGRAPHIC &&
all.slice(previousNonExtendIndex + 1, -2).every(function (c) {
return c === boundaries_1.CLUSTER_BREAK.EXTEND;
}) &&
previous === boundaries_1.CLUSTER_BREAK.ZWJ &&
nextEmoji === boundaries_1.EXTENDED_PICTOGRAPHIC) {
return NotBreak;
}
// GB12. ^ (RI RI)* RI × RI
// GB13. [^RI] (RI RI)* RI × RI
if (mid.indexOf(boundaries_1.CLUSTER_BREAK.REGIONAL_INDICATOR) !== -1) {
return Break;
}
if (previous === boundaries_1.CLUSTER_BREAK.REGIONAL_INDICATOR &&
next === boundaries_1.CLUSTER_BREAK.REGIONAL_INDICATOR) {
return NotBreak;
}
// GB999. Any ? Any
return BreakStart;
}
}
exports.default = GraphemerHelper;
+22
View File
@@ -0,0 +1,22 @@
/**
* GraphemerIterator
*
* Takes a string and a "BreakHandler" method during initialisation
* and creates an iterable object that returns individual graphemes.
*
* @param str {string}
* @return GraphemerIterator
*/
declare class GraphemerIterator implements Iterator<string> {
private _index;
private _str;
private _nextBreak;
constructor(str: string, nextBreak: (str: string, index: number) => number);
[Symbol.iterator](): this;
next(): {
value: string;
done: boolean;
};
}
export default GraphemerIterator;
//# sourceMappingURL=GraphemerIterator.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"GraphemerIterator.d.ts","sourceRoot":"","sources":["../src/GraphemerIterator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,cAAM,iBAAkB,YAAW,QAAQ,CAAC,MAAM,CAAC;IACjD,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,UAAU,CAAyC;gBAE/C,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM;IAK1E,CAAC,MAAM,CAAC,QAAQ,CAAC;IAIjB,IAAI;;;;CAcL;AAED,eAAe,iBAAiB,CAAC"}
+36
View File
@@ -0,0 +1,36 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* GraphemerIterator
*
* Takes a string and a "BreakHandler" method during initialisation
* and creates an iterable object that returns individual graphemes.
*
* @param str {string}
* @return GraphemerIterator
*/
class GraphemerIterator {
constructor(str, nextBreak) {
this._index = 0;
this._str = str;
this._nextBreak = nextBreak;
}
[Symbol.iterator]() {
return this;
}
next() {
let brk;
if ((brk = this._nextBreak(this._str, this._index)) < this._str.length) {
const value = this._str.slice(this._index, brk);
this._index = brk;
return { value: value, done: false };
}
if (this._index < this._str.length) {
const value = this._str.slice(this._index);
this._index = this._str.length;
return { value: value, done: false };
}
return { value: undefined, done: true };
}
}
exports.default = GraphemerIterator;
+35
View File
@@ -0,0 +1,35 @@
/**
* The Grapheme_Cluster_Break property value
* @see https://www.unicode.org/reports/tr29/#Default_Grapheme_Cluster_Table
*/
export declare enum CLUSTER_BREAK {
CR = 0,
LF = 1,
CONTROL = 2,
EXTEND = 3,
REGIONAL_INDICATOR = 4,
SPACINGMARK = 5,
L = 6,
V = 7,
T = 8,
LV = 9,
LVT = 10,
OTHER = 11,
PREPEND = 12,
E_BASE = 13,
E_MODIFIER = 14,
ZWJ = 15,
GLUE_AFTER_ZWJ = 16,
E_BASE_GAZ = 17
}
/**
* The Emoji character property is an extension of UCD but shares the same namespace and structure
* @see http://www.unicode.org/reports/tr51/tr51-14.html#Emoji_Properties_and_Data_Files
*
* Here we model Extended_Pictograhpic only to implement UAX #29 GB11
* \p{Extended_Pictographic} Extend* ZWJ × \p{Extended_Pictographic}
*
* The Emoji character property should not be mixed with Grapheme_Cluster_Break since they are not exclusive
*/
export declare const EXTENDED_PICTOGRAPHIC = 101;
//# sourceMappingURL=boundaries.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"boundaries.d.ts","sourceRoot":"","sources":["../src/boundaries.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,oBAAY,aAAa;IACvB,EAAE,IAAI;IACN,EAAE,IAAI;IACN,OAAO,IAAI;IACX,MAAM,IAAI;IACV,kBAAkB,IAAI;IACtB,WAAW,IAAI;IACf,CAAC,IAAI;IACL,CAAC,IAAI;IACL,CAAC,IAAI;IACL,EAAE,IAAI;IACN,GAAG,KAAK;IACR,KAAK,KAAK;IACV,OAAO,KAAK;IACZ,MAAM,KAAK;IACX,UAAU,KAAK;IACf,GAAG,KAAK;IACR,cAAc,KAAK;IACnB,UAAU,KAAK;CAChB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,MAAM,CAAC"}
+3
View File
@@ -0,0 +1,3 @@
import Graphemer from './Graphemer';
export default Graphemer;
//# sourceMappingURL=index.d.ts.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAC;AAEpC,eAAe,SAAS,CAAC"}
+7
View File
@@ -0,0 +1,7 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const Graphemer_1 = __importDefault(require("./Graphemer"));
exports.default = Graphemer_1.default;
+54
View File
@@ -0,0 +1,54 @@
{
"name": "graphemer",
"version": "1.4.0",
"description": "A JavaScript library that breaks strings into their individual user-perceived characters (including emojis!)",
"homepage": "https://github.com/flmnt/graphemer",
"author": "Matt Davies <matt@filament.so> (https://github.com/mattpauldavies)",
"contributors": [
"Orlin Georgiev (https://github.com/orling)",
"Huáng Jùnliàng (https://github.com/JLHwung)"
],
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
"files": [
"lib"
],
"license": "MIT",
"keywords": [
"utf-8",
"strings",
"emoji",
"split"
],
"scripts": {
"prepublishOnly": "npm run build",
"build": "tsc --project tsconfig.json",
"pretest": "npm run build",
"test": "ts-node node_modules/tape/bin/tape tests/**.ts",
"prettier:check": "prettier --check .",
"prettier:fix": "prettier --write ."
},
"repository": {
"type": "git",
"url": "https://github.com/flmnt/graphemer.git"
},
"bugs": "https://github.com/flmnt/graphemer/issues",
"devDependencies": {
"@types/tape": "^4.13.0",
"husky": "^4.3.0",
"lint-staged": "^10.3.0",
"prettier": "^2.1.1",
"tape": "^4.6.3",
"ts-node": "^9.0.0",
"typescript": "^4.0.2"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged",
"pre-push": "npm test"
}
},
"lint-staged": {
"*.{js,ts,md,json}": "prettier --write"
}
}