forked from foliojs/unicode-properties
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunicode-properties.cjs.js.map
1 lines (1 loc) · 9.69 KB
/
unicode-properties.cjs.js.map
1
{"version":3,"file":"unicode-properties.cjs.js","sources":["index.js","node.js"],"sourcesContent":["const log2 = Math.log2 || (n => Math.log(n) / Math.LN2);\nconst bits = (n) => ((log2(n) + 1) | 0);\n\nconst buildUnicodeProperties = (data, trie) => {\n // compute the number of bits stored for each field\n const CATEGORY_BITS = bits(data.categories.length - 1);\n const COMBINING_BITS = bits(data.combiningClasses.length - 1);\n const SCRIPT_BITS = bits(data.scripts.length - 1);\n const EAW_BITS = bits(data.eaw.length - 1);\n const NUMBER_BITS = 10;\n\n // compute shift and mask values for each field\n const CATEGORY_SHIFT = COMBINING_BITS + SCRIPT_BITS + EAW_BITS + NUMBER_BITS;\n const COMBINING_SHIFT = SCRIPT_BITS + EAW_BITS + NUMBER_BITS;\n const SCRIPT_SHIFT = EAW_BITS + NUMBER_BITS;\n const EAW_SHIFT = NUMBER_BITS;\n const CATEGORY_MASK = (1 << CATEGORY_BITS) - 1;\n const COMBINING_MASK = (1 << COMBINING_BITS) - 1;\n const SCRIPT_MASK = (1 << SCRIPT_BITS) - 1;\n const EAW_MASK = (1 << EAW_BITS) - 1;\n const NUMBER_MASK = (1 << NUMBER_BITS) - 1;\n\n const getCategory = (codePoint) => {\n const val = trie.get(codePoint);\n return data.categories[(val >> CATEGORY_SHIFT) & CATEGORY_MASK];\n };\n\n const getCombiningClass = (codePoint) => {\n const val = trie.get(codePoint);\n return data.combiningClasses[(val >> COMBINING_SHIFT) & COMBINING_MASK];\n };\n\n const getScript = (codePoint) => {\n const val = trie.get(codePoint);\n return data.scripts[(val >> SCRIPT_SHIFT) & SCRIPT_MASK];\n };\n\n const getEastAsianWidth = (codePoint) => {\n const val = trie.get(codePoint);\n return data.eaw[(val >> EAW_SHIFT) & EAW_MASK];\n };\n\n const getNumericValue = (codePoint) => {\n let val = trie.get(codePoint);\n let num = val & NUMBER_MASK;\n\n if (num === 0) {\n return null;\n } else if (num <= 50) {\n return num - 1;\n } else if (num < 0x1e0) {\n const numerator = (num >> 4) - 12;\n const denominator = (num & 0xf) + 1;\n return numerator / denominator;\n } else if (num < 0x300) {\n val = (num >> 5) - 14;\n let exp = (num & 0x1f) + 2;\n\n while (exp > 0) {\n val *= 10;\n exp--;\n }\n return val;\n } else {\n val = (num >> 2) - 0xbf;\n let exp = (num & 3) + 1;\n while (exp > 0) {\n val *= 60;\n exp--;\n }\n return val;\n }\n };\n\n const isAlphabetic = (codePoint) => {\n const category = getCategory(codePoint);\n return (\n category === 'Lu' ||\n category === 'Ll' ||\n category === 'Lt' ||\n category === 'Lm' ||\n category === 'Lo' ||\n category === 'Nl'\n )\n };\n\n const isDigit = (codePoint) => (\n getCategory(codePoint) === 'Nd'\n );\n\n const isPunctuation = (codePoint) => {\n const category = getCategory(codePoint);\n return (\n category === 'Pc' ||\n category === 'Pd' ||\n category === 'Pe' ||\n category === 'Pf' ||\n category === 'Pi' ||\n category === 'Po' ||\n category === 'Ps'\n );\n };\n\n const isLowerCase = (codePoint) => {\n return getCategory(codePoint) === 'Ll';\n };\n\n const isUpperCase = (codePoint) => (\n getCategory(codePoint) === 'Lu'\n );\n\n const isTitleCase = (codePoint) => (\n getCategory(codePoint) === 'Lt'\n );\n\n const isWhiteSpace = (codePoint) => {\n const category = getCategory(codePoint);\n return (\n category === 'Zs' ||\n category === 'Zl' ||\n category === 'Zp'\n );\n };\n\n const isBaseForm = (codePoint) => {\n const category = getCategory(codePoint);\n return (\n category === 'Nd' ||\n category === 'No' ||\n category === 'Nl' ||\n category === 'Lu' ||\n category === 'Ll' ||\n category === 'Lt' ||\n category === 'Lm' ||\n category === 'Lo' ||\n category === 'Me' ||\n category === 'Mc'\n )\n };\n\n const isMark = (codePoint) => {\n const category = getCategory(codePoint);\n return (\n category === 'Mn' ||\n category === 'Me' ||\n category === 'Mc'\n );\n };\n\n return {\n getCategory,\n getCombiningClass,\n getScript,\n getEastAsianWidth,\n getNumericValue,\n isAlphabetic,\n isDigit,\n isPunctuation,\n isLowerCase,\n isUpperCase,\n isTitleCase,\n isWhiteSpace,\n isBaseForm,\n isMark\n }\n}\n\nexport default buildUnicodeProperties;\n","import fs from 'fs';\nimport UnicodeTrie from 'unicode-trie';\nimport data from './data.json';\nimport buildUnicodeProperties from './index';\n\nconst trie = new UnicodeTrie(fs.readFileSync(__dirname + '/data.trie'));\nconst unicodeProperties = buildUnicodeProperties(data, trie);\n\nexport default unicodeProperties;\n"],"names":["log2","Math","n","log","LN2","bits","buildUnicodeProperties","data","trie","CATEGORY_BITS","categories","length","COMBINING_BITS","combiningClasses","SCRIPT_BITS","scripts","EAW_BITS","eaw","NUMBER_BITS","CATEGORY_SHIFT","COMBINING_SHIFT","SCRIPT_SHIFT","EAW_SHIFT","CATEGORY_MASK","COMBINING_MASK","SCRIPT_MASK","EAW_MASK","NUMBER_MASK","getCategory","codePoint","val","get","getCombiningClass","getScript","getEastAsianWidth","getNumericValue","num","numerator","denominator","exp","isAlphabetic","category","isDigit","isPunctuation","isLowerCase","isUpperCase","isTitleCase","isWhiteSpace","isBaseForm","isMark","UnicodeTrie","fs","readFileSync","__dirname","unicodeProperties"],"mappings":";;;;;;;AAAA,IAAMA,IAAI,GAAGC,IAAI,CAACD,IAAL,KAAcE,CAAC,IAAID,IAAI,CAACE,GAAL,CAASD,CAAT,IAAcD,IAAI,CAACG,GAAtC,CAAb;;AACA,IAAMC,IAAI,GAAIH,CAAD,IAASF,IAAI,CAACE,CAAD,CAAJ,GAAU,CAAX,GAAgB,CAArC;;AAEA,IAAMI,sBAAsB,GAAG,CAACC,IAAD,EAAOC,IAAP,KAAgB;AAC7C;AACA,MAAMC,aAAa,GAAGJ,IAAI,CAACE,IAAI,CAACG,UAAL,CAAgBC,MAAhB,GAAyB,CAA1B,CAA1B;AACA,MAAMC,cAAc,GAAGP,IAAI,CAACE,IAAI,CAACM,gBAAL,CAAsBF,M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