Skip to content

Commit b1e0bcd

Browse files
committed
Add Typescript definitions
1 parent f33da83 commit b1e0bcd

6 files changed

Lines changed: 186 additions & 0 deletions

File tree

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
* Removes the first character of a string.
23+
*
24+
* @param str - input string
25+
* @returns updated string
26+
*
27+
* @example
28+
* var out = removeFirst( 'last man standing' );
29+
* // returns 'ast man standing'
30+
*
31+
* @example
32+
* var out = removeFirst( 'presidential election' );
33+
* // returns 'residential election'
34+
*
35+
* @example
36+
* var out = removeFirst( 'javaScript' );
37+
* // returns 'avaScript'
38+
*
39+
* @example
40+
* var out = removeFirst( 'Hidden Treasures' );
41+
* // returns 'idden Treasures'
42+
*/
43+
declare function removeFirst( str: string ): string;
44+
45+
46+
// EXPORTS //
47+
48+
export = removeFirst;
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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 removeFirst = require( './index' );
20+
21+
22+
// TESTS //
23+
24+
// The function returns a string...
25+
{
26+
removeFirst( 'abc' ); // $ExpectType string
27+
}
28+
29+
// The function does not compile if provided a value other than a number...
30+
{
31+
removeFirst( true ); // $ExpectError
32+
removeFirst( false ); // $ExpectError
33+
removeFirst( null ); // $ExpectError
34+
removeFirst( undefined ); // $ExpectError
35+
removeFirst( 5 ); // $ExpectError
36+
removeFirst( [] ); // $ExpectError
37+
removeFirst( {} ); // $ExpectError
38+
removeFirst( ( x: number ): number => x ); // $ExpectError
39+
}
40+
41+
// The function does not compile if provided insufficient arguments...
42+
{
43+
removeFirst(); // $ExpectError
44+
}

lib/node_modules/@stdlib/string/remove-first/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"lib": "./lib",
2626
"test": "./test"
2727
},
28+
"types": "./docs/types",
2829
"scripts": {},
2930
"homepage": "https://github.com/stdlib-js/stdlib",
3031
"repository": {
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
* Removes the last character of a string.
23+
*
24+
* @param str - input string
25+
* @returns updated string
26+
*
27+
* @example
28+
* var out = removeLast( 'last man standing' );
29+
* // returns 'last man standin'
30+
*
31+
* @example
32+
* var out = removeLast( 'presidential election' );
33+
* // returns 'presidential electio'
34+
*
35+
* @example
36+
* var out = removeLast( 'javaScript' );
37+
* // returns 'javaScrip'
38+
*
39+
* @example
40+
* var out = removeLast( 'Hidden Treasures' );
41+
* // returns 'Hidden Treasure'
42+
*/
43+
declare function removeLast( str: string ): string;
44+
45+
46+
// EXPORTS //
47+
48+
export = removeLast;
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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 removeFirst = require( './index' );
20+
21+
22+
// TESTS //
23+
24+
// The function returns a string...
25+
{
26+
removeFirst( 'abc' ); // $ExpectType string
27+
}
28+
29+
// The function does not compile if provided a value other than a number...
30+
{
31+
removeFirst( true ); // $ExpectError
32+
removeFirst( false ); // $ExpectError
33+
removeFirst( null ); // $ExpectError
34+
removeFirst( undefined ); // $ExpectError
35+
removeFirst( 5 ); // $ExpectError
36+
removeFirst( [] ); // $ExpectError
37+
removeFirst( {} ); // $ExpectError
38+
removeFirst( ( x: number ): number => x ); // $ExpectError
39+
}
40+
41+
// The function does not compile if provided insufficient arguments...
42+
{
43+
removeFirst(); // $ExpectError
44+
}

lib/node_modules/@stdlib/string/remove-last/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"lib": "./lib",
2626
"test": "./test"
2727
},
28+
"types": "./docs/types",
2829
"scripts": {},
2930
"homepage": "https://github.com/stdlib-js/stdlib",
3031
"repository": {

0 commit comments

Comments
 (0)