Skip to content

Commit 7445261

Browse files
takejohnFineArchs
andauthored
実際のAiScriptと同じ型注釈に変更 (#5)
* 実際のAiScriptと同じ型注釈に変更 * Update docs/en/references/builtin-props.md Co-authored-by: FineArchs <[email protected]> --------- Co-authored-by: FineArchs <[email protected]>
1 parent c607b11 commit 7445261

File tree

4 files changed

+88
-88
lines changed

4 files changed

+88
-88
lines changed

docs/en/references/builtin-props.md

+31-31
Original file line numberDiff line numberDiff line change
@@ -55,28 +55,28 @@ let y = "abc"
5555
<: y.to_num()
5656
```
5757

58-
### @(_v_: str).to_arr(): `arr<str>`
58+
### @(_v_: str).to_arr(): arr&lt;str&gt;
5959
Splits the string into an array of grapheme clusters.
6060
If the string contains no isolated surrogates, they are not returned.
6161

62-
### @(_v_: str).to_unicode_arr(): `arr<str>`
62+
### @(_v_: str).to_unicode_arr(): arr&lt;str&gt;
6363
Splits the string into an array of Unicode code points.
6464
Grapheme clusters are divided.
6565
If the string contains no isolated surrogates, they are not returned.
6666

67-
### @(_v_: str).to_unicode_codepoint_arr(): `arr<num>`
67+
### @(_v_: str).to_unicode_codepoint_arr(): arr&lt;num&gt;
6868
Splits the string into Unicode code points and returns their numeric values as an array.
6969
If the string contains no isolated surrogates, they are not returned.
7070

71-
### @(_v_: str).to_char_arr(): `arr<str>`
71+
### @(_v_: str).to_char_arr(): arr&lt;str&gt;
7272
Splits the string into an array of UTF-16 code units.
7373
If the string contains surrogate pairs, both the high and low surrogates are returned separately.
7474

75-
### @(_v_: str).to_charcode_arr(): `arr<num>`
75+
### @(_v_: str).to_charcode_arr(): arr&lt;num&gt;
7676
Splits the string into UTF-16 code units and returns their numeric values as an array.
7777
If the string contains surrogate pairs, both the high and low surrogates are returned separately.
7878

79-
### @(_v_: str).to_utf8_byte_arr(): `arr<num>`
79+
### @(_v_: str).to_utf8_byte_arr(): arr&lt;num&gt;
8080
Encodes the string into UTF-8 and returns an array of byte values (0–255).
8181

8282
### @(_v_: str).pick(_i_: num): str | null
@@ -127,7 +127,7 @@ let x = "Hello World!"
127127
<: x.slice(6, 11)
128128
```
129129

130-
### @(_v_: str).split(_splitter_?: str): `arr<str>`
130+
### @(_v_: str).split(_splitter_?: str): arr&lt;str&gt;
131131
Splits the string into an array based on the delimiter _splitter_. If _splitter_ is omitted, splits the string into individual characters.
132132
```aiscript playground
133133
let x = "Hey, how are you?"
@@ -152,7 +152,7 @@ let x = [1, 2, 3, 4, 5]
152152
<: x.len
153153
```
154154

155-
### @(_v_: arr).at(_index_: num, _otherwise_?: value): value
155+
### @(_v_: arr&lt;T&gt;).at(_index_: num, _otherwise_?: T): T | null
156156
Returns the element at the position _index_ in the array.\
157157
If _index_ is negative, it counts from the end.\
158158
If _index_ is out of range, it returns _otherwise_ instead.\
@@ -167,7 +167,7 @@ let x = [1, 2, 3, 4, 5]
167167
<: x.at(5, "Not Found")
168168
```
169169

170-
### @(_v_: arr).push(_i_: value): null
170+
### @(_v_: arr&lt;T&gt;).push(_i_: T): null
171171
**【This operation mutates the array】**
172172
Adds an element to the end of the array.
173173

@@ -178,7 +178,7 @@ x.push(8)
178178
<: x
179179
```
180180

181-
### @(_v_: arr).unshift(i: value): null
181+
### @(_v_: arr&lt;T&gt;).unshift(i: T): null
182182
**【This operation mutates the array】**
183183
Adds an element to the beginning of the array.
184184

@@ -189,7 +189,7 @@ x.unshift(7)
189189
<: x
190190
```
191191

192-
### @(_v_: arr).pop(): value
192+
### @(_v_: arr&lt;T&gt;).pop(): T | null
193193
**【This operation mutates the array】**
194194
Removes and returns the last element of the array.
195195

@@ -201,7 +201,7 @@ let popped = x.pop()
201201
<: x
202202
```
203203

204-
### @(_v_: arr).shift(): value
204+
### @(_v_: arr&lt;T&gt;).shift(): T | null
205205
**【This operation mutates the array】**
206206
Removes and returns the first element of the array.
207207

@@ -213,7 +213,7 @@ let shifted = x.shift()
213213
<: x
214214
```
215215

216-
### @(_a_: arr).concat(_b_: arr): arr
216+
### @(_a_: arr&lt;T&gt;).concat(_b_: arr&lt;T&gt;): arr&lt;T&gt;
217217
Concatenates two arrays.
218218

219219
```aiscript playground
@@ -239,7 +239,7 @@ let x = ["Hello", "World", "!"]
239239
<: x.join()
240240
```
241241

242-
### @(_v_: arr).slice(_begin_: num, _end_: num): arr
242+
### @(_v_: arr&lt;T&gt;).slice(_begin_: num, _end_: num): arr&lt;T&gt;
243243
Extracts a section of the array from _begin_ to _end_.
244244

245245
```aiscript playground
@@ -248,7 +248,7 @@ let x = [1, 2, 3, 4, 5]
248248
<: x.slice(1, 4)
249249
```
250250

251-
### @(_v_: arr).incl(_i_: value): bool
251+
### @(_v_: arr&lt;T&gt;).incl(_i_: T): bool
252252
Returns whether the specified value is present in the array.
253253

254254
```aiscript playground
@@ -258,7 +258,7 @@ let x = [1, 2, 3, 4, 5]
258258
<: x.incl(6)
259259
```
260260

261-
### @(_v_: arr).map(_func_: fn): arr
261+
### @(_v_: arr&lt;T&gt;).map(_func_: @(T, num) =&gt; U): arr&lt;U&gt;
262262
Asynchronously calls _func_ on each element of the array.\
263263
Returns a new array with elements replaced by the results of _func_.
264264

@@ -270,7 +270,7 @@ let x = ['Tanaka', 'Suzuki', 'Yamamoto']
270270
})
271271
```
272272

273-
### @(_v_: arr).filter(_func_: fn): arr
273+
### @(_v_: arr&lt;T&gt;).filter(_func_: @(T, num) =&gt; bool): arr&lt;T&gt;
274274
Extracts elements from the array where _func_ returns true.\
275275
The order is preserved.
276276

@@ -283,8 +283,8 @@ let x = [1, 2, 3, 4, 5]
283283
})
284284
```
285285

286-
### @(_v_: arr).reduce(_func_: Callback, _initial_: value): value
287-
`Callback`: @(_acm_: value, _item_: value, _index_: num): value
286+
### @(_v_: arr&lt;T&gt;).reduce&lt;U&gt;(_func_: Callback, _initial_: U): U
287+
`Callback`: @(_acm_: U, _item_: T, _index_: num): U
288288
Calls _func_ for each element of the array in turn.
289289
In each call, the previous result is passed as the first argument _acm_.
290290
If _initial_ is specified, the argument of the first call is (_initial_, _v_\[0], 0),
@@ -300,7 +300,7 @@ let x = [1, 2, 3, 4, 5]
300300
}, 0)
301301
```
302302

