regenerate-unicode-properties-5.1.3/000077500000000000000000000000001317314715300174645ustar00rootroot00000000000000regenerate-unicode-properties-5.1.3/.editorconfig000066400000000000000000000003161317314715300221410ustar00rootroot00000000000000root = 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 regenerate-unicode-properties-5.1.3/.gitattributes000066400000000000000000000000141317314715300223520ustar00rootroot00000000000000* text=auto regenerate-unicode-properties-5.1.3/.gitignore000066400000000000000000000003351317314715300214550ustar00rootroot00000000000000# Installed npm modules package-lock.json node_modules # Folder view configuration files .DS_Store Desktop.ini # Thumbnail cache files ._* Thumbs.db # Files that might appear on external disks .Spotlight-V100 .Trashes regenerate-unicode-properties-5.1.3/.travis.yml000066400000000000000000000002621317314715300215750ustar00rootroot00000000000000language: node_js node_js: - '4' - '5' - '6' - '7' script: - 'if [ "${TRAVIS_NODE_VERSION}" = "7" ]; then npm run build; fi' - 'npm test' git: depth: 1 regenerate-unicode-properties-5.1.3/LICENSE-MIT.txt000066400000000000000000000020651317314715300217410ustar00rootroot00000000000000Copyright 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. regenerate-unicode-properties-5.1.3/README.md000066400000000000000000000030711317314715300207440ustar00rootroot00000000000000# regenerate-unicode-properties [![Build status](https://travis-ci.org/mathiasbynens/regenerate-unicode-properties.svg?branch=master)](https://travis-ci.org/mathiasbynens/regenerate-unicode-properties) _regenerate-unicode-properties_ is a collection of [Regenerate](https://github.com/mathiasbynens/regenerate) sets for [various Unicode properties](https://github.com/tc39/proposal-regexp-unicode-property-escapes). ## Installation To use _regenerate-unicode-properties_ programmatically, install it as a dependency via [npm](https://www.npmjs.com/): ```bash $ npm install regenerate-unicode-properties ``` ## Usage To get a map of supported properties and their values: ```js const properties = require('regenerate-unicode-properties'); ``` To get a specific Regenerate set: ```js // Examples: const Lu = require('regenerate-unicode-properties/General_Category/Uppercase_Letter.js'); const Greek = require('regenerate-unicode-properties/Script_Extensions/Greek.js'); ``` To get the Unicode version the data was based on: ```js const unicodeVersion = require('regenerate-unicode-properties/unicode-version.js'); ``` To get the UTR51 version the emoji data was based on: ```js const emojiVersion = require('regenerate-unicode-properties/emoji-version.js'); ``` ## Author | [![twitter/mathias](https://gravatar.com/avatar/24e08a9ea84deb17ae121074d0f17125?s=70)](https://twitter.com/mathias "Follow @mathias on Twitter") | |---| | [Mathias Bynens](https://mathiasbynens.be/) | ## License _regenerate-unicode-properties_ is available under the [MIT](https://mths.be/mit) license. regenerate-unicode-properties-5.1.3/build.js000066400000000000000000000111461317314715300211240ustar00rootroot00000000000000'use strict'; const fs = require('fs'); const jsesc = require('jsesc'); const emptyDirSync = require('fs-extra').emptyDirSync; const regenerate = require('regenerate'); const UNICODE_VERSION = '10.0.0'; const unicode = require(`unicode-${ UNICODE_VERSION }`); /*----------------------------------------------------------------------------*/ const codePointToString = function(codePoint) { return '0x' + codePoint.toString(16).toUpperCase(); }; // Regenerate plugin that turns a set into some JavaScript source code that // generates that set. regenerate.prototype.toCode = function() { const data = this.data; // Iterate over the data per `(start, end)` pair. let index = 0; let start; let end; const length = data.length; const loneCodePoints = []; const ranges = []; while (index < length) { start = data[index]; end = data[index + 1] - 1; // Note: the `- 1` makes `end` inclusive. if (start == end) { loneCodePoints.push(codePointToString(start)); } else { ranges.push( 'addRange(' + codePointToString(start) + ', ' + codePointToString(end) + ')' ); } index += 2; } return 'require(\'regenerate\')(' + loneCodePoints.join(', ') + ')' + (ranges.length ? '.' + ranges.join('.') : ''); }; const INDEX = new Map(); /*----------------------------------------------------------------------------*/ const nonBinaryProperties = [ 'General_Category', 'Script', 'Script_Extensions', ]; for (const property of nonBinaryProperties) { const values = []; // Empty the target directory, or create it if it doesn’t exist yet. const directory = `${ property }`; console.log(`Emptying ${ directory }…`); emptyDirSync(directory); console.assert(unicode[property], `Property ${ property } not found.`); for (const value of unicode[property]) { values.push(value); const fileName = `${ directory }/${ value }.js`; console.log(`Creating ${ fileName }…`); const codePoints = require( `unicode-${ UNICODE_VERSION }/${ property }/${ value }/code-points.js` ); const set = regenerate(codePoints); const output = `module.exports = ${ set.toCode() };\n`; fs.writeFileSync(fileName, output); } INDEX.set(property, values.sort()); } /*----------------------------------------------------------------------------*/ const supportedProperties = require('unicode-canonical-property-names-ecmascript'); for (const property of nonBinaryProperties) { supportedProperties.delete(property); } const properties = [...supportedProperties]; const binaryProperties = []; const emojiBinaryProperties = []; for (const property of properties) { if (property == 'Extended_Pictographic' || property.startsWith('Emoji')) { emojiBinaryProperties.push(property); } else { binaryProperties.push(property); } } // Empty the target directory, or create it if it doesn’t exist yet. const directory = 'Binary_Property'; console.log(`Emptying ${ directory }…`); emptyDirSync(directory); for (const property of binaryProperties) { const fileName = `${ directory }/${ property }.js`; console.log(`Creating ${ fileName }…`); const codePoints = require( `unicode-${ UNICODE_VERSION }/Binary_Property/${ property }/code-points.js` ); const set = regenerate(codePoints); const output = `module.exports = ${ set.toCode() };\n`; fs.writeFileSync(fileName, output); } for (const property of emojiBinaryProperties) { const fileName = `Binary_Property/${ property }.js`; console.log(`Creating ${ fileName }…`); const codePoints = require( `unicode-tr51/${ property }.js` ); const set = regenerate(codePoints); const output = `module.exports = ${ set.toCode() };\n`; fs.writeFileSync(fileName, output); } const allBinaryProperties = binaryProperties .concat(emojiBinaryProperties) .sort(); INDEX.set('Binary_Property', allBinaryProperties); /*----------------------------------------------------------------------------*/ const output = `module.exports = ${ jsesc(INDEX, { 'compact': false }) };\n`; fs.writeFileSync('index.js', output); /*----------------------------------------------------------------------------*/ const packageData = require('./package.json'); const dependencies = Object.keys(packageData.devDependencies); const unicodePackage = dependencies.find((name) =>/^unicode-\d/.test(name)); const unicodeVersion = unicodePackage.replace(/^unicode-/g, ''); const versionOutput = `module.exports = ${ jsesc(unicodeVersion, { 'wrap': true }) };\n`; fs.writeFileSync('unicode-version.js', versionOutput); const emojiVersion = require('unicode-tr51/emoji-version.js'); const emojiVersionOutput = `module.exports = ${ jsesc(emojiVersion, { 'wrap': true }) };\n`; fs.writeFileSync('emoji-version.js', emojiVersionOutput); regenerate-unicode-properties-5.1.3/package.json000066400000000000000000000022651317314715300217570ustar00rootroot00000000000000{ "name": "regenerate-unicode-properties", "version": "5.1.3", "description": "Regenerate sets for Unicode properties and values.", "homepage": "https://github.com/mathiasbynens/regenerate-unicode-properties", "main": "index.js", "engines": { "node": ">=4" }, "files": [ "LICENSE-MIT.txt", "index.js", "emoji-version.js", "unicode-version.js", "Binary_Property", "General_Category", "Script", "Script_Extensions" ], "keywords": [ "unicode", "unicode-data", "regenerate" ], "license": "MIT", "author": { "name": "Mathias Bynens", "url": "https://mathiasbynens.be/" }, "repository": { "type": "git", "url": "https://github.com/mathiasbynens/regenerate-unicode-properties.git" }, "bugs": "https://github.com/mathiasbynens/regenerate-unicode-properties/issues", "dependencies": { "regenerate": "^1.3.3" }, "devDependencies": { "ava": "^0.22.0", "fs-extra": "^4.0.2", "jsesc": "^2.5.1", "unicode-10.0.0": "^0.7.4", "unicode-canonical-property-names-ecmascript": "^1.0.3", "unicode-tr51": "8.1.2" }, "scripts": { "build": "node build.js", "test": "ava ./tests" } } regenerate-unicode-properties-5.1.3/tests/000077500000000000000000000000001317314715300206265ustar00rootroot00000000000000regenerate-unicode-properties-5.1.3/tests/tests.js000066400000000000000000000011351317314715300223260ustar00rootroot00000000000000import test from 'ava'; import regenerate from 'regenerate'; import matchLoosely from '../index.js'; test(t => { t.true( require('../Binary_Property/ASCII.js') instanceof regenerate ); t.true( require('../Binary_Property/Emoji.js') instanceof regenerate ); t.true( require('../Binary_Property/Emoji.js').toRegExp().test('\u{1F921}') // U+1F921 CLOWN FACE ); t.throws( () => require('../Invalid_Property/X.js'), Error ); t.throws( () => require('../Script_Extensions/Invalid_Property_Value.js'), Error ); t.true( /^\d+\.\d+\.\d+$/.test(require('../unicode-version.js')) ); });