Skip to content

Commit eb9a872

Browse files
committed
Add Typescript definitions
1 parent 2fb004d commit eb9a872

File tree

6 files changed

+160
-0
lines changed

6 files changed

+160
-0
lines changed
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+
* Converts the first letter of each object key to uppercase.
23+
*
24+
* ## Notes
25+
*
26+
* - The function only transforms own properties. Hence, the function does not transform inherited properties.
27+
* - The function shallow copies key values.
28+
*
29+
* @param obj - source object
30+
* @returns new object
31+
*
32+
* @example
33+
* var obj1 = {
34+
* 'aa': 1,
35+
* 'bb': 2
36+
* };
37+
*
38+
* var obj2 = capitalizeKeys( obj1 );
39+
* // returns { 'Aa': 1, 'Bb': 2 }
40+
*/
41+
declare function capitalizeKeys( obj: Object ): Object;
42+
43+
44+
// EXPORTS //
45+
46+
export = capitalizeKeys;
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 capitalizeKeys = require( './index' );
20+
21+
22+
// TESTS //
23+
24+
// The function returns an object...
25+
{
26+
capitalizeKeys( { 'a': 1, 'b': 2 } ); // $ExpectType Object
27+
}
28+
29+
// The compiler throws an error if the function is provided an incorrect number of arguments...
30+
{
31+
capitalizeKeys(); // $ExpectError
32+
capitalizeKeys( [], 2 ); // $ExpectError
33+
}

lib/node_modules/@stdlib/utils/capitalize-keys/package.json

+1
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": {
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+
* Converts the first letter of each object key to lowercase.
23+
*
24+
* ## Notes
25+
*
26+
* - The function only transforms own properties. Hence, the function does not transform inherited properties.
27+
* - The function shallow copies key values.
28+
*
29+
* @param obj - source object
30+
* @returns new object
31+
*
32+
* @example
33+
* var obj1 = {
34+
* 'AA': 1,
35+
* 'BB': 2
36+
* };
37+
*
38+
* var obj2 = uncapitalizeKeys( obj1 );
39+
* // returns { 'aA': 1, 'bB': 2 }
40+
*/
41+
declare function uncapitalizeKeys( obj: Object ): Object;
42+
43+
44+
// EXPORTS //
45+
46+
export = uncapitalizeKeys;
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 uncapitalizeKeys = require( './index' );
20+
21+
22+
// TESTS //
23+
24+
// The function returns an object...
25+
{
26+
uncapitalizeKeys( { 'a': 1, 'b': 2 } ); // $ExpectType Object
27+
}
28+
29+
// The compiler throws an error if the function is provided an incorrect number of arguments...
30+
{
31+
uncapitalizeKeys(); // $ExpectError
32+
uncapitalizeKeys( [], 2 ); // $ExpectError
33+
}

lib/node_modules/@stdlib/utils/uncapitalize-keys/package.json

+1
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)