forked from andrewplummer/Sugar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sugar.d.ts
1235 lines (1182 loc) · 72.4 KB
/
sugar.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
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
// Type definitions for Sugar edge
// Project: https://sugarjs.com/
// Definitions by: Andrew Plummer <[email protected]>
declare namespace sugarjs {
type SugarDefaultChainable<RawValue> = Array.Chainable<any, RawValue> &
Date.Chainable<RawValue> &
Function.Chainable<RawValue> &
Number.Chainable<RawValue> &
Object.Chainable<RawValue> &
RegExp.Chainable<RawValue> &
String.Chainable<RawValue>;
type NativeConstructor = ArrayConstructor |
DateConstructor |
FunctionConstructor |
NumberConstructor |
ObjectConstructor |
RegExpConstructor |
StringConstructor |
BooleanConstructor |
ErrorConstructor;
interface Locale {
addFormat(src:string, to?: Array<string>): void;
getDuration(ms: number): string;
getFirstDayOfWeek(): number;
getFirstDayOfWeekYear(): number;
getMonthName(n: number): string;
getWeekdayName(n: number): string;
}
interface ExtendOptions {
methods?: Array<string>;
except?: Array<string|NativeConstructor>;
namespaces?: Array<NativeConstructor>;
enhance?: boolean;
enhanceString?: boolean;
enhanceArray?: boolean;
objectPrototype?: boolean;
}
interface Sugar {
(opts?: ExtendOptions): Sugar;
createNamespace(name: string): SugarNamespace;
extend(opts?: ExtendOptions): Sugar;
Array: Array.Constructor;
Date: Date.Constructor;
Function: Function.Constructor;
Number: Number.Constructor;
Object: Object.Constructor;
RegExp: RegExp.Constructor;
String: String.Constructor;
}
interface Range {
clamp<T>(el: T): T;
clone(): sugarjs.Range;
contains<T>(el: T): boolean;
days(): number;
every<T>(amount: string|number, everyFn?: (el: T, i: number, r: sugarjs.Range) => void): T[];
hours(): number;
intersect(range: sugarjs.Range): sugarjs.Range;
isValid(): boolean;
milliseconds(): number;
minutes(): number;
months(): number;
seconds(): number;
span(): number;
toArray<T>(): T[];
toString(): string;
union(range: sugarjs.Range): sugarjs.Range;
weeks(): number;
years(): number;
}
interface SugarNamespace {
alias(toName: string, from: string|Function): this;
alias(toName: string, fn: undefined): this;
defineInstance(methods: Object): this;
defineInstance(methodName: string, methodFn: Function): this;
defineInstanceAndStatic(methods: Object): this;
defineInstanceAndStatic(methodName: string, methodFn: Function): this;
defineInstancePolyfill(methods: Object): this;
defineInstancePolyfill(methodName: string, methodFn: Function): this;
defineInstanceWithArguments(methods: Object): this;
defineInstanceWithArguments(methodName: string, methodFn: Function): this;
defineStatic(methods: Object): this;
defineStatic(methodName: string, methodFn: Function): this;
defineStaticPolyfill(methods: Object): this;
defineStaticPolyfill(methodName: string, methodFn: Function): this;
defineStaticWithArguments(methods: Object): this;
defineStaticWithArguments(methodName: string, methodFn: Function): this;
extend(opts?: ExtendOptions): this;
}
namespace Array {
type mapFn<T, U> = (el: T, i: number, arr: T[]) => U;
type sortMapFn<T, U> = (el: T) => U;
type searchFn<T> = (el: T, i: number, arr: T[]) => boolean;
type Chainable<T, RawValue> = ChainableBase<T, RawValue> & Object.ChainableBase<RawValue>;
interface ArrayOptions {
sortIgnore?: RegExp;
sortIgnoreCase?: boolean;
sortNatural?: boolean;
sortOrder?: string;
sortEquivalents?: Object;
sortCollate?: Function;
}
interface Constructor extends SugarNamespace {
<T>(obj?: number|ArrayLike<T>, clone?: boolean): Chainable<T, T[]>;
new<T>(obj?: number|ArrayLike<T>, clone?: boolean): Chainable<T, T[]>;
construct<T>(n: number, indexMapFn: (i: number) => T): T[];
create<T>(obj?: number|ArrayLike<T>, clone?: boolean): T[];
add<T>(instance: T[], item: T|T[], index?: number): T[];
append<T>(instance: T[], item: T|T[], index?: number): T[];
at<T>(instance: T[], index: number|number[], loop?: boolean): T;
average<T, U>(instance: T[], map?: string|mapFn<T, U>): number;
clone<T>(instance: T[]): T[];
compact<T>(instance: T[], all?: boolean): T[];
count<T>(instance: T[], search: T|searchFn<T>, context?: any): number;
every<T>(instance: T[], search: T|searchFn<T>, context?: any): boolean;
everyFromIndex<T>(instance: T[], startIndex: number, loop?: boolean, ...args: any[]): T;
everyFromIndex<T>(instance: T[], startIndex: number, ...args: any[]): T;
exclude<T>(instance: T[], search: T|searchFn<T>): T[];
filter<T>(instance: T[], search: T|searchFn<T>, context?: any): T[];
filterFromIndex<T>(instance: T[], startIndex: number, loop?: boolean, ...args: any[]): T;
filterFromIndex<T>(instance: T[], startIndex: number, ...args: any[]): T;
find<T>(instance: T[], search: T|searchFn<T>, context?: any): T;
findFromIndex<T>(instance: T[], startIndex: number, loop?: boolean, ...args: any[]): T;
findFromIndex<T>(instance: T[], startIndex: number, ...args: any[]): T;
findIndex<T>(instance: T[], search: T|searchFn<T>, context?: any): number;
findIndexFromIndex<T>(instance: T[], startIndex: number, loop?: boolean, ...args: any[]): T;
findIndexFromIndex<T>(instance: T[], startIndex: number, ...args: any[]): T;
first<T>(instance: T[], num?: number): T;
flatten<T>(instance: T[], limit?: number): T[];
forEachFromIndex<T>(instance: T[], startIndex: number, loop?: boolean, ...args: any[]): T;
forEachFromIndex<T>(instance: T[], startIndex: number, ...args: any[]): T;
from<T>(instance: T[], index: number): T[];
groupBy<T, U>(instance: T[], map: string|mapFn<T, U>, groupFn?: (arr: T[], key: string, obj: Object) => void): Object;
inGroups<T>(instance: T[], num: number, padding?: any): T[];
inGroupsOf<T>(instance: T[], num: number, padding?: any): T[];
insert<T>(instance: T[], item: T|T[], index?: number): T[];
intersect<T>(instance: T[], arr: T[]): T[];
isEmpty<T>(instance: T[]): boolean;
isEqual<T>(instance: T[], arr: T[]): boolean;
last<T>(instance: T[], num?: number): T;
least<T, U>(instance: T[], all?: boolean, map?: string|mapFn<T, U>): T[];
least<T, U>(instance: T[], map?: string|mapFn<T, U>): T[];
map<T, U>(instance: T[], map: string|mapFn<T, U>, context?: any): U[];
mapFromIndex<T>(instance: T[], startIndex: number, loop?: boolean, ...args: any[]): T;
mapFromIndex<T>(instance: T[], startIndex: number, ...args: any[]): T;
max<T, U>(instance: T[], all?: boolean, map?: string|mapFn<T, U>): T;
max<T, U>(instance: T[], map?: string|mapFn<T, U>): T;
median<T, U>(instance: T[], map?: string|mapFn<T, U>): number;
min<T, U>(instance: T[], all?: boolean, map?: string|mapFn<T, U>): T;
min<T, U>(instance: T[], map?: string|mapFn<T, U>): T;
most<T, U>(instance: T[], all?: boolean, map?: string|mapFn<T, U>): T[];
most<T, U>(instance: T[], map?: string|mapFn<T, U>): T[];
none<T>(instance: T[], search: T|searchFn<T>, context?: any): boolean;
reduceFromIndex<T>(instance: T[], startIndex: number, loop?: boolean, ...args: any[]): T;
reduceFromIndex<T>(instance: T[], startIndex: number, ...args: any[]): T;
reduceRightFromIndex<T>(instance: T[], startIndex: number, loop?: boolean, ...args: any[]): T;
reduceRightFromIndex<T>(instance: T[], startIndex: number, ...args: any[]): T;
remove<T>(instance: T[], search: T|searchFn<T>): T[];
removeAt<T>(instance: T[], start: number, end?: number): T[];
sample<T>(instance: T[], num?: number, remove?: boolean): T;
shuffle<T>(instance: T[]): T[];
some<T>(instance: T[], search: T|searchFn<T>, context?: any): boolean;
someFromIndex<T>(instance: T[], startIndex: number, loop?: boolean, ...args: any[]): T;
someFromIndex<T>(instance: T[], startIndex: number, ...args: any[]): T;
sortBy<T, U>(instance: T[], map?: string|sortMapFn<T, U>, desc?: boolean): T[];
subtract<T>(instance: T[], item: T|T[]): T[];
sum<T, U>(instance: T[], map?: string|mapFn<T, U>): number;
to<T>(instance: T[], index: number): T[];
union<T>(instance: T[], arr: T[]): T[];
unique<T, U>(instance: T[], map?: string|mapFn<T, U>): T[];
zip<T>(instance: T[], ...args: any[]): T[];
getOption<T>(name: string): T;
setOption(name: string, value: any): void;
setOption(options: ArrayOptions): void;
}
interface ChainableBase<T, RawValue> {
raw: RawValue;
valueOf: () => RawValue;
toString: () => string;
add(item: T|T[], index?: number): SugarDefaultChainable<T[]>;
append(item: T|T[], index?: number): SugarDefaultChainable<T[]>;
at(index: number|number[], loop?: boolean): SugarDefaultChainable<T>;
average<U>(map?: string|mapFn<T, U>): SugarDefaultChainable<number>;
clone(): SugarDefaultChainable<T[]>;
compact(all?: boolean): SugarDefaultChainable<T[]>;
count(search: T|searchFn<T>, context?: any): SugarDefaultChainable<number>;
every(search: T|searchFn<T>, context?: any): SugarDefaultChainable<boolean>;
everyFromIndex(startIndex: number, loop?: boolean, ...args: any[]): SugarDefaultChainable<T>;
everyFromIndex(startIndex: number, ...args: any[]): SugarDefaultChainable<T>;
exclude(search: T|searchFn<T>): SugarDefaultChainable<T[]>;
filter(search: T|searchFn<T>, context?: any): SugarDefaultChainable<T[]>;
filterFromIndex(startIndex: number, loop?: boolean, ...args: any[]): SugarDefaultChainable<T>;
filterFromIndex(startIndex: number, ...args: any[]): SugarDefaultChainable<T>;
find(search: T|searchFn<T>, context?: any): SugarDefaultChainable<T>;
findFromIndex(startIndex: number, loop?: boolean, ...args: any[]): SugarDefaultChainable<T>;
findFromIndex(startIndex: number, ...args: any[]): SugarDefaultChainable<T>;
findIndex(search: T|searchFn<T>, context?: any): SugarDefaultChainable<number>;
findIndexFromIndex(startIndex: number, loop?: boolean, ...args: any[]): SugarDefaultChainable<T>;
findIndexFromIndex(startIndex: number, ...args: any[]): SugarDefaultChainable<T>;
first(num?: number): SugarDefaultChainable<T>;
flatten(limit?: number): SugarDefaultChainable<T[]>;
forEachFromIndex(startIndex: number, loop?: boolean, ...args: any[]): SugarDefaultChainable<T>;
forEachFromIndex(startIndex: number, ...args: any[]): SugarDefaultChainable<T>;
from(index: number): SugarDefaultChainable<T[]>;
groupBy<U>(map: string|mapFn<T, U>, groupFn?: (arr: T[], key: string, obj: Object) => SugarDefaultChainable<void>): SugarDefaultChainable<Object>;
inGroups(num: number, padding?: any): SugarDefaultChainable<T[]>;
inGroupsOf(num: number, padding?: any): SugarDefaultChainable<T[]>;
insert(item: T|T[], index?: number): SugarDefaultChainable<T[]>;
intersect(arr: T[]): SugarDefaultChainable<T[]>;
isEmpty(): SugarDefaultChainable<boolean>;
isEqual(arr: T[]): SugarDefaultChainable<boolean>;
last(num?: number): SugarDefaultChainable<T>;
least<U>(all?: boolean, map?: string|mapFn<T, U>): SugarDefaultChainable<T[]>;
least<U>(map?: string|mapFn<T, U>): SugarDefaultChainable<T[]>;
map<U>(map: string|mapFn<T, U>, context?: any): SugarDefaultChainable<U[]>;
mapFromIndex(startIndex: number, loop?: boolean, ...args: any[]): SugarDefaultChainable<T>;
mapFromIndex(startIndex: number, ...args: any[]): SugarDefaultChainable<T>;
max<U>(all?: boolean, map?: string|mapFn<T, U>): SugarDefaultChainable<T>;
max<U>(map?: string|mapFn<T, U>): SugarDefaultChainable<T>;
median<U>(map?: string|mapFn<T, U>): SugarDefaultChainable<number>;
min<U>(all?: boolean, map?: string|mapFn<T, U>): SugarDefaultChainable<T>;
min<U>(map?: string|mapFn<T, U>): SugarDefaultChainable<T>;
most<U>(all?: boolean, map?: string|mapFn<T, U>): SugarDefaultChainable<T[]>;
most<U>(map?: string|mapFn<T, U>): SugarDefaultChainable<T[]>;
none(search: T|searchFn<T>, context?: any): SugarDefaultChainable<boolean>;
reduceFromIndex(startIndex: number, loop?: boolean, ...args: any[]): SugarDefaultChainable<T>;
reduceFromIndex(startIndex: number, ...args: any[]): SugarDefaultChainable<T>;
reduceRightFromIndex(startIndex: number, loop?: boolean, ...args: any[]): SugarDefaultChainable<T>;
reduceRightFromIndex(startIndex: number, ...args: any[]): SugarDefaultChainable<T>;
remove(search: T|searchFn<T>): SugarDefaultChainable<T[]>;
removeAt(start: number, end?: number): SugarDefaultChainable<T[]>;
sample(num?: number, remove?: boolean): SugarDefaultChainable<T>;
shuffle(): SugarDefaultChainable<T[]>;
some(search: T|searchFn<T>, context?: any): SugarDefaultChainable<boolean>;
someFromIndex(startIndex: number, loop?: boolean, ...args: any[]): SugarDefaultChainable<T>;
someFromIndex(startIndex: number, ...args: any[]): SugarDefaultChainable<T>;
sortBy<U>(map?: string|sortMapFn<T, U>, desc?: boolean): SugarDefaultChainable<T[]>;
subtract(item: T|T[]): SugarDefaultChainable<T[]>;
sum<U>(map?: string|mapFn<T, U>): SugarDefaultChainable<number>;
to(index: number): SugarDefaultChainable<T[]>;
union(arr: T[]): SugarDefaultChainable<T[]>;
unique<U>(map?: string|mapFn<T, U>): SugarDefaultChainable<T[]>;
zip(...args: any[]): SugarDefaultChainable<T[]>;
concat(...items: (T | T[])[]): SugarDefaultChainable<T[]>;
concat(...items: T[][]): SugarDefaultChainable<T[]>;
copyWithin(target: number, start: number, end?: number): SugarDefaultChainable<this>;
every(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): SugarDefaultChainable<boolean>;
fill(value: T, start?: number, end?: number): SugarDefaultChainable<this>;
filter(callbackfn: (value: T, index: number, array: T[]) => any, thisArg?: any): SugarDefaultChainable<T[]>;
find(predicate: (value: T, index: number, obj: Array<T>) => boolean, thisArg?: any): SugarDefaultChainable<T | undefined>;
findIndex(predicate: (value: T, index: number, obj: Array<T>) => boolean, thisArg?: any): SugarDefaultChainable<number>;
forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): SugarDefaultChainable<void>;
indexOf(searchElement: T, fromIndex?: number): SugarDefaultChainable<number>;
join(separator?: string): SugarDefaultChainable<string>;
lastIndexOf(searchElement: T, fromIndex?: number): SugarDefaultChainable<number>;
map<U>(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): SugarDefaultChainable<U[]>;
pop(): SugarDefaultChainable<T | undefined>;
push(...items: T[]): SugarDefaultChainable<number>;
reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): SugarDefaultChainable<T>;
reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): SugarDefaultChainable<U>;
reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue?: T): SugarDefaultChainable<T>;
reduceRight<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): SugarDefaultChainable<U>;
reverse(): SugarDefaultChainable<T[]>;
shift(): SugarDefaultChainable<T | undefined>;
slice(start?: number, end?: number): SugarDefaultChainable<T[]>;
some(callbackfn: (value: T, index: number, array: T[]) => boolean, thisArg?: any): SugarDefaultChainable<boolean>;
sort(compareFn?: (a: T, b: T) => number): SugarDefaultChainable<this>;
splice(start: number): SugarDefaultChainable<T[]>;
splice(start: number, deleteCount: number, ...items: T[]): SugarDefaultChainable<T[]>;
toLocaleString(): SugarDefaultChainable<string>;
unshift(...items: T[]): SugarDefaultChainable<number>;
}
}
namespace Date {
type Chainable<RawValue> = ChainableBase<RawValue> & Object.ChainableBase<RawValue>;
interface DateOptions {
newDateInternal: Function;
}
interface DateCreateOptions {
locale?: string;
past?: boolean;
future?: boolean;
fromUTC?: boolean;
setUTC?: boolean;
clone?: boolean;
params?: Object;
}
interface Constructor extends SugarNamespace {
(d?: string|number|Date, options?: DateCreateOptions): Chainable<Date>;
new(d?: string|number|Date, options?: DateCreateOptions): Chainable<Date>;
addLocale(localeCode: string, def: Object): Locale;
create(d?: string|number|Date, options?: DateCreateOptions): Date;
getAllLocaleCodes(): string[];
getAllLocales(): Array<Locale>;
getLocale(localeCode?: string): Locale;
range(start?: string|Date, end?: string|Date): Range;
removeLocale(localeCode: string): Locale;
setLocale(localeCode: string): Locale;
addDays(instance: Date, n: number, reset?: boolean): Date;
addHours(instance: Date, n: number, reset?: boolean): Date;
addMilliseconds(instance: Date, n: number, reset?: boolean): Date;
addMinutes(instance: Date, n: number, reset?: boolean): Date;
addMonths(instance: Date, n: number, reset?: boolean): Date;
addSeconds(instance: Date, n: number, reset?: boolean): Date;
addWeeks(instance: Date, n: number, reset?: boolean): Date;
addYears(instance: Date, n: number, reset?: boolean): Date;
advance(instance: Date, set: string|Object, reset?: boolean): Date;
advance(instance: Date, milliseconds: number): Date;
advance(instance: Date, year: number, month: number, day?: number, hour?: number, minute?: number, second?: number, millliseconds?: undefined): Date;
beginningOfDay(instance: Date, localeCode?: string): Date;
beginningOfISOWeek(instance: Date): Date;
beginningOfMonth(instance: Date, localeCode?: string): Date;
beginningOfWeek(instance: Date, localeCode?: string): Date;
beginningOfYear(instance: Date, localeCode?: string): Date;
clone(instance: Date): Date;
daysAgo(instance: Date): number;
daysFromNow(instance: Date): number;
daysInMonth(instance: Date): number;
daysSince(instance: Date, d: string|number|Date, options?: DateCreateOptions): number;
daysUntil(instance: Date, d?: string|number|Date, options?: DateCreateOptions): number;
endOfDay(instance: Date, localeCode?: string): Date;
endOfISOWeek(instance: Date): Date;
endOfMonth(instance: Date, localeCode?: string): Date;
endOfWeek(instance: Date, localeCode?: string): Date;
endOfYear(instance: Date, localeCode?: string): Date;
format(instance: Date, f?: string, localeCode?: string): string;
full(instance: Date, localeCode?: string): string;
get(instance: Date, d: string|number|Date, options?: DateCreateOptions): Date;
getISOWeek(instance: Date): number;
getUTCOffset(instance: Date, iso?: boolean): string;
getUTCWeekday(instance: Date): number;
getWeekday(instance: Date): number;
hoursAgo(instance: Date): number;
hoursFromNow(instance: Date): number;
hoursSince(instance: Date, d: string|number|Date, options?: DateCreateOptions): number;
hoursUntil(instance: Date, d?: string|number|Date, options?: DateCreateOptions): number;
is(instance: Date, d: string|number|Date, margin?: number): boolean;
isAfter(instance: Date, d: string|number|Date, margin?: number): boolean;
isBefore(instance: Date, d: string|number|Date, margin?: number): boolean;
isBetween(instance: Date, d1: string|number|Date, d2: string|number|Date, margin?: number): boolean;
isFriday(instance: Date): boolean;
isFuture(instance: Date): boolean;
isLastMonth(instance: Date, localeCode?: string): boolean;
isLastWeek(instance: Date, localeCode?: string): boolean;
isLastYear(instance: Date, localeCode?: string): boolean;
isLeapYear(instance: Date): boolean;
isMonday(instance: Date): boolean;
isNextMonth(instance: Date, localeCode?: string): boolean;
isNextWeek(instance: Date, localeCode?: string): boolean;
isNextYear(instance: Date, localeCode?: string): boolean;
isPast(instance: Date): boolean;
isSaturday(instance: Date): boolean;
isSunday(instance: Date): boolean;
isThisMonth(instance: Date, localeCode?: string): boolean;
isThisWeek(instance: Date, localeCode?: string): boolean;
isThisYear(instance: Date, localeCode?: string): boolean;
isThursday(instance: Date): boolean;
isToday(instance: Date): boolean;
isTomorrow(instance: Date): boolean;
isTuesday(instance: Date): boolean;
isUTC(instance: Date): boolean;
isValid(instance: Date): boolean;
isWednesday(instance: Date): boolean;
isWeekday(instance: Date): boolean;
isWeekend(instance: Date): boolean;
isYesterday(instance: Date): boolean;
iso(instance: Date): string;
long(instance: Date, localeCode?: string): string;
medium(instance: Date, localeCode?: string): string;
millisecondsAgo(instance: Date): number;
millisecondsFromNow(instance: Date): number;
millisecondsSince(instance: Date, d: string|number|Date, options?: DateCreateOptions): number;
millisecondsUntil(instance: Date, d?: string|number|Date, options?: DateCreateOptions): number;
minutesAgo(instance: Date): number;
minutesFromNow(instance: Date): number;
minutesSince(instance: Date, d: string|number|Date, options?: DateCreateOptions): number;
minutesUntil(instance: Date, d?: string|number|Date, options?: DateCreateOptions): number;
monthsAgo(instance: Date): number;
monthsFromNow(instance: Date): number;
monthsSince(instance: Date, d: string|number|Date, options?: DateCreateOptions): number;
monthsUntil(instance: Date, d?: string|number|Date, options?: DateCreateOptions): number;
relative(instance: Date, localeCode?: string, relativeFn?: (num: number, unit: number, ms: number, loc: Locale) => string): string;
relative(instance: Date, relativeFn?: (num: number, unit: number, ms: number, loc: Locale) => string): string;
relativeTo(instance: Date, d: string|number|Date, localeCode?: string): string;
reset(instance: Date, unit?: string, localeCode?: string): Date;
rewind(instance: Date, set: string|Object, reset?: boolean): Date;
rewind(instance: Date, milliseconds: number): Date;
rewind(instance: Date, year: number, month: number, day?: number, hour?: number, minute?: number, second?: number, millliseconds?: undefined): Date;
secondsAgo(instance: Date): number;
secondsFromNow(instance: Date): number;
secondsSince(instance: Date, d: string|number|Date, options?: DateCreateOptions): number;
secondsUntil(instance: Date, d?: string|number|Date, options?: DateCreateOptions): number;
set(instance: Date, set: Object, reset?: boolean): Date;
set(instance: Date, milliseconds: number): Date;
set(instance: Date, year: number, month: number, day?: number, hour?: number, minute?: number, second?: number, millliseconds?: undefined): Date;
setISOWeek(instance: Date, num: number): void;
setUTC(instance: Date, on?: boolean): Date;
setWeekday(instance: Date, dow: number): void;
short(instance: Date, localeCode?: string): string;
weeksAgo(instance: Date): number;
weeksFromNow(instance: Date): number;
weeksSince(instance: Date, d: string|number|Date, options?: DateCreateOptions): number;
weeksUntil(instance: Date, d?: string|number|Date, options?: DateCreateOptions): number;
yearsAgo(instance: Date): number;
yearsFromNow(instance: Date): number;
yearsSince(instance: Date, d: string|number|Date, options?: DateCreateOptions): number;
yearsUntil(instance: Date, d?: string|number|Date, options?: DateCreateOptions): number;
getOption<T>(name: string): T;
setOption(name: string, value: any): void;
setOption(options: DateOptions): void;
}
interface ChainableBase<RawValue> {
raw: RawValue;
valueOf: () => RawValue;
toString: () => string;
addDays(n: number, reset?: boolean): SugarDefaultChainable<Date>;
addHours(n: number, reset?: boolean): SugarDefaultChainable<Date>;
addMilliseconds(n: number, reset?: boolean): SugarDefaultChainable<Date>;
addMinutes(n: number, reset?: boolean): SugarDefaultChainable<Date>;
addMonths(n: number, reset?: boolean): SugarDefaultChainable<Date>;
addSeconds(n: number, reset?: boolean): SugarDefaultChainable<Date>;
addWeeks(n: number, reset?: boolean): SugarDefaultChainable<Date>;
addYears(n: number, reset?: boolean): SugarDefaultChainable<Date>;
advance(set: string|Object, reset?: boolean): SugarDefaultChainable<Date>;
advance(milliseconds: number): SugarDefaultChainable<Date>;
advance(year: number, month: number, day?: number, hour?: number, minute?: number, second?: number, millliseconds?: undefined): SugarDefaultChainable<Date>;
beginningOfDay(localeCode?: string): SugarDefaultChainable<Date>;
beginningOfISOWeek(): SugarDefaultChainable<Date>;
beginningOfMonth(localeCode?: string): SugarDefaultChainable<Date>;
beginningOfWeek(localeCode?: string): SugarDefaultChainable<Date>;
beginningOfYear(localeCode?: string): SugarDefaultChainable<Date>;
clone(): SugarDefaultChainable<Date>;
daysAgo(): SugarDefaultChainable<number>;
daysFromNow(): SugarDefaultChainable<number>;
daysInMonth(): SugarDefaultChainable<number>;
daysSince(d: string|number|Date, options?: DateCreateOptions): SugarDefaultChainable<number>;
daysUntil(d?: string|number|Date, options?: DateCreateOptions): SugarDefaultChainable<number>;
endOfDay(localeCode?: string): SugarDefaultChainable<Date>;
endOfISOWeek(): SugarDefaultChainable<Date>;
endOfMonth(localeCode?: string): SugarDefaultChainable<Date>;
endOfWeek(localeCode?: string): SugarDefaultChainable<Date>;
endOfYear(localeCode?: string): SugarDefaultChainable<Date>;
format(f?: string, localeCode?: string): SugarDefaultChainable<string>;
full(localeCode?: string): SugarDefaultChainable<string>;
get(d: string|number|Date, options?: DateCreateOptions): SugarDefaultChainable<Date>;
getISOWeek(): SugarDefaultChainable<number>;
getUTCOffset(iso?: boolean): SugarDefaultChainable<string>;
getUTCWeekday(): SugarDefaultChainable<number>;
getWeekday(): SugarDefaultChainable<number>;
hoursAgo(): SugarDefaultChainable<number>;
hoursFromNow(): SugarDefaultChainable<number>;
hoursSince(d: string|number|Date, options?: DateCreateOptions): SugarDefaultChainable<number>;
hoursUntil(d?: string|number|Date, options?: DateCreateOptions): SugarDefaultChainable<number>;
is(d: string|number|Date, margin?: number): SugarDefaultChainable<boolean>;
isAfter(d: string|number|Date, margin?: number): SugarDefaultChainable<boolean>;
isBefore(d: string|number|Date, margin?: number): SugarDefaultChainable<boolean>;
isBetween(d1: string|number|Date, d2: string|number|Date, margin?: number): SugarDefaultChainable<boolean>;
isFriday(): SugarDefaultChainable<boolean>;
isFuture(): SugarDefaultChainable<boolean>;
isLastMonth(localeCode?: string): SugarDefaultChainable<boolean>;
isLastWeek(localeCode?: string): SugarDefaultChainable<boolean>;
isLastYear(localeCode?: string): SugarDefaultChainable<boolean>;
isLeapYear(): SugarDefaultChainable<boolean>;
isMonday(): SugarDefaultChainable<boolean>;
isNextMonth(localeCode?: string): SugarDefaultChainable<boolean>;
isNextWeek(localeCode?: string): SugarDefaultChainable<boolean>;
isNextYear(localeCode?: string): SugarDefaultChainable<boolean>;
isPast(): SugarDefaultChainable<boolean>;
isSaturday(): SugarDefaultChainable<boolean>;
isSunday(): SugarDefaultChainable<boolean>;
isThisMonth(localeCode?: string): SugarDefaultChainable<boolean>;
isThisWeek(localeCode?: string): SugarDefaultChainable<boolean>;
isThisYear(localeCode?: string): SugarDefaultChainable<boolean>;
isThursday(): SugarDefaultChainable<boolean>;
isToday(): SugarDefaultChainable<boolean>;
isTomorrow(): SugarDefaultChainable<boolean>;
isTuesday(): SugarDefaultChainable<boolean>;
isUTC(): SugarDefaultChainable<boolean>;
isValid(): SugarDefaultChainable<boolean>;
isWednesday(): SugarDefaultChainable<boolean>;
isWeekday(): SugarDefaultChainable<boolean>;
isWeekend(): SugarDefaultChainable<boolean>;
isYesterday(): SugarDefaultChainable<boolean>;
iso(): SugarDefaultChainable<string>;
long(localeCode?: string): SugarDefaultChainable<string>;
medium(localeCode?: string): SugarDefaultChainable<string>;
millisecondsAgo(): SugarDefaultChainable<number>;
millisecondsFromNow(): SugarDefaultChainable<number>;
millisecondsSince(d: string|number|Date, options?: DateCreateOptions): SugarDefaultChainable<number>;
millisecondsUntil(d?: string|number|Date, options?: DateCreateOptions): SugarDefaultChainable<number>;
minutesAgo(): SugarDefaultChainable<number>;
minutesFromNow(): SugarDefaultChainable<number>;
minutesSince(d: string|number|Date, options?: DateCreateOptions): SugarDefaultChainable<number>;
minutesUntil(d?: string|number|Date, options?: DateCreateOptions): SugarDefaultChainable<number>;
monthsAgo(): SugarDefaultChainable<number>;
monthsFromNow(): SugarDefaultChainable<number>;
monthsSince(d: string|number|Date, options?: DateCreateOptions): SugarDefaultChainable<number>;
monthsUntil(d?: string|number|Date, options?: DateCreateOptions): SugarDefaultChainable<number>;
relative(localeCode?: string, relativeFn?: (num: number, unit: number, ms: number, loc: Locale) => SugarDefaultChainable<string>): SugarDefaultChainable<string>;
relative(relativeFn?: (num: number, unit: number, ms: number, loc: Locale) => SugarDefaultChainable<string>): SugarDefaultChainable<string>;
relativeTo(d: string|number|Date, localeCode?: string): SugarDefaultChainable<string>;
reset(unit?: string, localeCode?: string): SugarDefaultChainable<Date>;
rewind(set: string|Object, reset?: boolean): SugarDefaultChainable<Date>;
rewind(milliseconds: number): SugarDefaultChainable<Date>;
rewind(year: number, month: number, day?: number, hour?: number, minute?: number, second?: number, millliseconds?: undefined): SugarDefaultChainable<Date>;
secondsAgo(): SugarDefaultChainable<number>;
secondsFromNow(): SugarDefaultChainable<number>;
secondsSince(d: string|number|Date, options?: DateCreateOptions): SugarDefaultChainable<number>;
secondsUntil(d?: string|number|Date, options?: DateCreateOptions): SugarDefaultChainable<number>;
set(set: Object, reset?: boolean): SugarDefaultChainable<Date>;
set(milliseconds: number): SugarDefaultChainable<Date>;
set(year: number, month: number, day?: number, hour?: number, minute?: number, second?: number, millliseconds?: undefined): SugarDefaultChainable<Date>;
setISOWeek(num: number): SugarDefaultChainable<void>;
setUTC(on?: boolean): SugarDefaultChainable<Date>;
setWeekday(dow: number): SugarDefaultChainable<void>;
short(localeCode?: string): SugarDefaultChainable<string>;
weeksAgo(): SugarDefaultChainable<number>;
weeksFromNow(): SugarDefaultChainable<number>;
weeksSince(d: string|number|Date, options?: DateCreateOptions): SugarDefaultChainable<number>;
weeksUntil(d?: string|number|Date, options?: DateCreateOptions): SugarDefaultChainable<number>;
yearsAgo(): SugarDefaultChainable<number>;
yearsFromNow(): SugarDefaultChainable<number>;
yearsSince(d: string|number|Date, options?: DateCreateOptions): SugarDefaultChainable<number>;
yearsUntil(d?: string|number|Date, options?: DateCreateOptions): SugarDefaultChainable<number>;
getDate(): SugarDefaultChainable<number>;
getDay(): SugarDefaultChainable<number>;
getFullYear(): SugarDefaultChainable<number>;
getHours(): SugarDefaultChainable<number>;
getMilliseconds(): SugarDefaultChainable<number>;
getMinutes(): SugarDefaultChainable<number>;
getMonth(): SugarDefaultChainable<number>;
getSeconds(): SugarDefaultChainable<number>;
getTime(): SugarDefaultChainable<number>;
getTimezoneOffset(): SugarDefaultChainable<number>;
getUTCDate(): SugarDefaultChainable<number>;
getUTCDay(): SugarDefaultChainable<number>;
getUTCFullYear(): SugarDefaultChainable<number>;
getUTCHours(): SugarDefaultChainable<number>;
getUTCMilliseconds(): SugarDefaultChainable<number>;
getUTCMinutes(): SugarDefaultChainable<number>;
getUTCMonth(): SugarDefaultChainable<number>;
getUTCSeconds(): SugarDefaultChainable<number>;
setDate(date: number): SugarDefaultChainable<number>;
setFullYear(year: number, month?: number, date?: number): SugarDefaultChainable<number>;
setHours(hours: number, min?: number, sec?: number, ms?: number): SugarDefaultChainable<number>;
setMilliseconds(ms: number): SugarDefaultChainable<number>;
setMinutes(min: number, sec?: number, ms?: number): SugarDefaultChainable<number>;
setMonth(month: number, date?: number): SugarDefaultChainable<number>;
setSeconds(sec: number, ms?: number): SugarDefaultChainable<number>;
setTime(time: number): SugarDefaultChainable<number>;
setUTCDate(date: number): SugarDefaultChainable<number>;
setUTCFullYear(year: number, month?: number, date?: number): SugarDefaultChainable<number>;
setUTCHours(hours: number, min?: number, sec?: number, ms?: number): SugarDefaultChainable<number>;
setUTCMilliseconds(ms: number): SugarDefaultChainable<number>;
setUTCMinutes(min: number, sec?: number, ms?: number): SugarDefaultChainable<number>;
setUTCMonth(month: number, date?: number): SugarDefaultChainable<number>;
setUTCSeconds(sec: number, ms?: number): SugarDefaultChainable<number>;
toDateString(): SugarDefaultChainable<string>;
toISOString(): SugarDefaultChainable<string>;
toJSON(key?: any): SugarDefaultChainable<string>;
toLocaleDateString(locales?: string | string[], options?: Intl.DateTimeFormatOptions): SugarDefaultChainable<string>;
toLocaleDateString(): SugarDefaultChainable<string>;
toLocaleString(): SugarDefaultChainable<string>;
toLocaleString(locales?: string | string[], options?: Intl.DateTimeFormatOptions): SugarDefaultChainable<string>;
toLocaleTimeString(): SugarDefaultChainable<string>;
toLocaleTimeString(locales?: string | string[], options?: Intl.DateTimeFormatOptions): SugarDefaultChainable<string>;
toTimeString(): SugarDefaultChainable<string>;
toUTCString(): SugarDefaultChainable<string>;
}
}
namespace Function {
type Chainable<RawValue> = ChainableBase<RawValue> & Object.ChainableBase<RawValue>;
interface Constructor extends SugarNamespace {
(raw?: Function): Chainable<Function>;
new(raw?: Function): Chainable<Function>;
after(instance: Function, n: number): Function;
cancel(instance: Function): Function;
debounce(instance: Function, ms?: number): Function;
delay(instance: Function, ms?: number, ...args: any[]): Function;
every(instance: Function, ms?: number, ...args: any[]): Function;
lazy(instance: Function, ms?: number, immediate?: boolean, limit?: number): Function;
lock(instance: Function, n?: number): Function;
memoize(instance: Function, hashFn?: string|Function, limit?: number): Function;
once(instance: Function): Function;
partial(instance: Function, ...args: any[]): Function;
throttle(instance: Function, ms?: number): Function;
}
interface ChainableBase<RawValue> {
raw: RawValue;
valueOf: () => RawValue;
toString: () => string;
after(n: number): SugarDefaultChainable<Function>;
cancel(): SugarDefaultChainable<Function>;
debounce(ms?: number): SugarDefaultChainable<Function>;
delay(ms?: number, ...args: any[]): SugarDefaultChainable<Function>;
every(ms?: number, ...args: any[]): SugarDefaultChainable<Function>;
lazy(ms?: number, immediate?: boolean, limit?: number): SugarDefaultChainable<Function>;
lock(n?: number): SugarDefaultChainable<Function>;
memoize(hashFn?: string|Function, limit?: number): SugarDefaultChainable<Function>;
once(): SugarDefaultChainable<Function>;
partial(...args: any[]): SugarDefaultChainable<Function>;
throttle(ms?: number): SugarDefaultChainable<Function>;
apply(thisArg: any, argArray?: any): SugarDefaultChainable<any>;
bind(thisArg: any, ...argArray: any[]): SugarDefaultChainable<any>;
call(thisArg: any, ...argArray: any[]): SugarDefaultChainable<any>;
}
}
namespace Number {
type Chainable<RawValue> = ChainableBase<RawValue> & Object.ChainableBase<RawValue>;
interface NumberOptions {
decimal: string;
thousands: string;
}
interface Constructor extends SugarNamespace {
(raw?: number): Chainable<number>;
new(raw?: number): Chainable<number>;
random(n1?: number, n2?: number): number;
range(start?: number, end?: number): Range;
abbr(instance: number, precision?: number): string;
abs(instance: number): number;
acos(instance: number): number;
asin(instance: number): number;
atan(instance: number): number;
bytes(instance: number, precision?: number, binary?: boolean, units?: string): string;
cap(instance: number, max?: number): number;
ceil(instance: number, precision?: number): number;
chr(instance: number): string;
clamp(instance: number, start?: number, end?: number): number;
cos(instance: number): number;
day(instance: number): number;
dayAfter(instance: number, d: string|number|Date, options?: Date.DateCreateOptions): Date;
dayAgo(instance: number): Date;
dayBefore(instance: number, d: string|number|Date, options?: Date.DateCreateOptions): Date;
dayFromNow(instance: number): Date;
days(instance: number): number;
daysAfter(instance: number, d: string|number|Date, options?: Date.DateCreateOptions): Date;
daysAgo(instance: number): Date;
daysBefore(instance: number, d: string|number|Date, options?: Date.DateCreateOptions): Date;
daysFromNow(instance: number): Date;
downto<T>(instance: number, num: number, step?: number, everyFn?: (el: T, i: number, r: Range) => void): T[];
downto<T>(instance: number, num: number, everyFn?: (el: T, i: number, r: Range) => void): T[];
duration(instance: number, localeCode?: string): string;
exp(instance: number): number;
floor(instance: number, precision?: number): number;
format(instance: number, place?: number): string;
hex(instance: number, pad?: number): string;
hour(instance: number): number;
hourAfter(instance: number, d: string|number|Date, options?: Date.DateCreateOptions): Date;
hourAgo(instance: number): Date;
hourBefore(instance: number, d: string|number|Date, options?: Date.DateCreateOptions): Date;
hourFromNow(instance: number): Date;
hours(instance: number): number;
hoursAfter(instance: number, d: string|number|Date, options?: Date.DateCreateOptions): Date;
hoursAgo(instance: number): Date;
hoursBefore(instance: number, d: string|number|Date, options?: Date.DateCreateOptions): Date;
hoursFromNow(instance: number): Date;
isEven(instance: number): boolean;
isInteger(instance: number): boolean;
isMultipleOf(instance: number, num: number): boolean;
isOdd(instance: number): boolean;
log(instance: number, base?: number): number;
metric(instance: number, precision?: number, units?: string): string;
millisecond(instance: number): number;
millisecondAfter(instance: number, d: string|number|Date, options?: Date.DateCreateOptions): Date;
millisecondAgo(instance: number): Date;
millisecondBefore(instance: number, d: string|number|Date, options?: Date.DateCreateOptions): Date;
millisecondFromNow(instance: number): Date;
milliseconds(instance: number): number;
millisecondsAfter(instance: number, d: string|number|Date, options?: Date.DateCreateOptions): Date;
millisecondsAgo(instance: number): Date;
millisecondsBefore(instance: number, d: string|number|Date, options?: Date.DateCreateOptions): Date;
millisecondsFromNow(instance: number): Date;
minute(instance: number): number;
minuteAfter(instance: number, d: string|number|Date, options?: Date.DateCreateOptions): Date;
minuteAgo(instance: number): Date;
minuteBefore(instance: number, d: string|number|Date, options?: Date.DateCreateOptions): Date;
minuteFromNow(instance: number): Date;
minutes(instance: number): number;
minutesAfter(instance: number, d: string|number|Date, options?: Date.DateCreateOptions): Date;
minutesAgo(instance: number): Date;
minutesBefore(instance: number, d: string|number|Date, options?: Date.DateCreateOptions): Date;
minutesFromNow(instance: number): Date;
month(instance: number): number;
monthAfter(instance: number, d: string|number|Date, options?: Date.DateCreateOptions): Date;
monthAgo(instance: number): Date;
monthBefore(instance: number, d: string|number|Date, options?: Date.DateCreateOptions): Date;
monthFromNow(instance: number): Date;
months(instance: number): number;
monthsAfter(instance: number, d: string|number|Date, options?: Date.DateCreateOptions): Date;
monthsAgo(instance: number): Date;
monthsBefore(instance: number, d: string|number|Date, options?: Date.DateCreateOptions): Date;
monthsFromNow(instance: number): Date;
ordinalize(instance: number): string;
pad(instance: number, place?: number, sign?: boolean, base?: number): string;
pow(instance: number): number;
round(instance: number, precision?: number): number;
second(instance: number): number;
secondAfter(instance: number, d: string|number|Date, options?: Date.DateCreateOptions): Date;
secondAgo(instance: number): Date;
secondBefore(instance: number, d: string|number|Date, options?: Date.DateCreateOptions): Date;
secondFromNow(instance: number): Date;
seconds(instance: number): number;
secondsAfter(instance: number, d: string|number|Date, options?: Date.DateCreateOptions): Date;
secondsAgo(instance: number): Date;
secondsBefore(instance: number, d: string|number|Date, options?: Date.DateCreateOptions): Date;
secondsFromNow(instance: number): Date;
sin(instance: number): number;
sqrt(instance: number): number;
tan(instance: number): number;
times<T>(instance: number, indexMapFn: (i: number) => any): T;
toNumber(instance: number): number;
upto<T>(instance: number, num: number, step?: number, everyFn?: (el: T, i: number, r: Range) => void): T[];
upto<T>(instance: number, num: number, everyFn?: (el: T, i: number, r: Range) => void): T[];
week(instance: number): number;
weekAfter(instance: number, d: string|number|Date, options?: Date.DateCreateOptions): Date;
weekAgo(instance: number): Date;
weekBefore(instance: number, d: string|number|Date, options?: Date.DateCreateOptions): Date;
weekFromNow(instance: number): Date;
weeks(instance: number): number;
weeksAfter(instance: number, d: string|number|Date, options?: Date.DateCreateOptions): Date;
weeksAgo(instance: number): Date;
weeksBefore(instance: number, d: string|number|Date, options?: Date.DateCreateOptions): Date;
weeksFromNow(instance: number): Date;
year(instance: number): number;
yearAfter(instance: number, d: string|number|Date, options?: Date.DateCreateOptions): Date;
yearAgo(instance: number): Date;
yearBefore(instance: number, d: string|number|Date, options?: Date.DateCreateOptions): Date;
yearFromNow(instance: number): Date;
years(instance: number): number;
yearsAfter(instance: number, d: string|number|Date, options?: Date.DateCreateOptions): Date;
yearsAgo(instance: number): Date;
yearsBefore(instance: number, d: string|number|Date, options?: Date.DateCreateOptions): Date;
yearsFromNow(instance: number): Date;
getOption<T>(name: string): T;
setOption(name: string, value: any): void;
setOption(options: NumberOptions): void;
}
interface ChainableBase<RawValue> {
raw: RawValue;
valueOf: () => RawValue;
toString: () => string;
abbr(precision?: number): SugarDefaultChainable<string>;
abs(): SugarDefaultChainable<number>;
acos(): SugarDefaultChainable<number>;
asin(): SugarDefaultChainable<number>;
atan(): SugarDefaultChainable<number>;
bytes(precision?: number, binary?: boolean, units?: string): SugarDefaultChainable<string>;
cap(max?: number): SugarDefaultChainable<number>;
ceil(precision?: number): SugarDefaultChainable<number>;
chr(): SugarDefaultChainable<string>;
clamp(start?: number, end?: number): SugarDefaultChainable<number>;
cos(): SugarDefaultChainable<number>;
day(): SugarDefaultChainable<number>;
dayAfter(d: string|number|Date, options?: Date.DateCreateOptions): SugarDefaultChainable<Date>;
dayAgo(): SugarDefaultChainable<Date>;
dayBefore(d: string|number|Date, options?: Date.DateCreateOptions): SugarDefaultChainable<Date>;
dayFromNow(): SugarDefaultChainable<Date>;
days(): SugarDefaultChainable<number>;
daysAfter(d: string|number|Date, options?: Date.DateCreateOptions): SugarDefaultChainable<Date>;
daysAgo(): SugarDefaultChainable<Date>;
daysBefore(d: string|number|Date, options?: Date.DateCreateOptions): SugarDefaultChainable<Date>;
daysFromNow(): SugarDefaultChainable<Date>;
downto<T>(num: number, step?: number, everyFn?: (el: T, i: number, r: Range) => SugarDefaultChainable<void>): SugarDefaultChainable<T[]>;
downto<T>(num: number, everyFn?: (el: T, i: number, r: Range) => SugarDefaultChainable<void>): SugarDefaultChainable<T[]>;
duration(localeCode?: string): SugarDefaultChainable<string>;
exp(): SugarDefaultChainable<number>;
floor(precision?: number): SugarDefaultChainable<number>;
format(place?: number): SugarDefaultChainable<string>;
hex(pad?: number): SugarDefaultChainable<string>;
hour(): SugarDefaultChainable<number>;
hourAfter(d: string|number|Date, options?: Date.DateCreateOptions): SugarDefaultChainable<Date>;
hourAgo(): SugarDefaultChainable<Date>;
hourBefore(d: string|number|Date, options?: Date.DateCreateOptions): SugarDefaultChainable<Date>;
hourFromNow(): SugarDefaultChainable<Date>;
hours(): SugarDefaultChainable<number>;
hoursAfter(d: string|number|Date, options?: Date.DateCreateOptions): SugarDefaultChainable<Date>;
hoursAgo(): SugarDefaultChainable<Date>;
hoursBefore(d: string|number|Date, options?: Date.DateCreateOptions): SugarDefaultChainable<Date>;
hoursFromNow(): SugarDefaultChainable<Date>;
isEven(): SugarDefaultChainable<boolean>;
isInteger(): SugarDefaultChainable<boolean>;
isMultipleOf(num: number): SugarDefaultChainable<boolean>;
isOdd(): SugarDefaultChainable<boolean>;
log(base?: number): SugarDefaultChainable<number>;
metric(precision?: number, units?: string): SugarDefaultChainable<string>;
millisecond(): SugarDefaultChainable<number>;
millisecondAfter(d: string|number|Date, options?: Date.DateCreateOptions): SugarDefaultChainable<Date>;
millisecondAgo(): SugarDefaultChainable<Date>;
millisecondBefore(d: string|number|Date, options?: Date.DateCreateOptions): SugarDefaultChainable<Date>;
millisecondFromNow(): SugarDefaultChainable<Date>;
milliseconds(): SugarDefaultChainable<number>;
millisecondsAfter(d: string|number|Date, options?: Date.DateCreateOptions): SugarDefaultChainable<Date>;
millisecondsAgo(): SugarDefaultChainable<Date>;
millisecondsBefore(d: string|number|Date, options?: Date.DateCreateOptions): SugarDefaultChainable<Date>;
millisecondsFromNow(): SugarDefaultChainable<Date>;
minute(): SugarDefaultChainable<number>;
minuteAfter(d: string|number|Date, options?: Date.DateCreateOptions): SugarDefaultChainable<Date>;
minuteAgo(): SugarDefaultChainable<Date>;
minuteBefore(d: string|number|Date, options?: Date.DateCreateOptions): SugarDefaultChainable<Date>;
minuteFromNow(): SugarDefaultChainable<Date>;
minutes(): SugarDefaultChainable<number>;
minutesAfter(d: string|number|Date, options?: Date.DateCreateOptions): SugarDefaultChainable<Date>;
minutesAgo(): SugarDefaultChainable<Date>;
minutesBefore(d: string|number|Date, options?: Date.DateCreateOptions): SugarDefaultChainable<Date>;
minutesFromNow(): SugarDefaultChainable<Date>;
month(): SugarDefaultChainable<number>;
monthAfter(d: string|number|Date, options?: Date.DateCreateOptions): SugarDefaultChainable<Date>;
monthAgo(): SugarDefaultChainable<Date>;
monthBefore(d: string|number|Date, options?: Date.DateCreateOptions): SugarDefaultChainable<Date>;
monthFromNow(): SugarDefaultChainable<Date>;
months(): SugarDefaultChainable<number>;
monthsAfter(d: string|number|Date, options?: Date.DateCreateOptions): SugarDefaultChainable<Date>;
monthsAgo(): SugarDefaultChainable<Date>;
monthsBefore(d: string|number|Date, options?: Date.DateCreateOptions): SugarDefaultChainable<Date>;
monthsFromNow(): SugarDefaultChainable<Date>;
ordinalize(): SugarDefaultChainable<string>;
pad(place?: number, sign?: boolean, base?: number): SugarDefaultChainable<string>;
pow(): SugarDefaultChainable<number>;
round(precision?: number): SugarDefaultChainable<number>;
second(): SugarDefaultChainable<number>;
secondAfter(d: string|number|Date, options?: Date.DateCreateOptions): SugarDefaultChainable<Date>;
secondAgo(): SugarDefaultChainable<Date>;
secondBefore(d: string|number|Date, options?: Date.DateCreateOptions): SugarDefaultChainable<Date>;
secondFromNow(): SugarDefaultChainable<Date>;
seconds(): SugarDefaultChainable<number>;
secondsAfter(d: string|number|Date, options?: Date.DateCreateOptions): SugarDefaultChainable<Date>;
secondsAgo(): SugarDefaultChainable<Date>;
secondsBefore(d: string|number|Date, options?: Date.DateCreateOptions): SugarDefaultChainable<Date>;
secondsFromNow(): SugarDefaultChainable<Date>;
sin(): SugarDefaultChainable<number>;
sqrt(): SugarDefaultChainable<number>;
tan(): SugarDefaultChainable<number>;
times<T>(indexMapFn: (i: number) => SugarDefaultChainable<any>): SugarDefaultChainable<T>;
toNumber(): SugarDefaultChainable<number>;
upto<T>(num: number, step?: number, everyFn?: (el: T, i: number, r: Range) => SugarDefaultChainable<void>): SugarDefaultChainable<T[]>;
upto<T>(num: number, everyFn?: (el: T, i: number, r: Range) => SugarDefaultChainable<void>): SugarDefaultChainable<T[]>;
week(): SugarDefaultChainable<number>;
weekAfter(d: string|number|Date, options?: Date.DateCreateOptions): SugarDefaultChainable<Date>;
weekAgo(): SugarDefaultChainable<Date>;
weekBefore(d: string|number|Date, options?: Date.DateCreateOptions): SugarDefaultChainable<Date>;
weekFromNow(): SugarDefaultChainable<Date>;
weeks(): SugarDefaultChainable<number>;
weeksAfter(d: string|number|Date, options?: Date.DateCreateOptions): SugarDefaultChainable<Date>;
weeksAgo(): SugarDefaultChainable<Date>;
weeksBefore(d: string|number|Date, options?: Date.DateCreateOptions): SugarDefaultChainable<Date>;
weeksFromNow(): SugarDefaultChainable<Date>;
year(): SugarDefaultChainable<number>;
yearAfter(d: string|number|Date, options?: Date.DateCreateOptions): SugarDefaultChainable<Date>;
yearAgo(): SugarDefaultChainable<Date>;
yearBefore(d: string|number|Date, options?: Date.DateCreateOptions): SugarDefaultChainable<Date>;
yearFromNow(): SugarDefaultChainable<Date>;
years(): SugarDefaultChainable<number>;
yearsAfter(d: string|number|Date, options?: Date.DateCreateOptions): SugarDefaultChainable<Date>;
yearsAgo(): SugarDefaultChainable<Date>;
yearsBefore(d: string|number|Date, options?: Date.DateCreateOptions): SugarDefaultChainable<Date>;
yearsFromNow(): SugarDefaultChainable<Date>;
toExponential(fractionDigits?: number): SugarDefaultChainable<string>;
toFixed(fractionDigits?: number): SugarDefaultChainable<string>;
toLocaleString(locales?: string | string[], options?: Intl.NumberFormatOptions): SugarDefaultChainable<string>;
toPrecision(precision?: number): SugarDefaultChainable<string>;
}
}
namespace Object {
type resolveFn<T> = (key: string, targetVal: T, sourceVal: T, target: Object, source: Object) => boolean;
type searchFn<T> = (key: string, val: T, obj: Object) => boolean;
type mapFn<T, U> = (val: T, key: string, obj: Object) => U;
type Chainable<RawValue> = ChainableBase<RawValue>;
interface QueryStringParseOptions<T, U> {
deep?: boolean;
auto?: boolean;
transform?: (key: string, val: T, obj: Object) => U;
separator?: string;
}
interface QueryStringOptions<T, U> {
deep?: boolean;
prefix?: string;
transform?: (key: string, val: T, obj: Object) => U;
separator?: string;
}
interface ObjectMergeOptions<T> {
deep?: boolean;
hidden?: boolean;
descriptor?: boolean;
resolve?: boolean|resolveFn<T>;
}
interface Constructor extends SugarNamespace {
(raw?: Object): Chainable<Object>;
new(raw?: Object): Chainable<Object>;
fromQueryString<T, U>(str: string, options?: QueryStringParseOptions<T, U>): Object;
add<T>(instance: Object, obj: Object, options?: ObjectMergeOptions<T>): Object;
addAll<T>(instance: Object, sources: Array<Object>, options?: ObjectMergeOptions<T>): Object;
average<T, U>(instance: Object, map?: string|mapFn<T, U>): number;
clone(instance: Object, deep?: boolean): Object;
count<T>(instance: Object, search: T|searchFn<T>): number;
defaults<T>(instance: Object, sources: Array<Object>, options?: ObjectMergeOptions<T>): Object;
every<T>(instance: Object, search: T|searchFn<T>): boolean;
exclude<T>(instance: Object, search: T|searchFn<T>): Object;
filter<T>(instance: Object, search: T|searchFn<T>): T[];
find<T>(instance: Object, search: T|searchFn<T>): boolean;
forEach<T>(instance: Object, eachFn: (val: T, key: string, obj: Object) => void): Object;
get<T>(instance: Object, key: string, inherited?: boolean): T;
has(instance: Object, key: string, inherited?: boolean): boolean;
intersect(instance: Object, obj: Object): Object;
invert(instance: Object, multi?: boolean): Object;
isArguments(instance: Object): boolean;
isArray(instance: any): instance is Array<any>;
isBoolean(instance: any): instance is boolean;
isDate(instance: any): instance is Date;
isEmpty(instance: Object): boolean;
isEqual(instance: Object, obj: Object): boolean;
isError(instance: any): instance is Error;
isFunction(instance: any): instance is Function;
isMap(instance: any): instance is Map<any, any>;
isNumber(instance: any): instance is number;
isObject(instance: Object): boolean;
isRegExp(instance: any): instance is RegExp;
isSet(instance: any): instance is Set<any>;
isString(instance: any): instance is string;
keys<T>(instance: Object): T[];
least<T, U>(instance: Object, all?: boolean, map?: string|mapFn<T, U>): T;
least<T, U>(instance: Object, map?: string|mapFn<T, U>): T;
map<T, U>(instance: Object, map: string|mapFn<T, U>): Object;
max<T, U>(instance: Object, all?: boolean, map?: string|mapFn<T, U>): T;
max<T, U>(instance: Object, map?: string|mapFn<T, U>): T;
median<T, U>(instance: Object, map?: string|mapFn<T, U>): number;
merge<T>(instance: Object, source: Object, options?: ObjectMergeOptions<T>): Object;
mergeAll<T>(instance: Object, sources: Array<Object>, options?: ObjectMergeOptions<T>): Object;
min<T, U>(instance: Object, all?: boolean, map?: string|mapFn<T, U>): T;
min<T, U>(instance: Object, map?: string|mapFn<T, U>): T;
most<T, U>(instance: Object, all?: boolean, map?: string|mapFn<T, U>): T;
most<T, U>(instance: Object, map?: string|mapFn<T, U>): T;
none<T>(instance: Object, search: T|searchFn<T>): boolean;
reduce<T>(instance: Object, reduceFn: (acc: T, val: T, key: string, obj: Object) => void, init?: any): T;
reject(instance: Object, find: string|RegExp|Array<string>|Object): Object;
remove<T>(instance: Object, search: T|searchFn<T>): Object;
select(instance: Object, find: string|RegExp|Array<string>|Object): Object;
set<T>(instance: Object, key: string, val: T): Object;
size(instance: Object): number;
some<T>(instance: Object, search: T|searchFn<T>): boolean;
subtract(instance: Object, obj: Object): Object;
sum<T, U>(instance: Object, map?: string|mapFn<T, U>): number;
tap(instance: Object, tapFn: (obj: Object) => any): Object;
toQueryString<T, U>(instance: Object, options?: QueryStringOptions<T, U>): Object;
values<T>(instance: Object): T[];
}
interface ChainableBase<RawValue> {
raw: RawValue;
valueOf: () => RawValue;
toString: () => string;
add<T>(obj: Object, options?: ObjectMergeOptions<T>): SugarDefaultChainable<Object>;
addAll<T>(sources: Array<Object>, options?: ObjectMergeOptions<T>): SugarDefaultChainable<Object>;
average<T, U>(map?: string|mapFn<T, U>): SugarDefaultChainable<number>;
clone(deep?: boolean): SugarDefaultChainable<Object>;
count<T>(search: T|searchFn<T>): SugarDefaultChainable<number>;
defaults<T>(sources: Array<Object>, options?: ObjectMergeOptions<T>): SugarDefaultChainable<Object>;
every<T>(search: T|searchFn<T>): SugarDefaultChainable<boolean>;
exclude<T>(search: T|searchFn<T>): SugarDefaultChainable<Object>;
filter<T>(search: T|searchFn<T>): SugarDefaultChainable<T[]>;
find<T>(search: T|searchFn<T>): SugarDefaultChainable<boolean>;
forEach<T>(eachFn: (val: T, key: string, obj: Object) => SugarDefaultChainable<void>): SugarDefaultChainable<Object>;
get<T>(key: string, inherited?: boolean): SugarDefaultChainable<T>;
has(key: string, inherited?: boolean): SugarDefaultChainable<boolean>;