Skip to content

Commit a91d4cc

Browse files
committed
Add Typescript definitions
1 parent b3c5e65 commit a91d4cc

File tree

9 files changed

+265
-0
lines changed

9 files changed

+265
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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+
* Tests if a value is an alphagram (i.e., a sequence of characters arranged in alphabetical order).
23+
*
24+
* ## Notes
25+
*
26+
* - The function first checks that an input value is a string before validating that the value is an alphagram. For non-string values, the function returns `false`.
27+
*
28+
* @param x - value to test
29+
* @returns boolean indicating if a value is an alphagram
30+
*
31+
* @example
32+
* var out = isAlphagram( 'beep' );
33+
* // returns true
34+
*
35+
* @example
36+
* var out = isAlphagram( new String( 'beep' ) );
37+
* // returns true
38+
*
39+
* @example
40+
* var out = isAlphagram( 'zba' );
41+
* // returns false
42+
*
43+
* @example
44+
* var out = isAlphagram( '' );
45+
* // returns false
46+
*
47+
* @example
48+
* var out = isAlphagram( 123 );
49+
* // returns false
50+
*/
51+
declare function isAlphagram( value: any ): boolean;
52+
53+
54+
// EXPORTS //
55+
56+
export = isAlphagram;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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 isAlphagram = require( './index' );
20+
21+
22+
// TESTS //
23+
24+
// The function returns a boolean...
25+
{
26+
isAlphagram( 'beep' ); // $ExpectType boolean
27+
isAlphagram( 'zba' ); // $ExpectType boolean
28+
}
29+
30+
// The compiler throws an error if the function is provided an unsupported number of arguments...
31+
{
32+
isAlphagram(); // $ExpectError
33+
isAlphagram( undefined, 123 ); // $ExpectError
34+
}

lib/node_modules/@stdlib/assert/is-alphagram/package.json

+1
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": {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
* Tests whether a string contains only alphanumeric characters.
23+
*
24+
* @param x - value to test
25+
* @returns boolean indicating if a string contains only alphanumeric characters
26+
*
27+
* @example
28+
* var out = isAlphaNumeric( 'abc123def456' );
29+
* // returns true
30+
*
31+
* @example
32+
* var out = isAlphaNumeric( '0xffffff' );
33+
* // returns true
34+
*
35+
* @example
36+
* var out = isAlphaNumeric( '123' );
37+
* // returns true
38+
*
39+
* @example
40+
* var out = isAlphaNumeric( '' );
41+
* // returns false
42+
*
43+
* @example
44+
* var out = isAlphaNumeric( 123 );
45+
* // returns false
46+
*/
47+
declare function isAlphaNumeric( value: any ): boolean;
48+
49+
50+
// EXPORTS //
51+
52+
export = isAlphaNumeric;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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 isAlphaNumeric = require( './index' );
20+
21+
22+
// TESTS //
23+
24+
// The function returns a boolean...
25+
{
26+
isAlphaNumeric( '0xffffff' ); // $ExpectType boolean
27+
isAlphaNumeric( '' ); // $ExpectType boolean
28+
}
29+
30+
// The compiler throws an error if the function is provided an unsupported number of arguments...
31+
{
32+
isAlphaNumeric(); // $ExpectError
33+
isAlphaNumeric( undefined, 123 ); // $ExpectError
34+
}

lib/node_modules/@stdlib/assert/is-alphanumeric/package.json

+1
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": {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
* Tests if a value is an anagram.
23+
*
24+
* @param str - comparison string
25+
* @param x - value to test
26+
* @returns boolean indicating if a value is an anagram
27+
*
28+
* @example
29+
* var bool = isAnagram( 'I am a weakish speller', 'William Shakespeare' );
30+
* // returns true
31+
*
32+
* @example
33+
* var bool = isAnagram( 'bat', 'tabba' );
34+
* // returns false
35+
*/
36+
declare function isAnagram( str: string, x: any ): boolean;
37+
38+
39+
// EXPORTS //
40+
41+
export = isAnagram;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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 isAnagram = require( './index' );
20+
21+
22+
// TESTS //
23+
24+
// The function returns a boolean...
25+
{
26+
isAnagram( 'I am a weakish speller', 'William Shakespeare' ); // $ExpectType boolean
27+
isAnagram( 'bat', 'tabba' ); // $ExpectType boolean
28+
}
29+
30+
// The compiler throws an error if the returned accumulator function is provided invalid arguments...
31+
{
32+
isAnagram( 5, 'a' ); // $ExpectError
33+
isAnagram( true, 'a' ); // $ExpectError
34+
isAnagram( false, 'a' ); // $ExpectError
35+
isAnagram( null, 'a' ); // $ExpectError
36+
isAnagram( {}, 'a' ); // $ExpectError
37+
isAnagram( [], 'a' ); // $ExpectError
38+
isAnagram( ( x: number ): number => x, 'a' ); // $ExpectError
39+
}
40+
41+
// The compiler throws an error if the function is provided an unsupported number of arguments...
42+
{
43+
isAnagram(); // $ExpectError
44+
isAnagram( 'bat' ); // $ExpectError
45+
}

lib/node_modules/@stdlib/assert/is-anagram/package.json

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