Skip to content

Commit 34605c6

Browse files
committed
Initial commit
0 parents  commit 34605c6

File tree

5 files changed

+174
-0
lines changed

5 files changed

+174
-0
lines changed

Diff for: .gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/js/
2+
/externs/
3+
/node_modules/
4+
/bower_components/

Diff for: LICENSE

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2014 PureScript
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software is furnished to do so,
10+
subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Diff for: bower.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "purescript-strings",
3+
"version": "0.0.0",
4+
"homepage": "https://github.com/purescript/purescript-strings",
5+
"description": "String utility functions and regular expressions",
6+
"keywords": [
7+
"purescript"
8+
],
9+
"license": "MIT",
10+
"ignore": [
11+
"**/.*",
12+
"node_modules",
13+
"bower_components",
14+
"examples",
15+
"externs",
16+
"js"
17+
]
18+
}

Diff for: src/Data/String.purs

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
module Data.String where
2+
3+
foreign import lengthS
4+
"function lengthS(s) {\
5+
\ return s.length;\
6+
\}" :: String -> Number
7+
8+
foreign import charAt
9+
"function charAt(i) {\
10+
\ return function(s) {\
11+
\ return s.charAt(i); \
12+
\ };\
13+
\}" :: Number -> String -> String
14+
15+
foreign import indexOfS
16+
"function indexOfS(s1) {\
17+
\ return function(s2) {\
18+
\ return s1.indexOf(s2);\
19+
\ }; \
20+
\}" :: String -> String -> Number
21+
22+
foreign import lastIndexOfS
23+
"function lastIndexOfS(s1) {\
24+
\ return function(s2) {\
25+
\ return s1.lastIndexOf(s2);\
26+
\ };\
27+
\}" :: String -> String -> Number
28+
29+
foreign import localeCompare
30+
"function localeCompare(s1) {\
31+
\ return function(s2) {\
32+
\ return s1.localeCompare(s2);\
33+
\ };\
34+
\}" :: String -> String -> Number
35+
36+
foreign import replace
37+
"function replace(s1) {\
38+
\ return function(s2) {\
39+
\ return function(s3) {\
40+
\ return s3.replace(s1, s2);\
41+
\ };\
42+
\ };\
43+
\}" :: String -> String -> String -> String
44+
45+
foreign import sliceS
46+
"function sliceS(st) {\
47+
\ return function(e) {\
48+
\ return function(s) {\
49+
\ return s.slice(st, e);\
50+
\ };\
51+
\ };\
52+
\}" :: Number -> Number -> String -> String
53+
54+
foreign import split
55+
"function split(sep) {\
56+
\ return function(s) {\
57+
\ return s.split(sep);\
58+
\ };\
59+
\}" :: String -> String -> [String]
60+
61+
foreign import substr
62+
"function substr(n1) {\
63+
\ return function(n2) {\
64+
\ return function(s) {\
65+
\ return s.substr(n1, n2);\
66+
\ };\
67+
\ };\
68+
\}" :: Number -> Number -> String -> String
69+
70+
foreign import substring
71+
"function substring(n1) {\
72+
\ return function(n2) {\
73+
\ return function(s) {\
74+
\ return s.substring(n1, n2);\
75+
\ };\
76+
\ };\
77+
\}" :: Number -> Number -> String -> String
78+
79+
foreign import toLower
80+
"function toLower(s) {\
81+
\ return s.toLowerCase();\
82+
\}" :: String -> String
83+
84+
foreign import toUpper
85+
"function toUpper(s) {\
86+
\ return s.toUpperCase();\
87+
\}" :: String -> String
88+
89+
foreign import trim
90+
"function trim(s) {\
91+
\ return s.trim();\
92+
\}" :: String -> String

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

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
module Data.String.Regex where
2+
3+
foreign import data Regex :: *
4+
5+
foreign import regex
6+
"function regex(s1) {\
7+
\ return function(s2) {\
8+
\ return new Regex(s1, s2);\
9+
\ };\
10+
\}" :: String -> String -> Regex
11+
12+
foreign import test
13+
"function test(r) {\
14+
\ return function (s) {\
15+
\ return r.test(s);\
16+
\ };\
17+
\}" :: Regex -> String -> Boolean
18+
19+
foreign import match
20+
"function match(r) {\
21+
\ return function (s) {\
22+
\ return s.match(r); \
23+
\ };\
24+
\}" :: Regex -> String -> [String]
25+
26+
foreign import replaceR
27+
"function replaceR(r) {\
28+
\ return function(s1) {\
29+
\ return function(s2) {\
30+
\ return s2.replace(r, s1);\
31+
\ };\
32+
\ };\
33+
\}" :: Regex -> String -> String -> String
34+
35+
foreign import search
36+
"function search(r) {\
37+
\ return function (s) {\
38+
\ return s.search(r);\
39+
\ };\
40+
\}" :: Regex -> String -> Number

0 commit comments

Comments
 (0)