[Pkg-javascript-commits] [node-unicode-data] 01/06: New upstream version 0~20180223+gitd542555

Julien Puydt julien.puydt at laposte.net
Fri Feb 23 20:56:06 UTC 2018


This is an automated email from the git hooks/post-receive script.

jpuydt-guest pushed a commit to branch master
in repository node-unicode-data.

commit 39230d76aa9d9e33848c97f6d7da0b5f36bea9e5
Author: Julien Puydt <julien.puydt at laposte.net>
Date:   Fri Feb 23 19:03:22 2018 +0100

    New upstream version 0~20180223+gitd542555
---
 .nvmrc                                     |  2 +-
 README.md                                  |  1 +
 bootstrap.sh                               |  9 +++---
 index.js                                   | 14 +++++++++
 package.json                               | 10 +++----
 scripts/download.js                        |  5 +++-
 scripts/generate-data.js                   | 18 ++++++------
 scripts/parse-blocks-scripts-properties.js |  4 ++-
 scripts/parse-emoji-sequences.js           | 35 ++++++++++++++++++++++
 scripts/parse-emoji.js                     | 47 ++++++++++++++++++++++++++++++
 scripts/utils.js                           | 14 ++++++++-
 templates/README.md                        |  4 +++
 templates/package.json                     |  2 +-
 13 files changed, 142 insertions(+), 23 deletions(-)

