Skip to content

Commit 96bc87c

Browse files
committed
Add Typescript definitions
1 parent eb9a872 commit 96bc87c

File tree

6 files changed

+154
-0
lines changed

6 files changed

+154
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2019 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
// TypeScript Version: 2.0
20+
21+
/**
22+
* Returns an array of an object's own and inherited property names and symbols.
23+
*
24+
* ## Notes
25+
*
26+
* - If provided `null` or `undefined`, the function returns an empty array.
27+
*
28+
* @param value - input object
29+
* @returns a list of own and inherited property names and symbols
30+
*
31+
* @example
32+
* var props = propertiesIn( [] );
33+
* // returns [...]
34+
*/
35+
declare function propertiesIn( value: any ): Array<string|symbol>;
36+
37+
38+
// EXPORTS //
39+
40+
export = propertiesIn;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2019 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
import propertiesIn = require( './index' );
20+
21+
22+
// TESTS //
23+
24+
// The function returns an array of strings or symbols...
25+
{
26+
propertiesIn( { 'beep': 'boop', 'foo': 3.14 } ); // $ExpectType (string | symbol)[]
27+
}
28+
29+
// The compiler throws an error if the function is provided an incorrect number of arguments...
30+
{
31+
propertiesIn(); // $ExpectError
32+
propertiesIn( [], 2 ); // $ExpectError
33+
}

lib/node_modules/@stdlib/utils/properties-in/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"lib": "./lib",
2222
"test": "./test"
2323
},
24+
"types": "./docs/types",
2425
"scripts": {},
2526
"homepage": "https://github.com/stdlib-js/stdlib",
2627
"repository": {
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2019 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
// TypeScript Version: 2.0
20+
21+
/**
22+
* Returns an array of an object's own enumerable and non-enumerable property names and symbols.
23+
*
24+
* ## Notes
25+
*
26+
* - Property order is not guaranteed, as object property enumeration is not specified according to the ECMAScript specification. In practice, however, most engines use insertion order to sort an object's properties, thus allowing for deterministic extraction.
27+
* - If provided `null` or `undefined`, the function returns an empty array.
28+
*
29+
* @param value - input object
30+
* @returns a list of own property names and symbols
31+
*
32+
* @example
33+
* var obj = {
34+
* 'beep': 'boop',
35+
* 'foo': 3.14
36+
* };
37+
*
38+
* var props = properties( obj );
39+
* // e.g., returns [ 'beep', 'foo' ]
40+
*/
41+
declare function properties( value: any ): Array<string|symbol>;
42+
43+
44+
// EXPORTS //
45+
46+
export = properties;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2019 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
import properties = require( './index' );
20+
21+
22+
// TESTS //
23+
24+
// The function returns an array of strings or symbols...
25+
{
26+
properties( { 'beep': 'boop', 'foo': 3.14 } ); // $ExpectType (string | symbol)[]
27+
}
28+
29+
// The compiler throws an error if the function is provided an incorrect number of arguments...
30+
{
31+
properties(); // $ExpectError
32+
properties( [], 2 ); // $ExpectError
33+
}

lib/node_modules/@stdlib/utils/properties/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"lib": "./lib",
2222
"test": "./test"
2323
},
24+
"types": "./docs/types",
2425
"scripts": {},
2526
"homepage": "https://github.com/stdlib-js/stdlib",
2627
"repository": {

0 commit comments

Comments
 (0)