File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed
Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,8 @@ exports._count = function (isLead) {
7373exports . _fromCodePointArray = function ( singleton ) {
7474 return hasFromCodePoint
7575 ? function ( cps ) {
76+ // Function.prototype.apply will fail for very large second parameters,
77+ // so we don't use it for arrays with 10KB or more entries.
7678 if ( cps . length < 10240 ) {
7779 return String . fromCodePoint . apply ( String , cps ) ;
7880 }
Original file line number Diff line number Diff line change 1+ -- | These functions allow PureScript strings to be treated as if they were
2+ -- | sequences of Unicode code points instead of their true underlying
3+ -- | implementation (sequences of UTF-16 code units). For nearly all uses of
4+ -- | strings, these functions should be preferred over the ones in Data.String.
15module Data.String.CodePoints
26 ( module StringReExports
37 , CodePoint ()
@@ -36,12 +40,17 @@ import Data.Tuple (Tuple(Tuple))
3640import Data.Unfoldable (unfoldr )
3741
3842
43+ -- | CodePoint is an Int bounded between 0 and 0x10FFFF, corresponding to
44+ -- | Unicode code points.
3945newtype CodePoint = CodePoint Int
4046
4147derive instance eqCodePoint :: Eq CodePoint
4248derive instance ordCodePoint :: Ord CodePoint
4349derive instance newtypeCodePoint :: Newtype CodePoint _
4450
51+ -- I would prefer that this smart constructor not need to exist and instead
52+ -- CodePoint just implements Enum, but the Enum module already depends on this
53+ -- one. To avoid the circular dependency, we just expose these two functions.
4554codePointFromInt :: Int -> Maybe CodePoint
4655codePointFromInt n | 0 <= n && n <= 0x10FFFF = Just (CodePoint n)
4756codePointFromInt n = Nothing
You can’t perform that action at this time.
0 commit comments