Skip to content

Commit 41fce82

Browse files
authored
Merge pull request #11 from MrSpoocy/master
Add JSON & TypeScript-Definitions, version 0.3.0
2 parents aabdf3c + 78e6f25 commit 41fce82

File tree

12 files changed

+2574
-820
lines changed

12 files changed

+2574
-820
lines changed

Array.d.ts

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
/*! *****************************************************************************
2+
Copyright (c) Microsoft Corporation. All rights reserved.
3+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4+
this file except in compliance with the License. You may obtain a copy of the
5+
License at http://www.apache.org/licenses/LICENSE-2.0
6+
7+
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8+
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
9+
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
10+
MERCHANTABLITY OR NON-INFRINGEMENT.
11+
12+
See the Apache Version 2.0 License for specific language governing permissions
13+
and limitations under the License.
14+
***************************************************************************** */
15+
16+
interface ArrayConstructor {
17+
isArray(arg: any): arg is any[];
18+
}
19+
20+
interface Array<T> {
21+
/**
22+
* Determines whether all the members of an array satisfy the specified test.
23+
* @param callbackfn A function that accepts up to three arguments. The every method calls
24+
* the callbackfn function for each element in the array until the callbackfn returns a value
25+
* which is coercible to the Boolean value false, or until the end of the array.
26+
* @param thisArg An object to which the this keyword can refer in the callbackfn function.
27+
* If thisArg is omitted, undefined is used as the this value.
28+
*/
29+
every(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean;
30+
31+
/**
32+
* Returns the elements of an array that meet the condition specified in a callback function.
33+
* @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array.
34+
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
35+
*/
36+
filter<S extends T>(callbackfn: (value: T, index: number, array: T[]) => value is S, thisArg?: any): S[];
37+
38+
/**
39+
* Returns the elements of an array that meet the condition specified in a callback function.
40+
* @param callbackfn A function that accepts up to three arguments. The filter method calls the callbackfn function one time for each element in the array.
41+
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
42+
*/
43+
filter(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): T[];
44+
45+
/**
46+
* Performs the specified action for each element in an array.
47+
* @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.
48+
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
49+
*/
50+
forEach(callbackfn: (value: T, index: number, array: T[]) => void, thisArg?: any): void;
51+
52+
/**
53+
* Returns the index of the first occurrence of a value in an array.
54+
* @param searchElement The value to locate in the array.
55+
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0.
56+
*/
57+
indexOf(searchElement: T, fromIndex?: number): number;
58+
59+
/**
60+
* Returns the index of the last occurrence of a specified value in an array.
61+
* @param searchElement The value to locate in the array.
62+
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at the last index in the array.
63+
*/
64+
lastIndexOf(searchElement: T, fromIndex?: number): number;
65+
66+
/**
67+
* Calls a defined callback function on each element of an array, and returns an array that contains the results.
68+
* @param callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
69+
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
70+
*/
71+
map<U>(callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): U[];
72+
73+
/**
74+
* Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
75+
* @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.
76+
*/
77+
reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T;
78+
79+
/**
80+
* Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
81+
* @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.
82+
* @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.
83+
*/
84+
reduce(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T;
85+
86+
/**
87+
* Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
88+
* @param callbackfn A function that accepts up to four arguments. The reduce method calls the callbackfn function one time for each element in the array.
89+
* @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.
90+
*/
91+
reduce<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U;
92+
93+
/**
94+
* Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
95+
* @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array.
96+
*/
97+
reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T): T;
98+
99+
/**
100+
* Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
101+
* @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array.
102+
* @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.
103+
*/
104+
reduceRight(callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T;
105+
106+
/**
107+
* Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
108+
* @param callbackfn A function that accepts up to four arguments. The reduceRight method calls the callbackfn function one time for each element in the array.
109+
* @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.
110+
*/
111+
reduceRight<U>(callbackfn: (previousValue: U, currentValue: T, currentIndex: number, array: T[]) => U, initialValue: U): U;
112+
113+
/**
114+
* Determines whether the specified callback function returns true for any element of an array.
115+
* @param callbackfn A function that accepts up to three arguments. The some method calls
116+
* the callbackfn function for each element in the array until the callbackfn returns a value
117+
* which is coercible to the Boolean value true, or until the end of the array.
118+
* @param thisArg An object to which the this keyword can refer in the callbackfn function.
119+
* If thisArg is omitted, undefined is used as the this value.
120+
*/
121+
some(callbackfn: (value: T, index: number, array: T[]) => unknown, thisArg?: any): boolean;
122+
}
123+
124+
declare var Array: ArrayConstructor;

Date.d.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*! *****************************************************************************
2+
Copyright (c) Microsoft Corporation. All rights reserved.
3+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4+
this file except in compliance with the License. You may obtain a copy of the
5+
License at http://www.apache.org/licenses/LICENSE-2.0
6+
7+
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8+
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
9+
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
10+
MERCHANTABLITY OR NON-INFRINGEMENT.
11+
12+
See the Apache Version 2.0 License for specific language governing permissions
13+
and limitations under the License.
14+
***************************************************************************** */
15+
16+
/** Enables basic storage and retrieval of dates and times. */
17+
interface Date {
18+
/** Returns a date as a string value in ISO format. */
19+
toISOString(): string;
20+
}

Function.d.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*! *****************************************************************************
2+
Copyright (c) Microsoft Corporation. All rights reserved.
3+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4+
this file except in compliance with the License. You may obtain a copy of the
5+
License at http://www.apache.org/licenses/LICENSE-2.0
6+
7+
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8+
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
9+
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
10+
MERCHANTABLITY OR NON-INFRINGEMENT.
11+
12+
See the Apache Version 2.0 License for specific language governing permissions
13+
and limitations under the License.
14+
***************************************************************************** */
15+
16+
/**
17+
* Creates a new function.
18+
*/
19+
interface Function {
20+
/**
21+
* For a given function, creates a bound function that has the same body as the original function.
22+
* The this object of the bound function is associated with the specified object, and has the specified initial parameters.
23+
* @param thisArg An object to which the this keyword can refer inside the new function.
24+
* @param argArray A list of arguments to be passed to the new function.
25+
*/
26+
bind(this: Function, thisArg: any, ...argArray: any[]): any;
27+
}

JSON.d.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*! *****************************************************************************
2+
Copyright (c) Microsoft Corporation. All rights reserved.
3+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4+
this file except in compliance with the License. You may obtain a copy of the
5+
License at http://www.apache.org/licenses/LICENSE-2.0
6+
7+
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8+
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
9+
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
10+
MERCHANTABLITY OR NON-INFRINGEMENT.
11+
12+
See the Apache Version 2.0 License for specific language governing permissions
13+
and limitations under the License.
14+
***************************************************************************** */
15+
16+
interface JSON {
17+
/**
18+
* Converts a JavaScript Object Notation (JSON) string into an object.
19+
* @param text A valid JSON string.
20+
* @param reviver A function that transforms the results. This function is called for each member of the object.
21+
* If a member contains nested objects, the nested objects are transformed before the parent object is.
22+
*/
23+
parse(text: string, reviver?: (this: any, key: string, value: any) => any): any;
24+
25+
/**
26+
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
27+
* @param value A JavaScript value, usually an object or array, to be converted.
28+
* @param replacer A function that transforms the results.
29+
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
30+
*/
31+
stringify(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string;
32+
33+
/**
34+
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
35+
* @param value A JavaScript value, usually an object or array, to be converted.
36+
* @param replacer An array of strings and numbers that acts as a approved list for selecting the object properties that will be stringified.
37+
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
38+
*/
39+
stringify(value: any, replacer?: (number | string)[] | null, space?: string | number): string;
40+
}
41+
42+
/**
43+
* An intrinsic object that provides functions to convert JavaScript values to and from the JavaScript Object Notation (JSON) format.
44+
*/
45+
declare var JSON: JSON;

0 commit comments

Comments
 (0)