Skip to content

Commit 160a433

Browse files
committed
Merge branch 'develop' of https://github.com/stdlib-js/stdlib into develop
2 parents 23e85e7 + 5e0bb0d commit 160a433

File tree

57 files changed

+1851
-415
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1851
-415
lines changed

lib/node_modules/@stdlib/_tools/static-analysis/js/program-summary/lib/whitespace.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
// MODULES //
2222

23-
var RE_WHITESPACE = require( '@stdlib/regexp/whitespace' );
23+
var reWhitespace = require( '@stdlib/regexp/whitespace' );
2424

2525

2626
// MAIN //
@@ -33,7 +33,7 @@ var RE_WHITESPACE = require( '@stdlib/regexp/whitespace' );
3333
* @returns {NonNegativeInteger} amount of whitespace
3434
*/
3535
function whitespace( str ) {
36-
return str.split( RE_WHITESPACE ).length - 1; // account for assumed trailing newline
36+
return str.split( reWhitespace.REGEXP ).length - 1; // account for assumed trailing newline
3737
}
3838

3939

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2021 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+
/// <reference types="@stdlib/types"/>
22+
23+
import { TypedArray } from '@stdlib/types/array';
24+
import { Collection } from '@stdlib/types/object';
25+
26+
27+
/**
28+
* Array or typed array.
29+
*/
30+
type ArrayOrTypedArray = Array<any> | TypedArray;
31+
32+
/**
33+
* Converts an array to the same data type as a second input array.
34+
*
35+
* @param x - array to convert
36+
* @param y - array having the desired output data type
37+
* @returns output array
38+
*
39+
* @example
40+
* var Float64Array = require( `@stdlib/array/float64` );
41+
*
42+
* var y = new Float64Array( 0 );
43+
*
44+
* var x = [ 1.0, 2.0, 3.0, 4.0 ];
45+
* var out = convertSame( x, y );
46+
* // returns <Float64Array>[ 1.0, 2.0, 3.0, 4.0 ]
47+
*/
48+
declare function convertSame( x: Collection, y: ArrayOrTypedArray ): ArrayOrTypedArray; // tslint:disable-line:max-line-length unified-signatures
49+
50+
51+
// EXPORTS //
52+
53+
export = convertSame;
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2021 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 convertSame = require( './index' );
20+
21+
22+
// TESTS //
23+
24+
// The function returns an array or typed array...
25+
{
26+
const y = new Float64Array( 0 );
27+
28+
convertSame( [ 1.0, 2.0, 3.0, 4.0 ], y ); // $ExpectType ArrayOrTypedArray
29+
}
30+
31+
// The compiler throws an error if the function is provided a first argument which is not array-like...
32+
{
33+
const y = new Float64Array( 0 );
34+
35+
convertSame( 123, y ); // $ExpectError
36+
convertSame( true, y ); // $ExpectError
37+
convertSame( false, y ); // $ExpectError
38+
convertSame( {}, y ); // $ExpectError
39+
convertSame( null, y ); // $ExpectError
40+
convertSame( undefined, y ); // $ExpectError
41+
}
42+
43+
// The compiler throws an error if the function is provided a second argument which is not an array or typed array...
44+
{
45+
const x = [ 1.0, 2.0, 3.0, 4.0 ];
46+
47+
convertSame( x, 'abc' ); // $ExpectError
48+
convertSame( x, 123 ); // $ExpectError
49+
convertSame( x, true ); // $ExpectError
50+
convertSame( x, false ); // $ExpectError
51+
convertSame( x, {} ); // $ExpectError
52+
convertSame( x, null ); // $ExpectError
53+
convertSame( x, undefined ); // $ExpectError
54+
}
55+
56+
// The compiler throws an error if the function is provided an unsupported number of arguments...
57+
{
58+
const x = [ 1.0, 2.0, 3.0, 4.0 ];
59+
const y = new Float64Array( 0 );
60+
61+
convertSame(); // $ExpectError
62+
convertSame( x ); // $ExpectError
63+
convertSame( x, y, 2 ); // $ExpectError
64+
}

