-
-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathfull.d.ts
264 lines (220 loc) · 5.66 KB
/
full.d.ts
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
@Constant
declare function debug_type_independent(t: any): void;
declare class Array<T> {
[index: number]: T | undefined;
length: number;
push(item: T) {
this[this.length] = item;
return ++this.length
}
pop(): T | undefined {
if (this.length === 0) {
return undefined
} else {
const value = this[--this.length];
delete this[this.length];
return value
}
}
// TODO this argument
map<U>(cb: (t: T, i?: number) => U): Array<U> {
const { length } = this, mapped: Array<U> = [];
let i: number = 0;
while (i < length) {
const value = this[i];
mapped.push(cb(value, i++))
}
return mapped;
}
// // TODO any is debatable
filter(cb: (t: T, i?: number) => any): Array<T> {
const { length } = this, filtered: Array<T> = [];
let i: number = 0;
while (i < length) {
const value = this[i];
if (cb(value, i++)) {
filtered.push(value)
}
}
return filtered;
}
// TODO any is debatable
find(cb: (t: T, i?: number) => any): T | undefined {
const { length } = this;
let i: number = 0;
while (i < length) {
const value = this[i];
if (cb(value, i++)) {
return value
}
}
}
// TODO any is debatable
every(cb: (t: T, i?: number) => any): boolean {
const { length } = this;
let i: number = 0;
while (i < length) {
const value = this[i];
if (!cb(value, i++)) {
return false
}
}
// Vacuous truth
return true
}
some(cb: (t: T, i?: number) => any): boolean {
const { length } = this;
let i: number = 0;
while (i < length) {
const value = this[i];
if (cb(value, i++)) {
return true
}
}
return false
}
// includes(searchElement: T, fromIndex?: number): boolean {
// const { length } = this;
// let i: number = fromIndex ?? 0;
// while (i < length) {
// const value = this[i++];
// if (value === searchElement) {
// return true
// }
// }
// return false
// }
join(joiner: string = ","): string {
const { length } = this;
let i: number = 1;
if (length === 0) {
return ""
}
let s: string = "" + this[0];
while (i < length) {
s += joiner;
s += this[i++];
// debug_type_independent(s)
}
return s
}
}
declare class Math {
@Constant
static sin(x: number): number;
@Constant
static cos(x: number): number;
@Constant
static tan(x: number): number;
@Constant
static floor(x: number): number;
@Constant
static sqrt(x: number): number;
@Constant
static cbrt(x: number): number;
// TODO newer method
@Constant
static trunc(x: number): number;
static PI: 3.141592653589793
}
@Primitive("string")
declare class String {
[index: number]: string | undefined;
@Constant
toUpperCase(): string;
@Constant
toLowerCase(): string;
get length(): number;
// TODO
slice(start: number, end?: number): string;
// TODO
split(splitter: string): Array<string>;
}
declare class Promise<T> { }
interface Response {
ok: boolean;
json(): Promise<any>;
}
declare class Console {
@InputOutput
log(msg: any): void;
}
declare const console: Console;
declare class JSON {
// TODO any temp
parse(input: string): any;
// TODO any temp
stringify(input: any): string;
}
declare class Function {
bind(this_ty: any): Function;
}
declare class Symbols {
// TODO temp
iterator: 199
}
declare class Object {
@Constant
static setPrototypeOf(on: object, to: object): object;
@Constant
static getPrototypeOf(on: object): object | null;
// create(prototype: object): object performs {
// const n = {};
// Object.setProtoTypeOf(n, prototype);
// return n
// }
// keys(on: object): Array<string> performs {
// const array = [];
// for (const key in on) {
// array.push(key);
// }
// return array
// }
}
// TODO wip
declare function JSXH(tag: string, attributes: any, children?: any) {
return { tag, attributes, children }
}
interface Document {
title: string
}
interface FormData {
}
// TODO temp
@InputOutput
declare function fetch(from: string): Promise<Response>;
@client
declare const document: Document;
// @server
// declare function createItem(a: any);
// ↓↓ Ezno testing functions ↓↓
@Constant
declare function print_type(t: any): void;
@Constant
declare function debug_type(t: any): void;
@Constant
declare function print_and_debug_type(t: any): void;
@Constant
declare function debug_type_rust(t: any): void;
@Constant
declare function debug_type_rust_independent(t: any): void;
@Constant
declare function debug_effects_rust(t: () => {}): void;
@Constant
declare function debug_effects(t: () => {}): void;
@Constant
declare function is_dependent(t: any): void;
@Constant
declare function print_environment_state<T>(): any;
@Constant
declare function debug_context(): void;
@Constant
declare function context_id(): void;
@Constant
declare function context_id_chain(): void;
// A function, as it should be!
@Constant
declare function satisfies<T>(t: T): T;
@Constant
declare function compile_type_to_object<T>(): any;
// ↑↑ Ezno Functions ↑↑