diff --git a/.nvmrc b/.nvmrc
index 1e8b314..45a4fb7 100644
--- a/.nvmrc
+++ b/.nvmrc
@@ -1 +1 @@
-6
+8
diff --git a/README.md b/README.md
index 7397df9..c66e41d 100644
--- a/README.md
+++ b/README.md
@@ -55,6 +55,7 @@ For more information, see the README for the package you’re interested in. [He
 * [_unicode-8.0.0_](https://npmjs.org/package/unicode-8.0.0#readme) ([repository](https://github.com/mathiasbynens/unicode-8.0.0#readme))
 * [_unicode-9.0.0_](https://npmjs.org/package/unicode-9.0.0#readme) ([repository](https://github.com/mathiasbynens/unicode-9.0.0#readme))
 * [_unicode-10.0.0_](https://npmjs.org/package/unicode-10.0.0#readme) ([repository](https://github.com/mathiasbynens/unicode-10.0.0#readme))
+* [_unicode-11.0.0_](https://npmjs.org/package/unicode-11.0.0#readme) ([repository](https://github.com/mathiasbynens/unicode-11.0.0#readme))
 
 Note that these READMEs are auto-generated by this script, too – they describe all the data that is available for that particular Unicode version. To programmatically get this list of available categories, scripts, script extensions, blocks, and properties for a given Unicode version, just `require` the main module for that version:
 
diff --git a/bootstrap.sh b/bootstrap.sh
index 3beaa60..3ff366b 100755
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -11,10 +11,11 @@ for dir in $(find ./unicode-* -type d -maxdepth 0 | sort -r); do
 	cd "${dir}";
 	echo "Taking care of ${dir}…";
 	git add -A;
-	git commit -m 'Release v0.7.4';
-	git tag v0.7.4;
+	git commit -m 'Update @ https://github.com/mathiasbynens/node-unicode-data/commit/2d076c0f5bf6871644f745834b67003cf9e7dd2d';
+	#git commit -m 'Release v0.7.5'
+	#git tag v0.7.5;
 	git push;
-	git push --tags;
-	npm publish;
+	#git push --tags;
+	#npm publish;
 	cd ..;
 done;
diff --git a/index.js b/index.js
index 762724b..c937a0d 100644
--- a/index.js
+++ b/index.js
@@ -11,6 +11,8 @@ parsers.parseCompositionExclusions = require('./scripts/parse-composition-exclus
 parsers.parseLineBreak = require('./scripts/parse-line-break.js');
 parsers.parseScriptExtensions = require('./scripts/parse-script-extensions.js');
 parsers.parseWordBreak = require('./scripts/parse-word-break.js');
+parsers.parseEmoji = require('./scripts/parse-emoji.js');
+parsers.parseEmojiSequences = require('./scripts/parse-emoji-sequences.js');
 parsers.parseNames = require('./scripts/parse-names.js');
 const extend = utils.extend;
 const cp = require('cp');
@@ -119,6 +121,18 @@ const generateData = function(version) {
 		'map': parsers.parseWordBreak(version),
 		'type': 'Word_Break'
 	}));
+	console.log('Parsing Unicode v%s binary emoji properties…', version);
+	extend(dirMap, utils.writeFiles({
+		'version': version,
+		'map': parsers.parseEmoji(version),
+		'type': 'Binary_Property'
+	}));
+	console.log('Parsing Unicode v%s emoji sequence properties…', version);
+	extend(dirMap, utils.writeFiles({
+		'version': version,
+		'map': parsers.parseEmojiSequences(version),
+		'type': 'Sequence_Property'
+	}));
 	console.log('Parsing Unicode v%s `Names`…', version);
 	extend(dirMap, utils.writeFiles({
 		'version': version,
diff --git a/package.json b/package.json
index cd0d498..7b2fc9f 100644
--- a/package.json
+++ b/package.json
@@ -44,14 +44,14 @@
     "jsesc": "^2.5.1",
     "lodash.template": "^4.4.0",
     "mkdirp": "^0.5.1",
-    "regenerate": "^1.3.2",
-    "request": "^2.81.0",
-    "unicode-loose-match": "^2.2.0",
-    "unicode-property-aliases": "^1.1.1",
+    "regenerate": "^1.3.3",
+    "request": "^2.83.0",
+    "unicode-loose-match": "^2.4.0",
+    "unicode-property-aliases": "^1.3.0",
     "when": "^3.7.8"
   },
   "devDependencies": {
     "istanbul": "^0.4.5",
-    "unicode-property-value-aliases": "^3.0.0"
+    "unicode-property-value-aliases": "^3.2.0"
   }
 }
diff --git a/scripts/download.js b/scripts/download.js
index a918f76..59de6a2 100644
--- a/scripts/download.js
+++ b/scripts/download.js
@@ -40,7 +40,10 @@ const TYPES = [
 	'bidi-mirroring',
 	'bidi-brackets',
 	'line-break',
-	'word-break'
+	'word-break',
+	'emoji',
+	'emoji-sequences',
+	'emoji-zwj-sequences'
 ];
 
 for (const resource of resources) {
diff --git a/scripts/generate-data.js b/scripts/generate-data.js
index 14c17da..c50f089 100644
--- a/scripts/generate-data.js
+++ b/scripts/generate-data.js
@@ -9,18 +9,18 @@ const utils = require('../scripts/utils.js');
 const cluster = require('cluster');
 const numCPUs = require('os').cpus().length;
 
-const pad = function(number) {
-	return ('00' + String(number)).slice(-2);
+const pad = (number) => {
+	return String(number).padStart(2, '0');
 };
 
-const getTime = function() {
+const getTime = () => {
 	const currentdate = new Date();
 	return pad(currentdate.getHours()) + ':' +
 		pad(currentdate.getMinutes()) + ':' +
 		pad(currentdate.getSeconds());
 };
 
-const complicatedWorkThatTakesTime = function(resource, callback) {
+const complicatedWorkThatTakesTime = (resource, callback) => {
 
 	if (resource.length) {
 
@@ -46,7 +46,7 @@ if (cluster.isMaster) {
 		cluster.fork();
 	}
 
-	cluster.on('online', function(worker) {
+	cluster.on('online', (worker) => {
 
 		const size = Math.round(resources.length / numCPUs);
 		const x = worker.id - 1;
@@ -62,16 +62,16 @@ if (cluster.isMaster) {
 
 	});
 
-	cluster.on('exit', function(worker) {
-		if (worker.suicide) {
+	cluster.on('exit', (worker) => {
+		if (worker.exitedAfterDisconnect) {
 			console.log('[%s] Worker %d is done!', getTime(), worker.id);
 		}
 	});
 
 } else {
 
-	process.on('message', function(message) {
-		complicatedWorkThatTakesTime(message, function() {
+	process.on('message', (message) => {
+		complicatedWorkThatTakesTime(message, () => {
 			cluster.worker.kill();
 		});
 	});
diff --git a/scripts/parse-blocks-scripts-properties.js b/scripts/parse-blocks-scripts-properties.js
index b834623..c88aabc 100644
--- a/scripts/parse-blocks-scripts-properties.js
+++ b/scripts/parse-blocks-scripts-properties.js
@@ -48,7 +48,9 @@ const parseBlocksScriptsProperties = function(type, version) {
 		}
 		if (type == 'blocks') {
 			// Use canonical block names. See #34
-			item = looseMatch('Block', item).value;
+			const tmp = looseMatch('Block', item).value;
+			console.assert(item, `Canonical block name not found for ${item}`);
+			item = tmp;
 		} else if (type == 'bidi-mirroring') {
 			item = String.fromCodePoint(parseInt(item, 16));
 		}
diff --git a/scripts/parse-emoji-sequences.js b/scripts/parse-emoji-sequences.js
new file mode 100644
index 0000000..b59fd15
--- /dev/null
+++ b/scripts/parse-emoji-sequences.js
@@ -0,0 +1,35 @@
+'use strict';
+
+const utils = require('./utils.js');
+
+const parseEmojiSequences = function(version) {
+	const source = utils.readDataFile(version, 'emoji-sequences');
+	if (!source) {
+		return;
+	}
+	const propertyMap = new Map();
+	const lines = source.split('\n');
+	lines.forEach(function(line) {
+		if (!line || /^#/.test(line)) {
+			return;
+		}
+		const data = line.trim().split('; ');
+		const codePoints = data[0].trim().split(' ').map((hex) => {
+			return parseInt(hex, 16);
+		});
+		const sequence = String.fromCodePoint(...codePoints);
+		const property = data[1].split('#')[0].trim();
+		if (propertyMap.has(property)) {
+			propertyMap.get(property).add(sequence);
+		} else {
+			propertyMap.set(property, new Set([sequence]));
+		}
+	});
+	const plainObject = {};
+	for (const [property, codePoints] of propertyMap) {
+		plainObject[property] = [...codePoints].sort((a, b) => a - b);
+	}
+	return plainObject;
+};
+
+module.exports = parseEmojiSequences;
diff --git a/scripts/parse-emoji.js b/scripts/parse-emoji.js
new file mode 100644
index 0000000..cda0ba6
--- /dev/null
+++ b/scripts/parse-emoji.js
@@ -0,0 +1,47 @@
+'use strict';
+
+const utils = require('./utils.js');
+
+const parseEmoji = function(version) {
+	const source = utils.readDataFile(version, 'emoji');
+	if (!source) {
+		return;
+	}
+	const propertyMap = new Map();
+	const lines = source.split('\n');
+	lines.forEach(function(line) {
+		if (!line || /^#/.test(line)) {
+			return;
+		}
+		const data = line.trim().split(' ; ');
+		const charRange = data[0].replace('..', '-').trim();
+		const rangeParts = charRange.split('-');
+		const property = data[1].split('#')[0].trim();
+		if (rangeParts.length == 2) {
+			utils.range(
+				parseInt(rangeParts[0], 16),
+				parseInt(rangeParts[1], 16)
+			).forEach(function(codePoint) {
+				if (propertyMap.has(property)) {
+					propertyMap.get(property).add(codePoint);
+				} else {
+					propertyMap.set(property, new Set([codePoint]));
+				}
+			});
+		} else {
+			const codePoint = parseInt(rangeParts, 16);
+			if (propertyMap.has(property)) {
+				propertyMap.get(property).add(codePoint);
+			} else {
+				propertyMap.set(property, new Set([codePoint]));
+			}
+		}
+	});
+	const plainObject = {};
+	for (const [property, codePoints] of propertyMap) {
+		plainObject[property] = [...codePoints].sort((a, b) => a - b);
+	}
+	return plainObject;
+};
+
+module.exports = parseEmoji;
diff --git a/scripts/utils.js b/scripts/utils.js
index 709c0c8..5cb808a 100644
--- a/scripts/utils.js
+++ b/scripts/utils.js
@@ -83,8 +83,20 @@ const writeFiles = function(options) {
 			return;
 		}
 		append(dirMap, type, item);
-		// Create the target directory if it doesn’t exist yet
+		// Create the target directory if it doesn’t exist yet.
 		mkdirp.sync(dir);
+
+		// Sequence properties are special.
+		if (type == 'Sequence_Property') {
+			const sequences = codePoints;
+			const output = `module.exports=${ gzipInline(map[item]) }`;
+			fs.writeFileSync(
+				path.resolve(dir, 'index.js'),
+				output
+			);
+			return;
+		}
+
 		// Save the data to a file
 		fs.writeFileSync(
 			path.resolve(dir, 'code-points.js'),
diff --git a/templates/README.md b/templates/README.md
index be5da81..c969376 100644
--- a/templates/README.md
+++ b/templates/README.md
@@ -72,6 +72,10 @@ require('unicode-<%= version %>/<%= type %>/<%= dir %>/code-points.js').get(code
 require('unicode-<%= version %>/<%= type %>/<%= dir %>/symbols.js'); // lookup map from symbol to symbol(s)
 require('unicode-<%= version %>/<%= type %>/<%= dir %>/symbols.js').get(symbol);
 <%
+		} else if ('Sequence_Property' == type) {
+%>
+require('unicode-<%= version %>/<%= type %>/<%= dir %>/index.js'); // array containing a string for each sequence
+<%
 		} else {
 %>
 require('unicode-<%= version %>/<%= type %>/<%= dir %>/code-points.js');
diff --git a/templates/package.json b/templates/package.json
index 82739a5..e114532 100644
--- a/templates/package.json
+++ b/templates/package.json
@@ -1,6 +1,6 @@
 {
 	"name": "unicode-<%= version %>",
-	"version": "0.7.4",
+	"version": "0.7.5",
 	"description": "JavaScript-compatible Unicode data. Arrays of code points, arrays of symbols, and regular expressions for Unicode v<%= version %>’s categories, scripts, blocks, bidi, and other properties.",
 	"homepage": "https://github.com/mathiasbynens/unicode-<%= version %>",
 	"main": "index.js",

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-unicode-data.git



More information about the Pkg-javascript-commits mailing list