summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-11-17 07:14:30 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2014-11-17 07:14:30 -0800
commit3fa0714153aa2242868d29a0c6e2816e561fbfbd (patch)
tree6fd01cfd9c4ed19689f06e0802596cace6cdea11
parentc507d164f5856779d23ef030c2a656391707a5ac (diff)
parentab76ca32ad353c3196357b02069e93267928751e (diff)
Merge pull request #203 from gcrico/Issue-202
Fix Issue 202 - Catch RangeError thrown by native String.fromCodePoint (js)
-rw-r--r--js/lib/from-code-point.js11
1 files changed, 10 insertions, 1 deletions
diff --git a/js/lib/from-code-point.js b/js/lib/from-code-point.js
index 94eca65..037c35e 100644
--- a/js/lib/from-code-point.js
+++ b/js/lib/from-code-point.js
@@ -2,7 +2,16 @@
/*! http://mths.be/fromcodepoint v0.2.1 by @mathias */
if (String.fromCodePoint) {
- module.exports = String.fromCodePoint;
+ module.exports = function (_) {
+ try {
+ return String.fromCodePoint(_);
+ } catch (e) {
+ if (e instanceof RangeError) {
+ return String.fromCharCode(0xFFFD);
+ }
+ throw e;
+ }
+ }
} else {