lib/node_modules/@stdlib/array/convert-same/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: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2021 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+
/// <reference types="@stdlib/types"/>
22+
23+
import { TypedArray } from '@stdlib/types/array';
24+
import { Collection } from '@stdlib/types/object';
25+
26+
/**
27+
* Array data type.
28+
*/
29+
type DataType = 'float32' | 'float64' | 'generic' | 'int16' | 'int32' | 'int8' | 'uint16' | 'uint32' | 'uint8' | 'uint8c'; // tslint:disable-line:max-line-length unified-signatures
30+
31+
/**
32+
* Array or typed array.
33+
*/
34+
type ArrayOrTypedArray = Array<any> | TypedArray;
35+
36+
/**
37+
* Converts an array to an array of a different data type.
38+
*
39+
* @param x - array to convert
40+
* @param dtype - output data type
41+
* @returns output array
42+
*
43+
* @example
44+
* var arr = [ 1.0, 2.0, 3.0, 4.0 ];
45+
* var out = convert( arr, 'float64' );
46+
* // returns <Float64Array>[ 1.0, 2.0, 3.0, 4.0 ]
47+
*/
48+
declare function convert( x: Collection, dtype: DataType ): ArrayOrTypedArray;
49+
50+
51+
// EXPORTS //
52+
53+
export = convert;
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2021 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 convert = require( './index' );
20+
21+
22+
// TESTS //
23+
24+
// The function returns an array or typed array...
25+
{
26+
convert( [ 1.0, 2.0, 3.0, 4.0 ], 'int32' ); // $ExpectType ArrayOrTypedArray
27+
convert( [ 1.0, 2.0, 3.0, 4.0 ], 'float32' ); // $ExpectType ArrayOrTypedArray
28+
}
29+
30+
// The compiler throws an error if the function is provided a first argument which is not array-like...
31+
{
32+
convert( 123, 'float64' ); // $ExpectError
33+
convert( true, 'float64' ); // $ExpectError
34+
convert( false, 'float64' ); // $ExpectError
35+
convert( {}, 'float64' ); // $ExpectError
36+
convert( null, 'float64' ); // $ExpectError
37+
convert( undefined, 'float64' ); // $ExpectError
38+
}
39+
40+
// The compiler throws an error if the function is provided a second argument which is not a known data type...
41+
{
42+
convert( [ 1, 2, 3, 4 ], 'abc' ); // $ExpectError
43+
convert( [ 1, 2, 3, 4 ], 123 ); // $ExpectError
44+
convert( [ 1, 2, 3, 4 ], [] ); // $ExpectError
45+
convert( [ 1, 2, 3, 4 ], {} ); // $ExpectError
46+
convert( [ 1, 2, 3, 4 ], true ); // $ExpectError
47+
convert( [ 1, 2, 3, 4 ], false ); // $ExpectError
48+
convert( [ 1, 2, 3, 4 ], null ); // $ExpectError
49+
}
50+
51+
// The compiler throws an error if the function is provided an unsupported number of arguments...
52+
{
53+
convert(); // $ExpectError
54+
convert( [ 1.0, 2.0, 3.0, 4.0 ] ); // $ExpectError
55+
convert( [ 1.0, 2.0, 3.0, 4.0 ], 'float64', 2 ); // $ExpectError
56+
}

lib/node_modules/@stdlib/array/convert/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": {

lib/node_modules/@stdlib/array/safe-casts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"test": "./test"
2323
},
2424
"types": "./docs/types",
25-
"scripts": {},
25+
"scripts": {},
2626
"homepage": "https://github.com/stdlib-js/stdlib",
2727
"repository": {
2828
"type": "git",
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) 2021 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 a complex typed array constructor.
23+
*
24+
* @param dtype - data type
25+
* @returns constructor or null
26+
*
27+
* @example
28+
* var ctor = ctors( 'complex128' );
29+
* // returns <Function>
30+
*
31+
* @example
32+
* var ctor = ctors( 'float64' );
33+
* // returns null
34+
*/
35+
declare function ctors( dtype: string ): Function | null;
36+
37+
38+
// EXPORTS //
39+
40+
export = ctors;
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) 2021 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 ctors = require( './index' );
20+
21+
// TESTS //
22+
23+
// The function returns a function or null..
24+
{
25+
ctors( 'complex128' ); // $ExpectType Function | null
26+
ctors( 'float' ); // $ExpectType Function | null
27+
}
28+
29+
// The compiler throws an error if the function is provided an unsupported number of arguments...
30+
{
31+
ctors(); // $ExpectError
32+
ctors( 'complex128', 3 ); // $ExpectError
33+
}

0 commit comments

Comments
 (0)