[Pkg-javascript-commits] [unorm.js] 08/19: Imported Upstream version 1.0.5

Mike Gabriel sunweaver at debian.org
Thu Dec 15 10:49:10 UTC 2016


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

sunweaver pushed a commit to branch master
in repository unorm.js.

commit 89c351b553721e66bcf5588bb73e4ee1ba2db200
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date:   Sun May 26 20:46:46 2013 +0200

    Imported Upstream version 1.0.5
---
 .gitignore                                         |  2 ++
 .npmignore                                         |  6 ++--
 README.md                                          | 35 ++++++++++++++++++++--
 download-source.sh                                 |  3 --
 .../basic-usage/basic-usage-in-node.js             | 15 ++++++----
 index.js => lib/unorm.js                           | 17 ++++++++---
 package.json                                       |  4 +--
 package.sh                                         | 21 -------------
 src/export.js                                      | 13 ++++++++
 src/scripts/package.sh                             | 19 ++++++++++++
 10 files changed, 94 insertions(+), 41 deletions(-)

diff --git a/.gitignore b/.gitignore
index 1ca9571..bd593f5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,4 @@
 node_modules/
 npm-debug.log
+.DS_Store
+research/
diff --git a/.npmignore b/.npmignore
index 7547d83..defe180 100644
--- a/.npmignore
+++ b/.npmignore
@@ -1,5 +1,5 @@
-src
-download-source.sh
-package.sh
 node_modules/
 npm-debug.log
+research/
+.DS_Store
+src/
diff --git a/README.md b/README.md
index 49aa582..0cca2bf 100644
--- a/README.md
+++ b/README.md
@@ -9,10 +9,21 @@ npm install unorm
 ```
 
 
-Usage example
--------------
+Functions
+---------
 
-For a longer example, see `example.js`.
+This module exports four functions: `nfc`, `nfd`, `nfkc`, and `nfkd`; one for each Unicode normalization. In the browser the functions are exported in the `unorm` global. In CommonJS environments you just require the module. Functions:
+
+ *  `unorm.nfd(str)` – Canonical Decomposition
+ *  `unorm.nfc(str)` – Canonical Decomposition, followed by Canonical Composition
+ *  `unorm.nfkd(str)` – Compatibility Decomposition
+ *  `unorm.nfkc(str)` – Compatibility Decomposition, followed by Canonical Composition
+
+
+Node.JS example
+---------------
+
+For a longer example, see `examples` directory.
 
 ```javascript
 var unorm = require('unorm');