303-
### @(_v_: arr).find(_func_: @(_item_: value, _index_: num) { bool }): value
303+
### @(_v_: arr&lt;T&gt;).find(_func_: @(_item_: T, _index_: num) =&gt; bool ): T | null
304304
Find the first element in the array such that _func_ returns true and returns their values.
305305

306306
```aiscript playground
@@ -312,7 +312,7 @@ let x = [1, 2, 3, 4, 5]
312312
})
313313
```
314314

315-
### @(_v_: arr).index_of(_val_: value, _fromIndex_?: num): num
315+
### @(_v_: arr&lt;T&gt;).index_of(_val_: T, _fromIndex_?: num): num
316316
Searches the array for a value equal to _val_ and returns its index.
317317
If _fromIndex_ is specified, the search starts at that position.
318318
If _fromIndex_ is negative, the position from the end (array length + _fromIndex_) is used.
@@ -336,7 +336,7 @@ x.reverse()
336336
<: x
337337
```
338338

339-
### @(_v_: arr).copy(): arr
339+
### @(_v_: arr&lt;T&gt;).copy(): arr&lt;T&gt;
340340
Generates a copy of the array.
341341
It is a shallow copy, and array and object references are preserved.
342342

@@ -353,7 +353,7 @@ xCopy.push(6)
353353
<: xCopy
354354
```
355355

