/
index.d.ts
747 lines (561 loc) · 21.3 KB
/
index.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
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
// Copyright 2015-2021 JC Fisher
// Contains type definitions for typescript users.
export declare enum basisOptions {
US = 0,
Actual,
Actual360,
// Copyright 2015-2021 JC Fisher
Actual365,
European
}
export declare enum roundingMode {
Floor = 0,
Ceiling = 1
}
export declare enum paymentTiming {
End = 0,
Beginning = 1
}
export declare enum months {
Jan = 1,
Feb = 2,
Mar = 3,
Apr = 4,
May = 5,
Jun = 6,
Jul = 7,
Aug = 8,
Sep = 9,
Oct = 10,
Nov = 11,
Dec = 12
}
export declare enum dateUnits {
Years = "Y",
Months = "M",
Weeks = "W",
Days = "D",
DaysIgnoringMonthsAndYears = "MD",
MonthsIgnoringDaysandYears = "YM",
DaysIgnoringYears = "YD"
}
export declare enum matchType {
GreaterThan = -1,
Exact = 0,
LessThan = 1
}
/** Compute absolute value */
export function abs(value: number): number;
/** Compute absolute value */
export function accrint(
issue: string | Date,
first: string | Date,
settlement: string | Date,
rate: number,
par: number,
frequency: number,
basis: basisOptions
): number;
/** Compute the inverse cosine of a number */
export function acos(value: number): number;
/** Compute the hyperbolic inverse cosine of a value. */
export function acosh(value: number): number;
/** Compute the arccotangent of a given number. */
export function acot(value: number): number;
/** Compute the arccotangent of a given number. */
export function acoth(value: number): number;
/** Compute sum of a and b. */
export function add(a: number, b: number): number;
/** Converts a row and column into an address. */
export function address(
row: string,
col: string,
absolute_relative_mode?: number,
use_a1_notation?: boolean,
sheet?: string
): string;
/** Reduces list of truthy values into true or false value. */
export function and(...criteria: Array<boolean | Function>): boolean;
/** Compute the inverse sin of a given number. */
export function asin(value: number): number;
/** Compute the inverse hyperbolic sin of a given number. */
export function asinh(value: number): number;
/** Assign properties from a list of objects into the initial object. */
export function assign(initial: object, ...list: Array<object>): number;
/** Compute the arctangent (in radians) of the given number. */
export function atan(value: number): number;
/** Compute the arctangent (in radians) of x and y. */
export function atan2(x: number, y: number): number;
/** Compute the inverse arctangent (in radians) of the given number */
export function atanh(x: number): number;
/** Compute the average of a list of numbers. */
export function average(...items: Array<number>): number;
/** Convert a number into a text representation with the given radix. */
export function base(
number: number,
radix: number,
min_length?: number
): string;
/** Converts binary string into decimal value. */
export function bin2dec(value: string): number;
/** Functional equivalent to if-elseif-else. */
export function branch(...cases: Array<any>): boolean;
/** Convert snakecase to camelcase. */
export function camelcase(value: string): string;
/** Compute number rounded up, away from zero, to the nearest multiple of significance. */
export function ceiling(
number: number,
significance: number,
mode?: roundingMode
): number;
/** Computes row and column in a location in a flat array. */
export function cellindex(row: number, col: number): number;
/** Computes the list of keys that are different between two objects. */
export function changed(a: object, b: object): object;
/** Compile a formula expression into a function. */
export function compile(exp: string): Function;
/** Convert an ascii code into a string. */
export function char(number: number): string;
/** Return the item that corresponds to the index. */
export function choose(index: number, ...items: Array<any>): any;
/** Compute object with blank properties removed. */
export function clean(obj: object): object;
/** Return the character code for a character in a string, optionally specify an index. */
export function code(text: string, index: number): string;
/** Convert column letter into number. */
export function columnletter(letter: string): number;
/** Convert column number into letter. */
export function columnnumber(number: number): string;
/** Compile multiple strings into a one. */
export function concatenate(
...values: Array<string | number | boolean>
): string;
/** Compute the cosine of a value. */
export function cos(value: number): number;
/** Compute the cumulative interest paid on a loan between start_period and end_period. */
export function cumipmt(
rate: number,
periods: number,
value: number,
start_period: number,
end_period: number,
type: paymentTiming
): number;
/** Compute the serial number given a year, month and day. */
export function date(year: number, month: months, day: number): number;
/** Compute the difference between two dates given a start date, end date and unit. */
export function datedif(
start_date: number | string | Date,
end_date: number | string | Date,
unit: dateUnits
): number;
/** Compute serial number. */
export function datevalue(d: number | string | Date): number;
/** Return day of month. */
export function day(d: number | string | Date): number;
/** Return number of days between 2 dates based on a 360 day year. */
export function days360(
start_date: number | string | Date,
end_date: number | string | Date,
method?: boolean
);
/** Convert a decimal number into a binary number. */
export function dec2bin(input: number, places?: number): string;
/** Decode a base64 encoded string. */
export function decodebase64(str: string): string;
/** Decode metadata in JSON Web Token. */
export function decodejwt(token: string): object;
/** Converts radians into degrees. */
export function degrees(radians: number): number;
/** Convert differences between two objects */
export function diff(a: object, b: object): object;
/** Compute the product of two numbers. */
export function divide(numerator: number, denominator: number): number;
/** Compute the serial number for a date that is a given number of months before or after a given date. */
export function edate(
start_date: number | string | Date,
months: number
): number;
/** Compute the last day of the month in future or past months. */
export function eomonth(start_date: number | string | Date, months);
/** Compare two values with case insensitivity for strings. */
export function eq(a: any, b: any): boolean;
/** Compute number rounded up to the nearest even integer. */
export function even(number: number): number;
/** Compare two values with strict equivalence. */
export function exact(a: any, b: any): boolean;
/** Filter a range with one or more filters. */
export function filter(
range: Array<object | Array<any>>,
...filters: Array<Array<boolean> | Function | string>
): Array<object | Array<any>>;
/** Search for index of text within a string, optionally starting after position. */
export function find(
find_text: string,
within_text: string,
position?: number
): number;
/** Convert nested array into flat array. */
export function flatten(ref: Array<any>): Array<any>;
/** Compute a number rounded down to a specified significance. */
export function floor(value: number, significance?: number): number;
/** Compute future value. */
export function fv(
rate: number,
periods: number,
payment: number,
value?: number,
type?: number
): number;
/** Pluck property from object. */
export function get(property: string, object: object): any;
/** Group a list of objects by one or more fields. */
export function group(list: Array<any>, ...fields: Array<string>): object;
/** Compute if a is greater than b. */
export function gt(a: any, b: any): boolean;
/** Compute if a is greater than or equal to b. */
export function gte(a: any, b: any): boolean;
/** Compute a v4 globally unique identifier. */
export function guid(): string;
/** Find a needle in a table searching horizontally. */
export function hlookup(
needle: any,
table: Array<any>,
index?: number,
exactmatch?: boolean
);
/** Compute the hours from a value between 0 and 1; or from date. */
export function hour(value: number | Date): number;
/** Return value when non-blank or value_if_blank. */
export function ifblank(value: any, value_if_blank: any): any;
/** Return value when non-empty or value_if_empty. */
export function ifempty(value: any, value_if_empty: any): any;
/** Return value when non-error or value_if_error. */
export function iferror(value: any, value_if_error: any): any;
/** Return value when not #!NA or value_if_na. */
export function ifna(value: any, value_if_na: any): any;
/** Return true when searchElement is present in searchList. */
export function includes(
searchElement: any,
searchList: Array<any>,
fromIndex?: number
): boolean;
/** Compute index of the reference in a row and column from a 2d array */
export function index(
reference: Array<any>,
row_num: number,
column_num?: number
): any;
/** Computes the column number a cell index. */
export function index2col(index: number): number;
/** Computes the row number a cell index. */
export function index2row(index: number): number;
/** Convert a number into an integer. */
export function int(value: number): number;
/** Compute the portion of the periodic payment which is interest for a fixed rate loan or annuity. */
export function ipmt(
rate: number,
period: number,
periods: number,
present: number,
future?: number,
type?: number
): number;
/** Return true when value is an array. */
export function isarray(value: any): boolean;
/** Return true when value is a binary string. */
export function isbinary(value: string): boolean;
/** Return true when value is blank (null or undefined). */
export function isblank(value: any): boolean;
/** Return true when value is boolean. */
export function isboolean(value: any): boolean;
/** Return true when value is boolean. */
export function isboolean(value: any): boolean;
/** Return true when value is a Date. */
export function isdate(value: any): boolean;
/** return true when value is a valid email. */
export function isemail(value: string): boolean;
/** Return true when value is empty (null, undefined, blank string or empty with 0 length). */
export function isempty(value: any): boolean;
/** Return true when value is error except #NA!. */
export function iserr(value: any): boolean;
/** Return true when any value is error. */
export function iserror(...values: Array<any>): boolean;
/** Return true when value is even. */
export function iseven(value: number): boolean;
/** Return true when value is falsy. */
export function isfalsy(value: any): boolean;
/** Return true when value is a function. */
export function isfunction(value: any): boolean;
/** Return true when value is a date in a leapyear. */
export function isleapyear(value: number | string | Date): boolean;
/** Return true when value is all lowercase. */
export function islowercase(value: string): boolean;
/** Return true when value is error #NA!. */
export function isna(value: any): boolean;
/** Return true when value is NaN. */
export function isnan(value: any): boolean;
/** Return true when value is a number. */
export function isnumber(value: any): boolean;
/** Return true when value is an object. */
export function isobject(value: any): boolean;
/** Return true when value is odd. */
export function isodd(value: number): boolean;
/** Compute number of the ISO week number of the year for a given date. */
export function isoweeknum(date: number | string | Date): number;
/** Return true when value is a reference. */
export function isref(value: any): boolean;
/** Return true when value is text. */
export function istext(value: any): boolean;
/** Return true when value is truthy. */
export function istruthy(value: any): boolean;
/** Return true when value is all uppercase. */
export function isuppercase(value: string): boolean;
/** Return true when value is a valid url. */
export function isurl(value: string): boolean;
/** Return true when value is a whole number. */
export function iswholenumber(value: number): boolean;
/** Join a list of values into a string with a delimiter, defaults to ", ". */
export function join(list: Array<number | string>, delim?: string): string;
/** Return list of properties in an object. */
export function keys(subject: object): Array<string>;
/** Return left most `text` truncated to `number` of characters. */
export function left(text: string, number: number): string;
/** Return length of text or list. */
export function len(text: string | Array<any>): number;
//** Lookup value from an array. */
export function lookup(
lookup_value: any,
lookup_array: Array<any>,
results_vector?: Array<any>
): any;
/** Convert `value` to lower case. */
export function lower(value: string): string;
/** Compute if a is less than b. */
export function lt(a: any, b: any): boolean;
/** Compute if a is less than or equal to b. */
export function lte(a: any, b: any): boolean;
/** Map each value in the `list` with `func`. */
export function map(list: Array<any>, func: Function): Array<any>;
/** Return the index in `lookup_array` by searching for `lookup_value`. */
export function match(
lookup_value: any,
lookup_array: Array<any>,
matchType?: matchType
);
/** Return largest value from `list`. */
export function max(...list: Array<number>): number;
/** Merge objects from setA and setB with corresponding indexes. */
export function merge(setA: Array<object>, setB: Array<object>): Array<object>;
/** Return smallest value from `list`. */
export function min(...list: Array<number>): number;
/** Invert the `value`. */
export function minus(value: number): number;
/** Compute the minutes from a value between 0 and 1; or from a date. */
export function minute(value: number | Date): number;
/** Compute the remainder of division. */
export function mod(number: number, divisor: number): number;
/** Compute the month of a `date`. */
export function month(date: number | string | Date): number;
/** Compute product of a and b. */
export function multiply(a: number, b: number): number;
/** Convert `value` into a number. */
export function n(value: any): number;
/** Return true when at least one value is false. */
export function nand(...criteria: Array<boolean | Function>): boolean;
/** Return true when a and b are not equal. */
export function ne(a: any, b: any): boolean;
/** Return true when all values are true or all values are false. */
export function nor(...criteria: Array<boolean | Function>): boolean;
/** Negate `value`. */
export function not(value: boolean | number): boolean;
/** Return true when searchElement is not present in searchList. */
export function notincludes(
searchElement: any,
searchList: Array<any>,
fromIndex?: number
): boolean;
/** Return serial number for current time. */
export function now(value: boolean | number): boolean;
/** Return the number of periods for an investment. */
export function nper(
rate: number,
pmt: number,
pv: number,
fv?: number,
type?: number
): number;
/** Compute the net present value of an investment. */
export function npv(rate: number, ...values: Array<number>): number;
// Filters non-numeric values from `values`.
export function numbers(...values: Array<any>): Array<number>;
/** Convert a text value into a number value. */
export function numbervalue(
text: string,
decimal_separator?: string,
group_separator?: string
): number;
/** Convert an octal value into a decimal value. */
export function oct2dec(octalNumber: string): number;
/** Return true when any of the values are true or 1. */
export function or(...criteria: Array<any>): boolean;
/** Parse `exp` into an abstract syntax tree. */
export function parse(exp: string): object;
/** Convert `value` into a boolean. */
export function parsebool(value: any): boolean;
/** Convert `value` into a date. */
export function parsedate(value: any): Date;
/** Convert `queryString` into an object. */
export function parsequery(queryString: any): object;
/** Return PI. */
export function pi(): number;
/** Pluck a property from a list of objects. */
export function pluck(prop: string, list: Array<object>): Array<any>;
/** Convert `value` to number. */
export function plus(value: number): number;
/** Compute a loan payment */
export function pmt(
rate: number,
periods: number,
present: number,
future?: number,
type?: number
): number;
/** Compute the power of `value` to the `nth`. */
export function power(value: number, nth: number): number;
/** Convert text into proper case. */
export function proper(text: string): string;
/** Compute present value. */
export function pv(
rate: number,
periods: number,
payment: number,
future?: number,
type?: number
): number;
/** Execute a `query` against `data`. */
export function query(data: Array<any>, query: object): Array<any>;
/** Reduce an array to a value with `func`. */
export function reduce(
arr: Array<any>,
func: Function,
...rest: Array<any>
): any;
/** Create a reference object with `top` left and `bottom` right. */
export function ref(top: number | Function, bottom: number | Function): object;
/** Replace `num_chars` at `start` in `text` with `new_text`. */
export function replace(
text: string,
start: number,
num_chars: number,
new_text: string
): string;
/** Repeat `text` a `number` of times. */
export function rept(text: string, number: number): string;
/** Return right most `text` truncated to `number` of characters. */
export function right(text: string, number: number): string;
/** Round `value` to a fixed `precision`. */
export function round(value: number, precision: number): number;
/** Round up `value` to a fixed `precision`. */
export function roundup(value: number, precision: number): number;
/** Execute a formula `exp` with `params`. */
export function run(exp: string, params: object): any;
/** Search for `find_text` in `within_text` with wildcards ?, \*, ~?, and ~\*. */
export function search(
find_text: string,
within_text: string,
position?: number
): number;
/** Compute the seconds from a value between 0 and 1; or from date. */
export function second(value: number | Date): number;
/** Select fields from object or array of objects. */
export function select(
fields: string | Array<string>,
object: object | Array<object>
): object | Array<object>;
/** Convert date into serial number. */
export function serial(date: Date): number;
/** Compute sin of value. */
export function sin(value: number): number;
/** Convert pascal case to snake case. */
export function snakecase(value: string): string;
/** Return true when needle found in list. */
export function some(needle: any, list: Array<any>): boolean;
/** Sort data with criteria of ordered pairs (field, asc, ...). */
export function sort(
data: Array<any>,
...criteria: Array<string | number | boolean>
): Array<any>;
/** Split `text` with `delimiter`. */
export function split(text: string, delimiter: string): Array<string>;
/** Substitute `old_text` in `text` with `new_text`, optionally only 1 `occurence`. */
export function substitute(
text: string,
old_text: string,
new_text: string,
occurrence?: number
): string;
/** Lightweight template engine. */
export function substituteAll(
content: string,
locals: object,
startToken?: string,
endToken?: string
);
/** Compute the difference of two numbers. */
export function subtract(a: number, b: number): number;
/** Sum a list of `numbers`. */
export function sum(...numbers: Array<number>): number;
/** Append/prepend character to keys of subject. */
export function surroundKeys(
subject: object,
start?: string,
end?: string
): object;
/** Search the odd args and return even value when odd arg equals targetValue. */
export function SWITCH(targetValue: any, ...args: Array<any>): any;
/** Compute the tagent of a value. */
export function tan(value: number): number;
/** Compute tau (pi * 2) */
export function tau(): number;
/** Format number. */
export function text(
value: number,
format: string,
currency_char: string
): string;
/** Compute time fraction with hour, minute and second. */
export function time(hour: number, minute: number, second: number): number;
/** Compute time fraction with time string. */
export function timevalue(time: string): number;
/** Return serial number for current date. */
export function today(): number;
/** Remove whitespace from beginning and end of `text`. */
export function trim(text: string): string;
/** Drop decimal from number. */
export function trunc(value: number): number;
/** Nest array with given `length`. */
export function unflatten(list: Array<any>, length?: number): Array<any>;
/** Compute unique values in list. */
export function unique(list: Array<any>): Array<any>;
/** Convert text to upper case. */
export function upper(text: string): string;
/** Find a needle in a table searching vertically. */
export function vlookup(
needle: any,
table: Array<any>,
index?: number,
exactmatch?: boolean
): any;
/** Create walker function with config. */
export function walker(config): Function;
/** Compute the exclusive or for a given set of `values`. */
export function xor(...values: Array<any>): boolean;
/** Parse year out of date. */
export function year(date: string | number | Date): number;
/** Compute the fraction of a year between two dates. */
export function yearfrac(
start_date: string | number | Date,
end_date: string | number | Date,
basis?: basisOptions
): number;