muScript: document additional
ci/woodpecker/push/woodpecker Pipeline was successful
Details
ci/woodpecker/push/woodpecker Pipeline was successful
Details
This commit is contained in:
parent
5757e0055a
commit
0048a439fa
|
@ -70,7 +70,9 @@ public class StandardLib {
|
|||
.set("toObject", StandardLib::toObject)
|
||||
|
||||
.set("callableObject", StandardLib::callableObject)
|
||||
.set("enum", StandardLib::enum_);
|
||||
.set("enum", StandardLib::enum_)
|
||||
.set("keys", StandardLib::keys)
|
||||
.set("values", StandardLib::values);
|
||||
}
|
||||
|
||||
// Numbers
|
||||
|
@ -227,4 +229,14 @@ public class StandardLib {
|
|||
else if (args.size() == 2) return new DEnum(args.get(0).asObject().getValue(), args.get(1).asString().getValue());
|
||||
else throw new IllegalArgumentException("Invalid number of arguments for enum: expected 1 or 2 but got " + args.size());
|
||||
}
|
||||
|
||||
public static DList keys(DList args) {
|
||||
if (args.size() != 1) throw new IllegalArgumentException("Invalid number of arguments for keys: expected 1 but got " + args.size());
|
||||
return of(args.get(0).asObject().getValue().keySet().stream().map(DFinal::of).toList());
|
||||
}
|
||||
|
||||
public static DList values(DList args) {
|
||||
if (args.size() != 1) throw new IllegalArgumentException("Invalid number of arguments for values: expected 1 but got " + args.size());
|
||||
return of(args.get(0).asObject().getValue().values().stream().toList());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ Values of all other types can also be coerced into strings.
|
|||
|
||||
Equality operations are supported.
|
||||
|
||||
The StdLib comes with some additional functions, namely: `toUpper`, `toLower`, `contains` and `replace`
|
||||
The StdLib comes with some additional functions, namely: `len`, `toUpper`, `toLower`, `contains` and `replace`
|
||||
|
||||
<details>
|
||||
<summary>Example</summary>
|
||||
|
@ -106,7 +106,8 @@ Result:
|
|||
|
||||
You can read (but not write) the fields of objects via `.` or `[]`.
|
||||
|
||||
The StdLib also contains two objects, namely `date` and `time` which allow reading the current date and time.
|
||||
The StdLib comes with some additional functions, namely: `isEmpty`, `len`, `keys`, `values` and `contains`
|
||||
It also contains two objects, namely `date` and `time` which allow reading the current date and time.
|
||||
They also allow creating date/time objects and comparing them.
|
||||
|
||||
<details>
|
||||
|
@ -152,7 +153,7 @@ Result:
|
|||
Lists can be created with the stdlib function `listOf` (as seen in other examples).
|
||||
You can access their entries with `[]`, just like you would access fields for objects.
|
||||
In function calls, you can use the spread operator (`...`) to use all elements of the list as parameters.
|
||||
The StdLib also comes with some additional functions, namely `len`, `isEmpty`, `concat`, `filter`, `map`, `flatMap`, `fold` and `forEach`.
|
||||
The StdLib also comes with some additional functions, namely `len`, `contains`, `isEmpty`, `concat`, `filter`, `allMatch`, `anyMatch`, `map`, `flatMap`, `fold`, `forEach` and `toObject`.
|
||||
|
||||
<details>
|
||||
<summary>Example</summary>
|
||||
|
|
Loading…
Reference in New Issue