Skip to content

Commit c60ce90

Browse files
committed
Add unsafe versions of charAt, charCodeAt
1 parent 1f49396 commit c60ce90

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

Diff for: README.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,13 @@
104104

105105
split :: Regex -> String -> [String]
106106

107-
test :: Regex -> String -> Boolean
107+
test :: Regex -> String -> Boolean
108+
109+
110+
## Module Data.String.Unsafe
111+
112+
### Values
113+
114+
charAt :: Number -> String -> Char
115+
116+
charCodeAt :: Number -> String -> Number

Diff for: src/Data/String/Unsafe.purs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
module Data.String.Unsafe
2+
( charAt
3+
, charCodeAt
4+
) where
5+
6+
import Data.Char
7+
8+
foreign import charCodeAt
9+
"""
10+
function charCodeAt(i) {
11+
return function(s) {
12+
return s.charCodeAt(i);
13+
};
14+
}
15+
""" :: Number -> String -> Number
16+
17+
foreign import charAt
18+
"""
19+
function charAt(i) {
20+
return function(s) {
21+
return s.charAt(i);
22+
};
23+
}
24+
""" :: Number -> String -> Char

0 commit comments

Comments
 (0)