@@ -33,6 +44,24 @@ console.log(' * = Combining characters removed from decomposed form.');
 ```
 
 
+Road map
+--------
+
+As of May 2013.
+
+Short term:
+- Clean up some of the code
+- Fix JSHint errors
+
+Middle term:
+- Test harness by using the Unicode normalization test suite and examples from the reports
+
+Longer term:
+- Look at the unicode data compiler to create up-to-date (Unicode 6.2.0) compatible normalization
+- Look at possible optimizations (speed primarely, module size secondarily)
+- Adding functions to quick check normalizations: `is_nfc`, `is_nfd`, etc.
+
+
 License
 -------
 
diff --git a/download-source.sh b/download-source.sh
deleted file mode 100755
index facea1c..0000000
--- a/download-source.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-test -d src/ && rm -r src/
-svn export http://svn.coderepos.org/share/lang/javascript/UnicodeNormalizer/ src/
diff --git a/example.js b/examples/basic-usage/basic-usage-in-node.js
similarity index 81%
rename from example.js
rename to examples/basic-usage/basic-usage-in-node.js
index 79cca06..3d82fcf 100644
--- a/example.js
+++ b/examples/basic-usage/basic-usage-in-node.js
@@ -1,3 +1,6 @@
+/*jshint node:true*/
+'use strict';
+
 var unorm = require('unorm');
 
 // Function to display Unicode codepoints of a string.
@@ -32,8 +35,10 @@ console.log(unorm.nfkc(scientific));
 
 // Remove combining characters / marks from Swedish name, ie. ö becomes o.
 // This is useful for indexing and searching internationalized text.
-var XRegExp = require('xregexp').XRegExp;
-var name = '\u00C5ngstr\u00F6m';
-console.log('- Example 4 -');
-console.log(unorm.nfkd(name));
-console.log(unorm.nfkd(name).replace(XRegExp('\\p{M}', 'g'), ''));
+try {
+	var xregexp = require('xregexp').XRegExp;
+	var name = '\u00C5ngstr\u00F6m';
+	console.log('- Example 4 -');
+	console.log(unorm.nfkd(name));
+	console.log(unorm.nfkd(name).replace(xregexp('\\p{M}', 'g'), ''));
+} catch (ex) {}
diff --git a/index.js b/lib/unorm.js
similarity index 99%
rename from index.js
rename to lib/unorm.js
index c74112d..fbcd3be 100644
--- a/index.js
+++ b/lib/unorm.js
@@ -1,3 +1,5 @@
+/*globals exports:true,window:true*/
+(function() {
 
 /***** unorm.js *****/
 
@@ -396,9 +398,16 @@ if(!this.UNorm || !this.UNorm.UChar){throw 'must include unorm.js prior to unorm
 
 /***** Export as Common JS module *****/
 
+var root = typeof(exports) === 'object' ? exports : {};
+
+if (typeof(window) === 'object') {
+	window.unorm = root;
+}
+
 // The easy conversion functions are exported.
+root.nfc  = UNorm.nfc;
+root.nfd  = UNorm.nfd;
+root.nfkc = UNorm.nfkc;
+root.nfkd = UNorm.nfkd;
 
-exports.nfc  = UNorm.nfc;
-exports.nfd  = UNorm.nfd;
-exports.nfkc = UNorm.nfkc;
-exports.nfkd = UNorm.nfkd;
+}());
diff --git a/package.json b/package.json
index c606c7c..5920470 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
 	"name" : "unorm",
-	"version" : "1.0.3",
+	"version" : "1.0.5",
 	"description" : "JavaScript Unicode Normalization - NFC, NFD, NFKC, NFKD. Read <http://unicode.org/reports/tr15/> UAX #15 Unicode Normalization Forms.",
 	"author": "Matsuza <matsuza at gmail.com>",
 	"contributors": [
@@ -11,7 +11,7 @@
 		"type" : "git",
 		"url" : "http://github.com/walling/unorm.git" 
 	},
-	"main": "./index.js",
+	"main": "./lib/unorm.js",
 	"engines" : {
 		"node" : ">= 0.4.0"
 	}
diff --git a/package.sh b/package.sh
deleted file mode 100755
index d6afbdd..0000000
--- a/package.sh
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/bin/sh
-test -f index.js && rm index.js
-
-echo ''                                               >> index.js
-echo '/***** unorm.js *****/'                         >> index.js
-echo ''                                               >> index.js
-cat src/unorm.js | sed -e 's/^})();$/}).call(this);/' >> index.js
-echo 'var UNorm = this.UNorm; // Small hack :-)'      >> index.js
-echo ''                                               >> index.js
-echo '/***** unormdata.js *****/'                     >> index.js
-echo ''                                               >> index.js
-cat src/unormdata.js                                  >> index.js
-echo ''                                               >> index.js
-echo '/***** Export as Common JS module *****/'       >> index.js
-echo ''                                               >> index.js
-echo '// The easy conversion functions are exported.' >> index.js
-echo ''                                               >> index.js
-echo 'exports.nfc  = UNorm.nfc;'                      >> index.js
-echo 'exports.nfd  = UNorm.nfd;'                      >> index.js
-echo 'exports.nfkc = UNorm.nfkc;'                     >> index.js
-echo 'exports.nfkd = UNorm.nfkd;'                     >> index.js
diff --git a/src/export.js b/src/export.js
new file mode 100644
index 0000000..302011c
--- /dev/null
+++ b/src/export.js
@@ -0,0 +1,13 @@
+/***** Export as Common JS module *****/
+
+var root = typeof(exports) === 'object' ? exports : {};
+
+if (typeof(window) === 'object') {
+	window.unorm = root;
+}
+
+// The easy conversion functions are exported.
+root.nfc  = UNorm.nfc;
+root.nfd  = UNorm.nfd;
+root.nfkc = UNorm.nfkc;
+root.nfkd = UNorm.nfkd;
diff --git a/src/scripts/package.sh b/src/scripts/package.sh
new file mode 100755
index 0000000..2fe6813
--- /dev/null
+++ b/src/scripts/package.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+cd "`dirname "$0"`/../.."
+
+echo '/*globals exports:true,window:true*/'            > lib/unorm.js
+echo '(function() {'                                  >> lib/unorm.js
+echo ''                                               >> lib/unorm.js
+echo '/***** unorm.js *****/'                         >> lib/unorm.js
+echo ''                                               >> lib/unorm.js
+cat src/unorm.js | sed -e 's/^})();$/}).call(this);/' >> lib/unorm.js
+echo 'var UNorm = this.UNorm; // Small hack :-)'      >> lib/unorm.js
+echo ''                                               >> lib/unorm.js
+echo '/***** unormdata.js *****/'                     >> lib/unorm.js
+echo ''                                               >> lib/unorm.js
+cat src/unormdata.js                                  >> lib/unorm.js
+echo ''                                               >> lib/unorm.js
+cat src/export.js                                     >> lib/unorm.js
+echo ''                                               >> lib/unorm.js
+echo '}());'                                          >> lib/unorm.js

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/unorm.js.git



More information about the Pkg-javascript-commits mailing list