forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathext_string.mli
172 lines (117 loc) · 4.56 KB
/
ext_string.mli
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* In addition to the permissions granted to you by the LGPL, you may combine
* or link a "work that uses the Library" with a publicly distributed version
* of this file to produce a combined library or application, then distribute
* that combined work under the terms of your choosing, with no requirement
* to comply with the obligations normally placed on you by section 4 of the
* LGPL version 3 (or the corresponding section of a later version of the LGPL
* should you choose to use a later version).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
(** Extension to the standard library [String] module, fixed some bugs like
avoiding locale sensitivity *)
(** default is false *)
val split_by : ?keep_empty:bool -> (char -> bool) -> string -> string list
(** remove whitespace letters ('\t', '\n', ' ') on both side*)
val trim : string -> string
(** default is false *)
val split : ?keep_empty:bool -> string -> char -> string list
(** split by space chars for quick scripting *)
val quick_split_by_ws : string -> string list
val starts_with : string -> string -> bool
(**
return [-1] when not found, the returned index is useful
see [ends_with_then_chop]
*)
val ends_with_index : string -> string -> int
val ends_with : string -> string -> bool
(**
[ends_with_then_chop name ext]
@example:
{[
ends_with_then_chop "a.cmj" ".cmj"
"a"
]}
This is useful in controlled or file case sensitve system
*)
val ends_with_then_chop : string -> string -> string option
val escaped : string -> string
(**
[for_all_from s start p]
if [start] is negative, it raises,
if [start] is too large, it returns true
*)
val for_all_from:
string ->
int ->
(char -> bool) ->
bool
val for_all :
string ->
(char -> bool) ->
bool
val is_empty : string -> bool
val repeat : int -> string -> string
val equal : string -> string -> bool
(**
[find ~start ~sub s]
returns [-1] if not found
*)
val find : ?start:int -> sub:string -> string -> int
val contain_substring : string -> string -> bool
val non_overlap_count : sub:string -> string -> int
val rfind : sub:string -> string -> int
(** [tail_from s 1]
return a substring from offset 1 (inclusive)
*)
val tail_from : string -> int -> string
(** returns negative number if not found *)
val rindex_neg : string -> char -> int
val rindex_opt : string -> char -> int option
type check_result =
| Good | Invalid_module_name | Suffix_mismatch
val is_valid_source_name :
string -> check_result
val no_char : string -> char -> int -> int -> bool
val no_slash : string -> bool
(** return negative means no slash, otherwise [i] means the place for first slash *)
val no_slash_idx : string -> int
(** if no conversion happens, reference equality holds *)
val replace_slash_backward : string -> string
(** if no conversion happens, reference equality holds *)
val replace_backward_slash : string -> string
val empty : string
#if BS_COMPILER_IN_BROWSER then
val compare : string -> string -> int
#elif OCAML_VERSION =~ ">4.3.0" then
external compare : string -> string -> int = "caml_string_length_based_compare" [@@noalloc];;
#else
external compare : string -> string -> int = "caml_string_length_based_compare" "noalloc";;
#end
val single_space : string
val concat3 : string -> string -> string -> string
val concat4 : string -> string -> string -> string -> string
val concat5 : string -> string -> string -> string -> string -> string
val inter2 : string -> string -> string
val inter3 : string -> string -> string -> string
val inter4 : string -> string -> string -> string -> string
val concat_array : string -> string array -> string
val single_colon : string
val parent_dir_lit : string
val current_dir_lit : string
val capitalize_ascii : string -> string
val uncapitalize_ascii : string -> string
val lowercase_ascii : string -> string