forked from xorgy/grapheme-iterator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GraphemeBreakProperty.js
15 lines (13 loc) · 8.7 KB
/
GraphemeBreakProperty.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// Generated by prep.js
const GraphemeBreakProperty = JSON.parse("[[1,5,[1536,72324]],[1,0,[1757,1807,2274,3406,69821,69837,71999,72001,72250,73030]],[1,1,[70082]],[2,0,[13]],[3,0,[10]],[4,9,[0,8294]],[4,1,[11,8206]],[4,17,[14]],[4,32,[127]],[4,0,[173,1564,6158,8203,8232,8233,8293,65279,917504,917505]],[4,4,[8234,8288]],[4,8,[65520,78896]],[4,2,[65529]],[4,3,[113824]],[4,7,[119155]],[4,29,[917506]],[4,127,[917632]],[4,3599,[918000]],[5,111,[768]],[5,4,[1155,2089,2753,3968,6966,7675,66422,69927,70512,71463,92912,119150,121499,122918,127995]],[5,1,[1160,1473,1476,1767,2402,2530,2561,2625,2631,2672,2689,2759,2786,2901,2914,3157,3170,3276,3285,3298,3328,3387,3426,3864,3974,4153,4157,4184,4229,5970,6002,6068,6277,6439,6679,6847,7040,7080,7144,7222,7416,12334,12441,42654,42736,43045,43204,43452,43569,43573,43703,43710,43756,65438,68101,68325,69291,69817,70016,70198,70400,70459,70847,70850,71100,71103,71132,71231,71737,71995,72154,72344,72882,72885,73020,73104,73459,113821,122915]],[5,44,[1425]],[5,0,[1471,1479,1648,1809,2045,2362,2364,2381,2433,2492,2494,2509,2519,2558,2620,2641,2677,2748,2765,2817,2876,2878,2879,2893,2903,2946,3006,3008,3021,3031,3072,3076,3201,3260,3263,3266,3270,3390,3405,3415,3457,3530,3535,3542,3551,3633,3761,3893,3895,3897,4038,4226,4237,4253,6086,6109,6313,6450,6683,6742,6752,6754,6783,6846,6964,6965,6972,6978,7142,7149,7405,7412,8204,8417,11647,42607,43010,43014,43019,43052,43263,43443,43493,43587,43596,43644,43696,43713,43766,44005,44008,44013,64286,66045,66272,68159,69633,70003,70095,70196,70206,70367,70462,70464,70487,70726,70750,70832,70842,70845,71087,71229,71339,71341,71351,71984,71998,72003,72160,72263,72767,73018,73031,73109,73111,94031,94180,119141,121461,121476]],[5,10,[1552,1958,3981,6089,43335,69446]],[5,20,[1611]],[5,6,[1750,2385,3636,6071,6744,7394,70502,72752,72874,73023,92976,119173,122880,122907,123184,125136,125252]],[5,5,[1759,2810,3784,4146,43561,70835,71344,72243,72273,72760,73009]],[5,3,[1770,2070,2497,2881,3146,3393,4141,4209,6912,7074,8413,12330,43446,68108,68900,69811,70089,71090,71458,72148,72251,94095,119210,123628]],[5,26,[1840]],[5,8,[2027,2075,3764,7019,70070,71727]],[5,2,[2085,2137,2635,3134,3142,3538,4190,4957,5906,5938,6155,6432,6457,7083,7151,7376,8418,11503,42608,43392,43698,68097,68152,69759,69888,70191,70722,71453,72281,119143,119362]],[5,14,[2259,69688,121505]],[5,31,[2275,11744]],[5,7,[2369,3655,6757,7212,43302,69933,70371,70712,71219,119163]],[5,13,[3953,6832]],[5,35,[3993]],[5,9,[6771,42612,72193]],[5,12,[7380,8400,72330]],[5,57,[7616]],[5,11,[8421]],[5,17,[43232]],[5,15,[65024,65056]],[5,21,[72850]],[5,54,[121344]],[5,49,[121403]],[5,16,[122888]],[5,95,[917536]],[5,239,[917760]],[6,25,[127462]],[7,0,[2307,2363,2563,2691,2761,2880,3007,3262,3635,3763,3967,4145,4228,6070,6741,6743,6916,6971,7042,7073,7082,7143,7150,7393,7415,43047,43395,43597,43755,43765,44012,69632,69634,69762,69932,70018,70094,70197,70463,70725,70841,70846,70849,71102,71230,71340,71350,71462,71736,71997,72000,72002,72164,72249,72343,72751,72766,72873,72881,72884,73110,119142,119149]],[7,2,[2366,2622,2750,3014,3018,3073,3398,3402,6441,7146,43454,69808,70067,70188,70368,70475,70709,71216,71724,72145]],[7,3,[2377,3137,6435,70465,71096,72156]],[7,1,[2382,2434,2495,2503,2507,2763,2818,2887,2891,3009,3202,3264,3267,3271,3274,3330,3391,3458,3536,3570,3902,4155,4182,6087,6448,6681,6979,7078,7154,7220,43043,43136,43346,43444,43450,43567,43571,43758,44003,44006,44009,69815,69957,70079,70194,70402,70471,70498,70720,70833,70843,71088,71227,71342,71456,71991,72279,73107,73461,94192]],[7,6,[3544]],[7,7,[6078,7204]],[7,5,[6451,6765]],[7,4,[6973,71985,73098]],[7,15,[43188]],[7,54,[94033]],[8,95,[4352]],[8,28,[43360]],[9,71,[4448]],[9,22,[55216]],[10,87,[4520]],[10,48,[55243]],[11,0,[44032,44060,44088,44116,44144,44172,44200,44228,44256,44284,44312,44340,44368,44396,44424,44452,44480,44508,44536,44564,44592,44620,44648,44676,44704,44732,44760,44788,44816,44844,44872,44900,44928,44956,44984,45012,45040,45068,45096,45124,45152,45180,45208,45236,45264,45292,45320,45348,45376,45404,45432,45460,45488,45516,45544,45572,45600,45628,45656,45684,45712,45740,45768,45796,45824,45852,45880,45908,45936,45964,45992,46020,46048,46076,46104,46132,46160,46188,46216,46244,46272,46300,46328,46356,46384,46412,46440,46468,46496,46524,46552,46580,46608,46636,46664,46692,46720,46748,46776,46804,46832,46860,46888,46916,46944,46972,47000,47028,47056,47084,47112,47140,47168,47196,47224,47252,47280,47308,47336,47364,47392,47420,47448,47476,47504,47532,47560,47588,47616,47644,47672,47700,47728,47756,47784,47812,47840,47868,47896,47924,47952,47980,48008,48036,48064,48092,48120,48148,48176,48204,48232,48260,48288,48316,48344,48372,48400,48428,48456,48484,48512,48540,48568,48596,48624,48652,48680,48708,48736,48764,48792,48820,48848,48876,48904,48932,48960,48988,49016,49044,49072,49100,49128,49156,49184,49212,49240,49268,49296,49324,49352,49380,49408,49436,49464,49492,49520,49548,49576,49604,49632,49660,49688,49716,49744,49772,49800,49828,49856,49884,49912,49940,49968,49996,50024,50052,50080,50108,50136,50164,50192,50220,50248,50276,50304,50332,50360,50388,50416,50444,50472,50500,50528,50556,50584,50612,50640,50668,50696,50724,50752,50780,50808,50836,50864,50892,50920,50948,50976,51004,51032,51060,51088,51116,51144,51172,51200,51228,51256,51284,51312,51340,51368,51396,51424,51452,51480,51508,51536,51564,51592,51620,51648,51676,51704,51732,51760,51788,51816,51844,51872,51900,51928,51956,51984,52012,52040,52068,52096,52124,52152,52180,52208,52236,52264,52292,52320,52348,52376,52404,52432,52460,52488,52516,52544,52572,52600,52628,52656,52684,52712,52740,52768,52796,52824,52852,52880,52908,52936,52964,52992,53020,53048,53076,53104,53132,53160,53188,53216,53244,53272,53300,53328,53356,53384,53412,53440,53468,53496,53524,53552,53580,53608,53636,53664,53692,53720,53748,53776,53804,53832,53860,53888,53916,53944,53972,54000,54028,54056,54084,54112,54140,54168,54196,54224,54252,54280,54308,54336,54364,54392,54420,54448,54476,54504,54532,54560,54588,54616,54644,54672,54700,54728,54756,54784,54812,54840,54868,54896,54924,54952,54980,55008,55036,55064,55092,55120,55148,55176]],[12,26,[44033,44061,44089,44117,44145,44173,44201,44229,44257,44285,44313,44341,44369,44397,44425,44453,44481,44509,44537,44565,44593,44621,44649,44677,44705,44733,44761,44789,44817,44845,44873,44901,44929,44957,44985,45013,45041,45069,45097,45125,45153,45181,45209,45237,45265,45293,45321,45349,45377,45405,45433,45461,45489,45517,45545,45573,45601,45629,45657,45685,45713,45741,45769,45797,45825,45853,45881,45909,45937,45965,45993,46021,46049,46077,46105,46133,46161,46189,46217,46245,46273,46301,46329,46357,46385,46413,46441,46469,46497,46525,46553,46581,46609,46637,46665,46693,46721,46749,46777,46805,46833,46861,46889,46917,46945,46973,47001,47029,47057,47085,47113,47141,47169,47197,47225,47253,47281,47309,47337,47365,47393,47421,47449,47477,47505,47533,47561,47589,47617,47645,47673,47701,47729,47757,47785,47813,47841,47869,47897,47925,47953,47981,48009,48037,48065,48093,48121,48149,48177,48205,48233,48261,48289,48317,48345,48373,48401,48429,48457,48485,48513,48541,48569,48597,48625,48653,48681,48709,48737,48765,48793,48821,48849,48877,48905,48933,48961,48989,49017,49045,49073,49101,49129,49157,49185,49213,49241,49269,49297,49325,49353,49381,49409,49437,49465,49493,49521,49549,49577,49605,49633,49661,49689,49717,49745,49773,49801,49829,49857,49885,49913,49941,49969,49997,50025,50053,50081,50109,50137,50165,50193,50221,50249,50277,50305,50333,50361,50389,50417,50445,50473,50501,50529,50557,50585,50613,50641,50669,50697,50725,50753,50781,50809,50837,50865,50893,50921,50949,50977,51005,51033,51061,51089,51117,51145,51173,51201,51229,51257,51285,51313,51341,51369,51397,51425,51453,51481,51509,51537,51565,51593,51621,51649,51677,51705,51733,51761,51789,51817,51845,51873,51901,51929,51957,51985,52013,52041,52069,52097,52125,52153,52181,52209,52237,52265,52293,52321,52349,52377,52405,52433,52461,52489,52517,52545,52573,52601,52629,52657,52685,52713,52741,52769,52797,52825,52853,52881,52909,52937,52965,52993,53021,53049,53077,53105,53133,53161,53189,53217,53245,53273,53301,53329,53357,53385,53413,53441,53469,53497,53525,53553,53581,53609,53637,53665,53693,53721,53749,53777,53805,53833,53861,53889,53917,53945,53973,54001,54029,54057,54085,54113,54141,54169,54197,54225,54253,54281,54309,54337,54365,54393,54421,54449,54477,54505,54533,54561,54589,54617,54645,54673,54701,54729,54757,54785,54813,54841,54869,54897,54925,54953,54981,55009,55037,55065,55093,55121,55149,55177]],[13,0,[8205]]]");
const lut = new Uint8Array(460800);
for (const [p, s, bs] of GraphemeBreakProperty)
for (const b of bs)
for (let c = b; c <= (b + s); c++)
lut[c >> 1] |= ((c & 1) ? p << 4 : p);
export const classify = c => {
const v = lut[c >> 1];
if (!v) return 0;
else if (c & 1) return v >> 4;
else return v & 0xF;
}