@hazae41/stdbob 0.0.11 → 0.0.13

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@hazae41/stdbob",
4
- "version": "0.0.11",
4
+ "version": "0.0.13",
5
5
  "description": "Standard libraries for Bobine WebAssembly VM",
6
6
  "repository": "github:hazae41/stdbob",
7
7
  "author": "hazae41",
@@ -1,18 +1,9 @@
1
- import { blobref } from "../blobs/mod";
2
1
  import { textref } from "../texts/mod";
3
2
 
4
3
  export type bigintref = externref
5
4
 
6
5
  export namespace bigints {
7
6
 
8
- // @ts-ignore: decorator
9
- @external("bigints", "identity")
10
- export declare function from(bigint: i64): bigintref
11
-
12
- // @ts-ignore: decorator
13
- @external("bigints", "identity")
14
- export declare function into(bigint: bigintref): i64
15
-
16
7
  // @ts-ignore: decorator
17
8
  @external("bigints", "zero")
18
9
  export declare function zero(): bigintref
@@ -85,14 +76,6 @@ export namespace bigints {
85
76
  @external("bigints", "pow")
86
77
  export declare function pow(left: bigintref, right: bigintref): bigintref
87
78
 
88
- // @ts-ignore: decorator
89
- @external("bigints", "encode")
90
- export declare function encode(bigint: bigintref): blobref
91
-
92
- // @ts-ignore: decorator
93
- @external("bigints", "decode")
94
- export declare function decode(blob: blobref): bigintref
95
-
96
79
  // @ts-ignore: decorator
97
80
  @external("bigints", "from_base16")
98
81
  export declare function fromBase16(text: textref): bigintref
@@ -100,6 +83,7 @@ export namespace bigints {
100
83
  // @ts-ignore: decorator
101
84
  @external("bigints", "to_base16")
102
85
  export declare function toBase16(bigint: bigintref): textref
86
+
103
87
  // @ts-ignore: decorator
104
88
  @external("bigints", "from_base10")
105
89
  export declare function fromBase10(text: textref): bigintref
@@ -108,4 +92,12 @@ export namespace bigints {
108
92
  @external("bigints", "to_base10")
109
93
  export declare function toBase10(bigint: bigintref): textref
110
94
 
95
+ // @ts-ignore: decorator
96
+ @external("bigints", "identity")
97
+ export declare function fromInt64(bigint: i64): bigintref
98
+
99
+ // @ts-ignore: decorator
100
+ @external("bigints", "identity")
101
+ export declare function toInt64(bigint: bigintref): i64
102
+
111
103
  }
@@ -1,13 +1,13 @@
1
- import { blobref } from "../blobs/mod";
1
+ import { packref, textref } from "../mod";
2
2
 
3
3
  export namespace storage {
4
4
 
5
5
  // @ts-ignore: decorator
6
6
  @external("storage", "get")
7
- export declare function get(key: blobref): blobref;
7
+ export declare function get(key: textref): packref;
8
8
 
9
9
  // @ts-ignore: decorator
10
10
  @external("storage", "set")
11
- export declare function set(key: blobref, value: blobref): void;
11
+ export declare function set(key: textref, value: packref): void;
12
12
 
13
13
  }
@@ -4,24 +4,6 @@ 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
-
16
- export function into(text: textref): string {
17
- const blob = toUtf8(text)
18
- const utf8 = blobs.load(blob)
19
-
20
- const string = String.UTF8.decode(utf8)
21
-
22
- return string
23
- }
24
-
25
7
  // @ts-ignore: decorator
26
8
  @external("texts", "length")
27
9
  export declare function length(text: textref): i32
@@ -62,4 +44,22 @@ export namespace texts {
62
44
  @external("texts", "trim")
63
45
  export declare function trim(text: textref): textref
64
46
 
47
+ export function fromString(string: string): textref {
48
+ const utf8 = String.UTF8.encode(string)
49
+
50
+ const blob = blobs.save(utf8)
51
+ const text = fromUtf8(blob)
52
+
53
+ return text
54
+ }
55
+
56
+ export function toString(text: textref): string {
57
+ const blob = toUtf8(text)
58
+ const utf8 = blobs.load(blob)
59
+
60
+ const string = String.UTF8.decode(utf8)
61
+
62
+ return string
63
+ }
64
+
65
65
  }