356-
### @(_v_: arr).sort(_comp_: @(_a_: value, _b_: value)): arr
356+
### @(_v_: arr&lt;T&gt;).sort(_comp_: @(_a_: T, _b_: T) => num): arr&lt;T&gt;
357357
**【This operation mutates the array】**
358358
Sort an array. Pass the following comparison function as the first argument _comp_.
359359
This operation is stable sort.
@@ -380,7 +380,7 @@ x.sort(@(a, b) {
380380
<: x
381381
```
382382

383-
### @(_v_: arr).fill(_val_?: value, _fromIndex_?: num, _toIndex_?: num): arr
383+
### @(_v_: arr&lt;T&gt;).fill(_val_?: T, _fromIndex_?: num, _toIndex_?: num): arr&lt;T&gt;
384384
**【This operation mutates the array】**
385385
Replaces elements in the range _fromIndex_ to _toIndex_ of the array with _val_.
386386
If _val_ is omitted, it is replaced with `null`.
@@ -395,7 +395,7 @@ x.fill(0, 1, 4)
395395
<: x
396396
```
397397

398-
### @(_v_: arr).repeat(_times_: num): arr
398+
### @(_v_: arr&lt;T&gt;).repeat(_times_: num): arr&lt;T&gt;
399399
Creates an array repeated _times_ times.
400400
Like `arr.copy`, it is a shallow copy, and array and object references are preserved.
401401
_times_ must be an integer value greater than or equal to 0. Otherwise, throws error.
@@ -406,7 +406,7 @@ let x = [1, 2, 3]
406406
<: x.repeat(3)
407407
```
408408

409-
### @(_v_: arr).splice(_index_: num, _remove_count_?: num, _items_?: arr\&lt;value&gt;): arr\&lt;value&gt;
409+
### @(_v_: arr&lt;T&gt;).splice(_index_: num, _remove_count_?: num, _items_?: arr&lt;T&gt;): arr&lt;T&gt;
410410
**【This operation mutates the array】**
411411
Removes _remove_count_ elements from the _index_ array and inserts _items_ elements in their place.
412412
Returns an array of the elements removed as the return value.
@@ -436,7 +436,7 @@ let x = [1, [2, 3], [4, [5, 6]]]
436436
<: x.flat(2)
437437
```
438438

439-
### @(_v_: arr).flat_map(_func_: @(_item_: value, _index_: num) { value }): arr
439+
### @(_v_: arr&lt;T&gt;).flat_map&lt;U&gt;(_func_: @(_item_: T, _index_: num) =&gt; arr&lt;U&gt; | U ): arr&lt;U&gt;
440440
After replacing each element of the array with the return value of _func_, a new array is created, flattened by one level.
441441
_func_ is called asynchronously.
442442

@@ -448,7 +448,7 @@ let x = [1, 2, 3]
448448
})
449449
```
450450

451-
### @(_v_: arr).insert(_index_: num, _item_: value): null
451+
### @(_v_: arr&lt;T&gt;).insert(_index_: num, _item_: T): null
452452
**【This operation mutates the array】**
453453
Inserts _item_ at the _index_ position in the array.
454454
If _index_ is negative, count from the end.
@@ -463,7 +463,7 @@ x.insert(2, 6)
463463
<: x
464464
```
465465

466-
### @(_v_: arr).remove(_index_: num): value | null
466+
### @(_v_: arr&lt;T&gt;).remove(_index_: num): T | null
467467
**【This operation mutates the array】**
468468
Removes the element at position _index_ from the array and returns that element.
469469
If _index_ is negative, count from the end.
@@ -479,7 +479,7 @@ let removed = x.remove(2)
479479
<: x
480480
```
481481

482-
### @(_v_: arr).every(_func_: @(_item_: value, _index_: num) { bool }): bool
482+
### @(_v_: arr&lt;T&gt;).every(_func_: @(_item_: T, _index_: num) =&gt; bool ): bool
483483
Returns true only if _func_ returns true for all elements of the array. Always returns true for an empty array.
484484

485485
```aiscript playground
@@ -498,7 +498,7 @@ let y = [2, 4, 6, 7, 8]
498498
<: judgeAllEven(y)
499499
```
500500

501-
### @(_v_: arr).some(_func_: @(_item_: value, _index_: num) { bool }): bool
501+
### @(_v_: arr&lt;T&gt;).some(_func_: @(_item_: T, _index_: num) =&gt; bool): bool
502502
Returns true only when there is an element for which _func_ returns true for an array element.
503503

504504
```aiscript playground

