@hazae41/stdbob 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/mods/console/mod.ts +2 -2
- package/src/mods/texts/mod.ts +10 -1
package/package.json
CHANGED
package/src/mods/console/mod.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { textref } from "../mod";
|
|
2
2
|
|
|
3
3
|
export namespace console {
|
|
4
4
|
|
|
5
5
|
// @ts-ignore: decorator
|
|
6
6
|
@external("console", "log")
|
|
7
|
-
export declare function log(message:
|
|
7
|
+
export declare function log(message: textref): void
|
|
8
8
|
|
|
9
9
|
}
|
package/src/mods/texts/mod.ts
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
|
-
import { blobref } from "../mod";
|
|
1
|
+
import { blobref, blobs } from "../mod";
|
|
2
2
|
|
|
3
3
|
export type textref = externref
|
|
4
4
|
|
|
5
5
|
export namespace texts {
|
|
6
6
|
|
|
7
|
+
export function from(string: string): textref {
|
|
8
|
+
const utf8 = String.UTF8.encode(string)
|
|
9
|
+
|
|
10
|
+
const blob = blobs.save(utf8)
|
|
11
|
+
const text = fromUtf8(blob)
|
|
12
|
+
|
|
13
|
+
return text
|
|
14
|
+
}
|
|
15
|
+
|
|
7
16
|
// @ts-ignore: decorator
|
|
8
17
|
@external("texts", "length")
|
|
9
18
|
export declare function length(text: textref): i32
|