-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstubs.tis
More file actions
5340 lines (4556 loc) · 223 KB
/
stubs.tis
File metadata and controls
5340 lines (4556 loc) · 223 KB
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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Global functions
/**
Evaluates (interprets) input and returns its value. If input is a string then function tries to interpret it as if it contains script source code. If input is a stream object then it compiles and executes source code from it.
Example: after execution of the following:
var obj = eval( "({ one:1, two:2 })" );
variable obj will contain object having two fields: one and two.
environment is an environment object – if provided then script execution takes place in the namespace of that object.
var env = { one:1, two:2 };
var res = eval( "one + two", env);
After execution of two lines above variable res will contain integer 3.
environments is a list of objects – environments – element with index 0 is inmost environment.
These functions available only if host application configured the engine to use them.
* @param {String} input
* @param {object} namespace
* @param {String[]} namespaces
* @returns {any}
*/
declare function eval(input: String, namespace?: Object, namespaces?: String[]): any;
/**
a.k.a. JSON++ data parser.
Evaluates (interprets) data literal at the input and returns its value. Input shall contain valid data literal expression otherwise parsing exception will be thrown.
Example 1: after execution of the following:
var obj = parseData( " { one:1, two:2 } " );
variable obj will contain object having two fields: one and two.
Example 2: after execution of the following:
var v = parseData( "3.1415926" );
variable v will contain float number 3.1415926 – parsed value of the string.
Main difference from the eval function is that parseData will not parse and execute any function declarations or functions so it is safe to use this function when data is coming from unknown sources e.g. in AJAX like of interactions.
* @param {String} json
* @returns {any}
*/
declare function parseData(json: String): any;
/**
Evaluates the input stream in serverScript mode (see below) and emits result to the output stream. Function assumes that executable script at the input is contained in <% %> brackets. Function returns result of first standalone return statement in the input stream.
env is an environment object, it allows to pass parameters to the input script from the caller.
* @param {String | Stream} input
* @param {Stream} output
* @param {Object} env
* @returns {Object}
*/
declare function emit(input: String | Stream, output: Stream, env?: Object): any;
/**
Loads (compiles and executes) source. Source here either string – file name or stream object. If asServerScript provided and equals to true then source is interpreted as a text with embedded script like PHP or ASP web page:
<html> ... <% =some_script_function(); %>... </html>
These two fragments:
load( "c:/myscripts/test.tis" );
and
var s = Stream.openFile("c:/myscripts/test.tis","r"); load( s );
are equivalent.
Script execution takes place in the namespace of the caller of the function.
* @param {String} source
* @param {boolean} asServerScript
* @returns {boolean}
*/
declare function load(source: String, asServerScript?: boolean): boolean;
/**
Loads compiled bytecodes defined by source. Source here either string – file name or stream object.
* @param {String} source
* @returns {boolean}
*/
declare function loadbc(source: String): boolean;
/**
Calls built-in compiler to compile input. Writes output bytecodes into out stream or file. Bytecodes can be loaded (executed) later by loadbc function.
* @param {String | Stream} input
* @param {String | Stream} output
* @param {boolean} asServerScript
* @returns {boolean}
*/
declare function compile(input: String | Stream, output: String | Stream, asServerScript?: boolean): boolean;
/**
Stores the value into file filename or stream in binary form. Returns true if data was stored successfully.
* @param {String | Stream} location
* @param value
* @returns {boolean}
*/
declare function store(location: String | Stream, value: any): boolean;
/**
Restores value previously written into the file (filename) or stream by function store. Returns value or null if operation failed.
* @param {String | Stream} location
* @returns {any | null}
*/
declare function fetch(location: String | Stream): any | null;
/**
Returns hash value of its argument.
* @param {String} value
* @returns {Integer}
*/
declare function hash(value: String): Integer;
/**
Returns map (simple object) that has the same set of properties as the obj. Main purpose of membersOf is to be used in for( var (k,v) in membersOf(obj)) alike enumerations to scan properties of entities that have different semantic of enumeration than in instances of Object.
* @param {Object} obj
* @returns {Object}
*/
declare function membersOf(obj: Object): Object;
/**
Returns a random number between 0 and maxNumber-1.
* @param {Integer} maxNumber
* @returns {Integer}
*/
declare function rand(maxNumber: Integer): Integer;
/**
Parses the url string.
* @param {String} url
* @returns {ParsedUrl}
*/
declare function crackUrl(url: String): ParsedUrl;
/**
Function returns symbol of the string. Internally symbol is 32bit value so symbol space is limited – it makes no sense to "symbolize" arbitrary strings.
* @param {String} str
* @returns {symbol}
*/
declare function symbol(str: String): symbol;
/**
The color function constructs color value from red, green, blue and opacity components or by parsing colorStr that can be #RRGGBB or name of the CSS color.
* @param {Integer} r
* @param {Integer} g
* @param {Integer} b
* @param {Float} opacity
* @returns {Color}
*/
declare function color(r: Integer, g: Integer, b: Integer, opacity?: Float): Color;
declare function color(colorStr: String): Color;
/**
, these functions constructs length values of correspondent type.
* @param {Float} v
* @returns {Length}
*/
declare function em(v: Float): Length
declare function ex(v: Float): Length
declare function pr(v: Float): Length
declare function fx(v: Float): Length
declare function px(v: Float): Length
//declare function in(v: Float): Length
declare function cm(v: Float): Length
declare function mm(v: Float): Length
declare function pt(v: Float): Length
declare function pc(v: Float): Length
declare function dip(v: Float): Length
/**
* flex unit value
* @param {Float} v
* @returns {Length}
*/
declare function flex(v: Float): Length
/**
* constructs angle value from float number of radians
* @param {float} v
* @returns {Angle}
*/
declare function rad(v: Float): Angle;
/**
* constructs angle value from number of degrees
* @param {Float} v
* @returns {Angle}
*/
declare function deg(v: Float): Angle;
declare const JSON: JSON;
interface JSON {
/**
*
Produces canonical JSON string representation.
If the replacer is a function (key, value) then it gets called for each key / value pair. The function shall return JSON compatible value. If replacer is an array , only members with key values in the array will be converted. The order in which the members are converted is the same as the order of the keys in the array. The replacer array is ignored when the value argument is also an array.
If space is a string then all \t characters in output are replaced by that string. If it is a number then all \t characters get replaced by that number of spaces.
* @param {Object} value
* @param {Function | String[]} replacer
* @param {String | Integer} space
* @returns {String}
*/
stringify(value: Object, replacer?: (key: String, value: any) => any | String[], space?: String | Integer): String;
/**
Parses JSON string. The reviver is a function (key, value): value or function (key, value): (key,value) – allows to transform parsed into another value or key/value pair.
* @param {String} text
* @param {Function} reviver
* @returns {Object}
*/
parse(text: String, reviver?: (key: String, value: any) => any): Object;
}
declare const URL: URL;
interface URL {
/**
* The function parses url
* @param {String} url
* @returns {ParsedUrl}
*/
parse(url: String): ParsedUrl
/**
* Makes url relative to baseUrl. So for:
baseUrl: http://example.com/foo/bar.htm and
url : http://example.com/zar/laf.htm#location
the function returns ../zar/laf.htm#location
* @param {String} url
* @param {String} baseUrl
* @returns {String}
*/
relative(url: String, baseUrl: String): String;
/**
* The function combines relative URL with base (absolute) URL.
* @param {String} relUrl
* @param {String} baseUrl
* @returns {String}
*/
absolute(relUrl: String, baseUrl: String): String;
/**
* The function encodes all non-url characters, space for example will be replaced by %20 , etc.
* @param {String} str
* @returns {String}
*/
encode(str: String): String;
/**
* The function encodes all characters except the following: alphabetic, decimal digits, - _ . ! ~ * ' ( )
* @param {String} str
* @returns {String}
*/
encodeParam(str: String): String;
/**
* The function decodes URL encoded String to its original form.
* @param {String} str
* @returns {String}
*/
decode(str: String): String;
/**
* The function converts "file://..." string to a path to file – path string suitable for target platform.
* @param {String} fileUrl
* @returns {String}
*/
toPath(fileUrl: String): String;
/**
* The function converts path (like C:\User\Desktop) to file URL (like file://C:/User/Desktop).
* @param {String} path
* @returns {String}
*/
fromPath(path: String): String;
}
declare const Stream: StaticStream;
interface StaticStream {
/**
* Static method. Opens the file which name is stored in the file-name string and returns an instance of Stream object. Operations allowed to the stream returned are defined by the mode parameter-string.
Script engine uses C/C++ runtime for opening file streams. See fopen function definition for the meaning of the mode string.
* @param {String} fileName
* @param mode
* @returns {Stream | null}
*/
openFile(fileName: String, mode?: any): Stream | null;
/**
* Static method. Opens the socket stream which address and port is stored in the address-port string and returns an instance of Stream object. Opens socket stream in read-write mode. Address can be either domain name or IP address. Format of address:port string is "domain:NNN" or "NNN.NNN.NNN.NNN:NNN" where N is a decimal digit. timeout is a number of seconds to wait on any operations on this socket. If execution of operation on this socket will take more than this limit then exception will be thrown by runtime system.
numberOfAttempts is an integer – number of attempts to connect, 1 by default.
Example: following code will print out http server response of terrainformatica.com server:
var sock = Stream.openSocket( "www.terrainformatica.com:80" , 5 );
if( !sock ) return;
sock.println("GET http://www.terrainformatica.com/main.whtm HTTP/1.0");
sock.println("User-Agent: TIScript [en]");
sock.println("");
while( true )
{
var s = sock.readln();
if(s == undefined) break;
stdout.println(s);
}
* @param {String} addressPort
* @param {Integer} timeout
* @param {Integer} numberOfAttempts
* @returns {stream | null}
*/
openSocket(addressPort: String, timeout?: Integer, numberOfAttempts?: Integer): stream | null;
/**
* Static method. Opens in-memory string output stream with initialSize (integer) of its buffer. Use string streams when you plan to update some string frequently or compose string from many components. String streams are also known as StringBuffer/StringBuilder in Java or .NET. To get current content of the string stream use its method toString.
* @param {Integer} initialSize
* @returns {Stream}
*/
openString(initialSize?: Integer): Stream;
/**
*Creates so called pipe – stream used for inter-thread communications. Pipe is shared between two threads allowing two threads to communicate. See methods send(), post() and properties pending and proxy.
The receiver is the function that has following signature: function recv(value). This function will be called when data printed by print(), println() or printf() will arrive from other side of the pipe.
The proxy object is an object that is used as an interface with functions accessible from the alien thread (VM) sitting on other side of the pipe, See methods send() and post() below.
Example, following fragment (from ScIDE/facades.tis) creates three pipes that are used as stdin, stdout and stderr streams in the alien VM (other ScIDE window running is separate thread).
function receiverOut(data) { Log.print(data,false); }
function receiverErr(data) { Log.print(data,true); }
// callback interface
var iface =
{
foo: function(v1,v2) { stdout.printf("got a call of 'foo' with %V,%V\n",v1,v2); return v1 + v2; }
};
view.open(f,
Stream.openPipe( null, iface ), // call interface for the alien
Stream.openPipe( receiverOut ), // stdout
Stream.openPipe( receiverErr ) // stderr
);
* @param {String} initialValue
* @returns {Stream}
*/
openString(initialValue?: String): Stream;
}
declare const stdout: Stream;
declare const stderr: Stream;
interface Stream extends StaticStream {
/** reports if this is an input stream or not. */
readonly isInput: boolean;
/** reports if this is an output stream or not. */
readonly isOutput: boolean;
/** read only, true | false */
readonly isPipe: boolean;
/**
(Pipe only)
Gets/sets proxy object used as an interface of the thread for other thread – proxy of this thread on the remote side (other thread). Each instance of the pipe can have only one proxy object on either side of the pipe so duplex inter-thread communications require two pipe streams. */
proxy: Object | null;
/**
(Pipe only)
Returns number of pending requests (not processed at the moment) issued by post() and print**() methods. */
readonly pending: Integer;
/** gets/sets encoding used by the stream.
For now it supports either "none" (raw byte stream) and "utf-8" encodings. */
encoding: String;
/** Name of the stream – either file name or url where the data came from. Can be an empty string, e.g. for in memory streams. */
readonly name: String;
/**
* Returns content of string buffer if this is a string stream or name/address of the stream if it was open as file or socket stream.
* @returns {String}
*/
toString(): String;
/**
* Closes this stream – file, socket or string stream buffer. If returnString is true then return value is a result of toString() method.
* @param {boolean} returnString
* @returns {String | boolean}
*/
close(returnString?: boolean): String | boolean;
/**
*
Outputs string into the stream.
print is an equivalent of: stream << string; operation.
* @param {String} what
* @returns {boolean}
*/
print(what: String): boolean;
/**
* Stringizer method, outputs content in brackets into the stream.
* @param what
* @returns {boolean}
*/
$(what: any): boolean;
/**
* Outputs string appended by \r\n into the stream.
* @param {String} what
* @returns {boolean}
*/
println(what: String): boolean;
/**
* Stringizer method, outputs content in brackets appended by \r\n into the stream.
* @param what
* @returns {boolean}
*/
$n(what: any): boolean;
/**
*
Prints formatted text by the rules of printf C/C++ function.
Additional format types:
%v and %V – these format types accept any value as an argument and produce source code representation of the value suitable for later parsing by eval() method. Thus if value is an array of values it will be printed as "[element1, element2, element3… elementN]" and object (instance of Object class) will be printed as "{key1:value1, key2:value2,…, keyN:valueN}". %v produces one line output and %V tries to produce human readable output with line feeds and tabulations.
Use it if you need to serialize objects in AJAX/JSON fashion.
%S – this format type converts its argument into string and outputs it with HTML escapement. So characters like ‘<‘ will be converted to "<" sequences in the output.
* @param {String} format
* @param value
* @returns {boolean}
*/
printf(format: String, ...value: any[]): boolean;
/**
*
Scans the stream for values according to the rules of scanf C/C++ function with wildcard (like %[a-z] ) extensions. See definition of scanf in MSDN.
Additional format types:
%N – scans for either float or integer number.
Function returns array of successfully parsed values.
* @param {String} format
* @returns {any[]}
*/
scanf(format: String): any[];
/**
*
Outputs character into the stream. Character defined by its integer code.
putc is an equivalent of: stream << charcode; operation.
* @param {Integer} charCode
* @returns {boolean}
*/
putc(charCode: Integer): boolean;
/**
* Reads one character from the stream. Returns its code as integer or undefined if stream was closed or got EOF.
* @returns {Integer | null}
*/
getc(): Integer | null;
/**
* Reads sequence of characters from stream until ‘\n’ character. Returns string read without trailing ‘\r’ and ‘\n’.
* @returns {String | null}
*/
readln(): String | null;
/**
* Sends call request to the proxy interface object on other side of the pipe and waits its completion. Returns result of the remote method. Additional parameters that follow the methodName are passed to the call of remote method as normal parameters.
* @param {Symbol} methodName
* @param params
* @returns {any}
*/
send(methodName: Symbol, ...params: any[]): any;
/**
* Posts call request to the proxy interface object on other side of the pipe. This method does not wait for the completion of the remote method it just increases the pending counter. Additional parameters that follow the methodName are passed to the call of remote method as normal parameters.
* @param {Symbol} methodName
* @param params
* @returns {null}
*/
post(methodName: Symbol, ...params: any[]): null;
}
declare const Color: StaticColor;
interface StaticColor {
/**
* Static method (of the class), В constructs color value from red, green, blue and opacity components.
* @param {Integer} r
* @param {Integer} g
* @param {Integer} b
* @param {Integer | Float} opacity
* @returns {Color}
*/
rgba(r: Integer, g: Integer, b: Integer, opacity?: Integer | Float): Color;
/**
* Static method (of the class), В constructs the color from HSV values, see: http://en.wikipedia.org/wiki/HSL_color_space
* @param {Float | angle} hue
* @param {Float} saturation
* @param {Float} value
* @param {Integer | Float} opacity
* @returns {Color}
*/
hsv(hue: Float | angle, saturation: Float, value: Float, opacity?: Integer | Float): Color;
/**
* Static method (of the class), В constructs the color from HSL values, see: http://en.wikipedia.org/wiki/HSL_color_space
* @param {Float | angle} hue
* @param {Float} saturation
* @param {Float} lightness
* @param {Integer | Float} opacity
* @returns {Color}
*/
hsl(hue: Float | angle, saturation: Float, lightness: Float, opacity?: Integer | Float): Color;
/**
* Static method (of the class), В parses the string and constructs the color value. Supported formats:
"#RGB"
"#RRGGBB"
"rgb(r,g,b)"
"rgba(r,g,b,a)"
literal color names like: "yellow", "gold", "red", etc.
* @param {string} text
* @returns {Color}
*/
parse(text: string): Color;
}
interface Color extends StaticColor {
/** 0..255, red channel. */
readonly r: Integer;
/** 0..255, green channel. */
readonly g: Integer;
/** 0..255, blue channel. */
readonly b: Integer;
/** 0..255, alpha channel. */
readonly a: Integer;
/**
* Returns new color by setting hue component of the color in HSL color space, hue is either angle or float, degrees 0 .. 360.
* @param {Angle} hue
* @returns {Color}
*/
hue(hue: Angle): Color;
/**
* Returns new color by incrementing/decrementing hue component of the color in HSL color space by the given angle
* @param {Angle} hue
* @returns {Color}
*/
rotate(hue: Angle): Color;
/**
* Returns new color by setting lightness component of the color in HSL color space.
* @param {Float} lightness
* @returns {Color}
*/
lightness(lightness: Float): Color;
/**
* Returns new color by incrementing lightness component of the color in HSL color space.
* @param {Float} dl
* @returns {Color}
*/
lighten(dl: Float): Color;
/**
* Returns new color by decrementing lightness component of the color in HSL color space.
* @param {Float} dl
* @returns {Color}
*/
darken(dl: Float): Color;
/**
* Returns new color by setting saturation component of the color in HSL color space.
* @param {Float} saturation
* @returns {Color}
*/
saturation(saturation: Float): Color;
/**
* Returns new color by incrementing saturation component of the color in HSL color space.
* @param {Float} ds
* @returns {Color}
*/
saturate(ds: Float): Color;
/**
* Returns new color by decrementing saturation component of the color in HSL color space.
* @param {Float} ds
* @returns {Color}
*/
desaturate(ds: Float): Color;
/**
* Returns new color by changing alpha component of the color in RGBA color space.
* @param {Float} opacity
* @returns {Color}
*/
opacity(opacity: Float): Color;
/**
* Returns new color by incrementing/decrementing alpha component of the color in RGBA color space.
* @param {Float} delta
* @returns {Color}
*/
opacify(delta: Float): Color;
/**
* Returns new color by mixing the color with its pure grayscale version.
* @param {Float} ratio
* @returns {Color}
*/
grayscale(ratio: Float): Color;
/**
* Returns string representation of the color value according to the format provided by the symbol defining one of formats:
#RGB – outputs color as "#RRGGBB";
#rgb – outputs color as "rgb(r,g,b)" string;
#rgba – as "rgba(r,g,b,a)" string.
* @param {Symbol} symbol
* @returns {String}
*/
toString(symbol?: Symbol): String;
/**
* Converts the color to 32bit integer.
* @returns {Integer}
*/
toInteger(): Integer;
/**
* Returns three values – H,S, and V color components .
* @returns {MultipleReturnValue}
*/
toHSV(): MultipleReturnValue; //float,float,float
/**
* Returns three values – H,S, and L color components .
* @returns {MultipleReturnValue}
*/
toHSL(): MultipleReturnValue; //float,float,float
/**
* Computes the average color using the formula: (to - from) * ratio + from for each color component. Transformation is made in premultiplied color space.
* @param {Color} from
* @param {Color} to
* @param {float} ratio
* @returns {Color}
*/
morph(from: Color, to: Color, ratio: float): Color;
}
declare const Length: StaticLength;
interface StaticLength {
/**
* static method (method of the class), parses text for the length value. In case of parsing failure returns value defined by defval.
* @param {String} text
* @param {Length} defaultValue
* @returns {Length}
*/
parse(text: String, defaultValue?: Length): Length;
}
interface Length extends StaticLength {
/**
* static function, constructs length of correspondent value and the unit symbol (above).
* @param {Integer | Float} v
* @param {Symbol} units
* @returns {length}
*/
make(v: Integer | Float, units: Symbol): Length;
/**
* Returns string representation of the value, e.g. "12.5pt", "1px", etc.
* @returns {String}
*/
toString(): String;
/**
* Converts the length to integer.
* @returns {Integer}
*/
toInteger(): Integer;
/**
* Converts the length to float. If unit is provided and its value is one the units above then the result be float representation in that units. If conversion is not possible the defvalue is returned (or 0.0 if it is omitted)
* @param {Symbol} unit
* @param {Float} defaultValue
* @returns {float}
*/
toFloat(unit?: Symbol, defaultValue?: Float): Float;
/**
* Computes the average length using the formula: (lengthTo – lengthFrom) * ratio + lengthFrom;
* @param {Float} lengthFrom
* @param {Float} lengthTo
* @param ratio
* @returns {length}
*/
morph(lengthFrom: Float, lengthTo: Float, ratio): Length;
}
declare const Angle: StaticAngle;
interface StaticAngle {
parse(s: String): Angle
}
interface Angle {
/**
* Returns number of radians.
* @returns {Float}
*/
toFloat(): Float
/**
* Returns number of degrees.
* @returns {Integer}
*/
toInteger(): Integer
/**
* Returns "NNNrad" string where NNN is a number of radians.
* @returns {String}
*/
toString(): String
/**
* Computes the average angle using the formula: (to - from) * ratio + from.
* @param {Angle} from
* @param {Angle} to
* @param {Float} ratio
* @returns {Angle}
*/
morph(from: Angle, to: Angle, ratio: Float): Angle
}
interface Symbol {
}
interface MultipleReturnValue {
}
declare const Integer: StaticInteger;
interface StaticInteger {
/** minimal value of the Integer type. */
readonly MIN: Integer;
/** maximal value of the Integer type. */
readonly MAX: Integer;
/**
* Static method – returns minimum value of its arguments. E.g. Integer.min(1, 2, 3) will return 1.
* @param {Integer} values
* @returns {Integer}
*/
min(...values: Integer[]): Integer;
/**
* Static method – returns maximum value of its arguments. E.g. Integer.max(1, 2, 3) will return 3.
* @param {Integer} values
* @returns {Integer}
*/
max(...values: Integer[]): Integer;
}
interface Integer extends StaticInteger {
/**
* Converts this integer value to float.
* @returns {Float}
*/
toFloat(): Float;
/**
* Simply returns value of the integer.
* @returns {Integer}
*/
toInteger(): Integer;
/**
* Returns string representation of the integer using one of radix value: 10(default), 8 or 16.
* @param {Integer} radix
* @returns {String}
*/
toString(radix?: Integer): String;
/**
* Returns string escaped by html rules. Is an alias of the toString() method here.
* @param {Integer} radix
* @returns {String}
*/
toHtmlString(radix?: Integer): String;
/**
* Returns string escaped by url rules. Is an alias of the toString() method here.
* @param {Integer} radix
* @returns {String}
*/
toUrlString(radix?: Integer): String;
/**
* Simply returns value of the integer itself.
* @returns {Integer}
*/
valueOf(): Integer;
/**
* This is exactly the following:
function Integer.limit(min, max)
{
if( this < min ) return min;
if( this > max ) return max;
return this;
}
* @param {Integer} min
* @param {Integer} max
* @returns {Integer}
*/
limit(min: Integer, max: Integer): Integer;
}
declare const Float: StaticFloat;
interface StaticFloat {
/** minimal value of the float type. */
readonly MIN: Float;
/** maximal value of the float type. */
readonly MAX: Float;
/**
* Static method – returns minimum value of its arguments. E.g. Float.min(1.0, 2.0, 3.0) will return 1.
* @param {Float} values
* @returns {Float}
*/
min(...values: Float[]): Float;
/**
* Static method – returns maximum value of its arguments. E.g. Float.max(1.0, 2.0, 3.0) will return 3.0.
* @param {Float} values
* @returns {Float}
*/
max(...values: Float[]): Float;
}
interface Float extends StaticFloat {
/**
* Simply returns value of the float.
* @returns {Float}
*/
toFloat(): Float;
/**
* Converts this float value to integer.
* @returns {Number}
*/
toInteger(): int;
/**
* Returns string representation of the float.
* @returns {String}
*/
toString(): String;
/**
* Returns string escaped by html rules. Is an alias of the toString() method here.
* @returns {String}
*/
toHtmlString(): String;
/**
* Returns string escaped by url rules. Is an alias of the toString() method here.
* @returns {String}
*/
toUrlString(): String;
/**
* Simply returns value of the float itself.
* @returns {Float}
*/
valueOf(): Float;
/**
* Returns true if this float value appears to be not a number.
* @returns {boolean}
*/
isNaN(): boolean;
/**
* Returns true if this float value is a finite number.
* @returns {boolean}
*/
isFinite(): boolean;
/**
* Computes the average value using the formula: (to - from) * ratio + from;
* @param {Float} from
* @param {Float} to
* @param {Float} ratio
* @returns {Float}
*/
morph(from: Float, to: Float, ratio: Float): Float;
}
interface RegExp {
/** number of matches after last exec or match methods calls. */
length: Integer;
/** last inspected string. */
input: String;
/** source code of the regular expression – string this RegExp was build from. */
source: String;
/** character position where the first successful match begins in a searched string, read-only. */
readonly index: Integer;
/** character position where the next match begins in a searched string. */
lastIndex: Integer;
/** read-only, returns n-th matched fragment. Index is a zero based index, integer. */
readonly [i: number]: String | null;
/**
* Used for intitalization of new instance of RegExp object. regular-expresion is a string – source of the regular expression. В flags is an optional string and if provided may contain characters ‘i’ for case insensitive search and/or ‘g’ – for global search – to find all occurences of source in the input string.
Use this constructor as: var re = new RegExp(…);
* @param {RegExp | String} regex
* @param {String} flags
* @returns {RegExp}
*/
new(regex: RegExp | String, flags?: String): RegExp;
/**
* Checks input string to see if a pattern exists within a string and returns true if so, and false otherwise.
* @param input
* @returns {true | false}
*/
test(input): boolean;
/**
* Returns this RegExp object with length and list of matches set if pattern exists in input string or null otherwise.
* @param input
* @returns {RegExp | null}
*/
exec(input): null | RegExp;
/**
* Valid after the exec() call, returns pair of integers – start and end positions of matched sub-expressions in input string
* MultipleReturnValue: (start:integer, end:integer)
* @param {Integer} matchIdex
* @returns {MultipleReturnValue}
*/
positions(matchIdex: Integer): MultipleReturnValue;
}
interface ParsedUrl {
port: String;
protocol: String;
hostname: String;
anchor: String;
username: String;
password: String;
params: String;
dir: String;
name: String;
ext: String;
name_ext: String;
}
declare const Object: Object;
interface Object {
/** Name of the class if object was created as instance of user defined class. */