docs/en/references/std.md

+13-13
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ Accepts string input.
2828
Type: `str`
2929
Version of AiScript runtime that's currently running.
3030

31-
#### @Core:type(_v_: value): str
31+
#### @Core:type(_v_: any): str
3232
Get the type name of the value.
3333

34-
#### @Core:to_str(_v_: value): str
34+
#### @Core:to_str(_v_: any): str
3535
Obtains a string representing a value.
3636

3737
#### @Core:sleep(_time_: num): void
@@ -45,10 +45,10 @@ Aborts the execution.
4545
Generates new UUID.
4646

4747
### :: Json
48-
#### @Json:stringify(_v_: value): str
48+
#### @Json:stringify(_v_: any): str
4949
Generate JSON string.
5050

51-
#### @Json:parse(_json_: str): value
51+
#### @Json:parse&lt;T&gt;(_json_: str): T
5252
Parse JSON into object. Returns an error type value (`name`=`'not_json'`) if the argument is not parsable as JSON.
5353

5454
#### @Json:parsable(_str_: str): bool
@@ -153,37 +153,37 @@ Escape sequences corresponding to the following characters are not decoded:
153153
Returns a string that decodes encoded_text as an encoded URI component.
154154

155155
### :: Arr
156-
#### @Arr:create(_length_: num, _initial_?: value): arr
156+
#### @Arr:create&lt;T&gt;(_length_: num, _initial_?: T): arr&lt;T&gt;
157157
Creates an array of length `length`.
158158
The array will be filled with _initial_ if given, otherwise with `null`.
159159

160160
### :: Obj
161161
#### @Obj:keys(_v_: obj): arr
162-
#### @Obj:vals(_v_: obj): arr
162+
#### @Obj:vals&lt;T&gt;(_v_: obj&lt;T&gt;): arr&lt;T&gt;
163163
#### @Obj:kvs(_v_: obj): arr
164164
Returns an array of object keys, values, and key/value pairs.
165165

166-
#### @Obj:get(_v_: obj, _key_: str): value
166+
#### @Obj:get&lt;T&gt;(_v_: obj&lt;T&gt;, _key_: str): T
167167

168-
#### @Obj:set(_v_: obj, _key_: str, _val_: value): null
168+
#### @Obj:set&lt;T&gt;(_v_: obj&lt;T&gt;, _key_: str, _val_: T): null
169169

170170
#### @Obj:has(_v_: obj, _key_: str): bool
171171

172-
#### @Obj:copy(_v_: obj): obj
172+
#### @Obj:copy&lt;T&gt;(_v_: obj&lt;T&gt;): obj&lt;T&gt;
173173
Generates the copy of the object.
174174

175-
#### @Obj:merge(_o1_: obj, _o2_: obj): obj
175+
#### @Obj:merge&lt;T&gt;(_o1_: obj&lt;T&gt;, _o2_: obj&lt;T&gt;): obj&lt;T&gt;
176176
Returns a merged version of the two objects.
177177

178178
### :: Error
179-
#### @Error:create(_name_: str, _info_?: value): error
179+
#### @Error:create(_name_: str, _info_?: any): error
180180
Create error type value.
181181

182182
### :: Async
183-
#### @Async:interval(_interval_: num, _callback_: fn, _immediate_?: bool): fn
183+
#### @Async:interval(_interval_: num, _callback_: @() => any, _immediate_?: bool): @() => void
184184
Calls the callback function at the specified period.
185185
Returns a stop function.
186186

187-
#### @Async:timeout(_delay_: num, _callback_: fn):
187+
#### @Async:timeout(_delay_: num, _callback_: @() => any): @() => void
188188
Calls the callback function after the specified time has elapsed.
189189
Returns a stop function as the return value.

0 commit comments

Comments
 (0)