Skip to content

Commit 74e9945

Browse files
committed
Merge branch 'develop' of https://github.com/stdlib-js/stdlib into develop
2 parents 6677a7e + 0ac74a9 commit 74e9945

File tree

70 files changed

+3284
-30
lines changed

Some content is hidden

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

70 files changed

+3284
-30
lines changed

lib/node_modules/@stdlib/assert/is-float64array/docs/types/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* @returns boolean indicating whether value is a Float64Array
2626
*
2727
* @example
28-
* var Float64Array = require( '@stdlib/array/float64' );
28+
* var Float64Array = require( `@stdlib/array/float64` );
2929
*
3030
* var bool = isFloat64Array( new Float64Array( 10 ) );
3131
* // returns true

lib/node_modules/@stdlib/utils/append/docs/types/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import { Collection } from '@stdlib/types/object';
3636
* // returns [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0 ]
3737
*
3838
* @example
39-
* var Float64Array = require( '@stdlib/array/float64' );
39+
* var Float64Array = require( `@stdlib/array/float64` );
4040
*
4141
* var arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0 ] );
4242
* // returns <Float64Array>[ 1.0, 2.0, 3.0, 4.0, 5.0 ]

lib/node_modules/@stdlib/utils/bifurcate-by/docs/types/index.d.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222

2323
import { Collection } from '@stdlib/types/object';
2424

25-
type Returns = 'values' | 'indices' | '*';
26-
2725
/**
2826
* Interface defining function options.
2927
*/
@@ -34,9 +32,9 @@ interface Options {
3432
thisArg?: any;
3533

3634
/**
37-
* If `values`, values are returned; if `indices`, indices are returned; if `*`, both indices and values are returned.
35+
* If `'values'`, values are returned; if `'indices'`, indices are returned; if `'*'`, both indices and values are returned.
3836
*/
39-
returns?: Returns;
37+
returns?: 'values' | 'indices' | '*';
4038
}
4139

4240
/**
@@ -120,11 +118,10 @@ declare function bifurcateBy( collection: Collection, predicate: Predicate ): Ar
120118
* @param collection - input collection
121119
* @param options - function options
122120
* @param options.thisArg - execution context
123-
* @param options.returns - if `values`, values are returned; if `indices`, indices are returned; if `*`, both indices and values are returned (default: 'values')
121+
* @param options.returns - if `'values'`, values are returned; if `'indices'`, indices are returned; if `'*'`, both indices and values are returned (default: 'values')
124122
* @param predicate - predicate function indicating which group an element in the input collection belongs to
125123
* @returns group results
126124
*
127-
*
128125
* @example
129126
* function predicate( v ) {
130127
* return v[ 0 ] === 'b';

lib/node_modules/@stdlib/utils/bifurcate-by/docs/types/test.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const predicate = ( v: Array<any> ): boolean => v[ 0 ] === 'b';
2323

2424
// TESTS //
2525

26-
// The function returns an an array of arrays...
26+
// The function returns an array of arrays...
2727
{
2828
bifurcateBy( [ 'beep', 'boop', 'foo', 'bar' ], predicate ); // $ExpectType any[][]
2929
bifurcateBy( [], predicate ); // $ExpectType any[][]
@@ -33,6 +33,13 @@ const predicate = ( v: Array<any> ): boolean => v[ 0 ] === 'b';
3333
bifurcateBy( [ 'beep', 'boop', 'foo', 'bar' ], opts, predicate ); // $ExpectType any[][]
3434
}
3535

36+
// The compiler throws an error if the function is provided a first argument which is not a collection...
37+
{
38+
bifurcateBy( true, predicate ); // $ExpectError
39+
bifurcateBy( false, predicate ); // $ExpectError
40+
bifurcateBy( 5, predicate ); // $ExpectError
41+
}
42+
3643
// The compiler throws an error if the function is provided a last argument which is not a function...
3744
{
3845
const arr = [ 'beep', 'boop', 'foo', 'bar' ];

lib/node_modules/@stdlib/utils/bifurcate-in/docs/types/index.d.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818

1919
// TypeScript Version: 2.0
2020

21-
type Returns = 'values' | 'indices' | '*';
22-
2321
/**
2422
* Interface defining function options.
2523
*/
@@ -30,9 +28,9 @@ interface Options {
3028
thisArg?: any;
3129

3230
/**
33-
* If `values`, values are returned; if `indices`, indices are returned; if `*`, both indices and values are returned.
31+
* If `'values'`, values are returned; if `'indices'`, indices are returned; if `'*'`, both indices and values are returned.
3432
*/
35-
returns?: Returns;
33+
returns?: 'values' | 'indices' | '*';
3634
}
3735

3836
/**
@@ -133,11 +131,10 @@ declare function bifurcateIn( obj: any, predicate: Predicate ): Array<Array<any>
133131
* @param input object
134132
* @param options - function options
135133
* @param options.thisArg - execution context
136-
* @param options.returns - if `values`, values are returned; if `keys`, keys are returned; if `*`, both keys and values are returned (default: 'values')
134+
* @param options.returns - if `'values'`, values are returned; if `'keys'`, keys are returned; if `'*'`, both keys and values are returned (default: 'values')
137135
* @param predicate - predicate function indicating which group an element in the input object belongs to
138136
* @returns group results
139137
*
140-
*
141138
* @example
142139
* function predicate( v ) {
143140
* return v[ 0 ] === 'b';

lib/node_modules/@stdlib/utils/bifurcate-in/docs/types/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class Foo {
4343

4444
// TESTS //
4545

46-
// The function returns an an array of arrays...
46+
// The function returns an array of arrays...
4747
{
4848
const obj = new Foo();
4949
bifurcateIn( obj, predicate ); // $ExpectType any[][]

lib/node_modules/@stdlib/utils/bifurcate-own/docs/types/index.d.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818

1919
// TypeScript Version: 2.0
2020

21-
type Returns = 'values' | 'indices' | '*';
22-
2321
/**
2422
* Interface defining function options.
2523
*/
@@ -30,9 +28,9 @@ interface Options {
3028
thisArg?: any;
3129

3230
/**
33-
* If `values`, values are returned; if `indices`, indices are returned; if `*`, both indices and values are returned.
31+
* If `'values'`, values are returned; if `'indices'`, indices are returned; if `'*'`, both indices and values are returned.
3432
*/
35-
returns?: Returns;
33+
returns?: 'values' | 'indices' | '*';
3634
}
3735

3836
/**
@@ -128,7 +126,7 @@ declare function bifurcateOwn( obj: any, predicate: Predicate ): Array<Array<any
128126
* @param obj - input object
129127
* @param options - function options
130128
* @param options.thisArg - execution context
131-
* @param options.returns - if `values`, values are returned; if `keys`, keys are returned; if `*`, both keys and values are returned
129+
* @param options.returns - if `'values'`, values are returned; if `'keys'`, keys are returned; if `'*'`, both keys and values are returned
132130
* @param predicate - predicate function indicating which group an element in the input object belongs to
133131
* @returns group results
134132
*

lib/node_modules/@stdlib/utils/bifurcate-own/docs/types/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class Foo {
4343

4444
// TESTS //
4545

46-
// The function returns an an array of arrays...
46+
// The function return an array of arrays...
4747
{
4848
const obj = new Foo();
4949
bifurcateOwn( obj, predicate ); // $ExpectType any[][]
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
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+
/// <reference types="@stdlib/types"/>
22+
23+
import { Collection } from '@stdlib/types/object';
24+
25+
/**
26+
* Interface defining function options.
27+
*/
28+
interface Options {
29+
/**
30+
* If `'values'`, values are returned; if `'indices'`, indices are returned; if `'*'`, both indices and values are returned.
31+
*/
32+
returns?: 'values' | 'indices' | '*';
33+
}
34+
35+
/**
36+
* Splits values into two groups.
37+
*
38+
* ## Notes
39+
*
40+
* - If an element in `filter` is truthy, then the corresponding element in the input collection belongs to the first group; otherwise, the collection element belongs to the second group.
41+
* - If provided an empty collection, the function returns an empty array.
42+
*
43+
* @param collection - input collection
44+
* @param filter - collection indicating which group an element in the input collection belongs to
45+
* @throws first and last arguments must be the same length
46+
* @returns results
47+
*
48+
* @example
49+
* var arr = [ 'beep', 'boop', 'foo', 'bar' ];
50+
* var filter = [ true, true, false, true ];
51+
*
52+
* var out = bifurcate( arr, filter );
53+
* // returns [ [ 'beep', 'boop', 'bar' ], [ 'foo' ] ]
54+
*/
55+
declare function bifurcate( collection: Collection, filter: Collection ): Array<Array<any>> | Array<any>; // tslint-disable-line max-line-length
56+
57+
/**
58+
* Splits values into two groups.
59+
*
60+
* ## Notes
61+
*
62+
* - If an element in `filter` is truthy, then the corresponding element in the input collection belongs to the first group; otherwise, the collection element belongs to the second group.
63+
* - If provided an empty collection, the function returns an empty array.
64+
*
65+
* @param collection - input collection
66+
* @param options - function options
67+
* @param options.returns - if `values`, values are returned; if `indices`, indices are returned; if `*`, both indices and values are returned (default: 'values')
68+
* @param filter - collection indicating which group an element in the input collection belongs to
69+
* @throws first and last arguments must be the same length
70+
* @returns results
71+
*
72+
* @example
73+
* var arr = [ 'beep', 'boop', 'foo', 'bar' ];
74+
* var filter = [ true, true, false, true ];
75+
*
76+
* var opts = {
77+
* 'returns': 'indices'
78+
* };
79+
*
80+
* var out = bifurcate( arr, opts, filter );
81+
* // returns [ [ 0, 1, 3 ], [ 2 ] ]
82+
*
83+
* @example
84+
* var arr = [ 'beep', 'boop', 'foo', 'bar' ];
85+
* var filter = [ true, true, false, true ];
86+
*
87+
* var opts = {
88+
* 'returns': '*'
89+
* };
90+
*
91+
* var out = bifurcate( arr, opts, filter );
92+
* // returns [ [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], [ [ 2, 'foo' ] ] ]
93+
*/
94+
declare function bifurcate( collection: Collection, options: Options, filter: Collection ): Array<Array<any>> | Array<any>; // tslint-disable-line max-line-length
95+
96+
97+
// EXPORTS //
98+
99+
export = bifurcate;
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
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 bifurcate = require( './index' );
20+
21+
22+
// TESTS //
23+
24+
// The function returns an array of arrays...
25+
{
26+
bifurcate( [ 'beep', 'boop', 'foo', 'bar' ], [ true, true, false, true ] ); // $ExpectType any[] | any[][]
27+
const opts = {
28+
'returns': 'indices' as 'indices'
29+
};
30+
bifurcate( [ 'beep', 'boop', 'foo', 'bar' ], opts, [ true, true, false, true ] ); // $ExpectType any[] | any[][]
31+
}
32+
33+
// The compiler throws an error if the function is provided a first argument which is not a collection...
34+
{
35+
bifurcate( true, [ true, true, false, true ] ); // $ExpectError
36+
bifurcate( false, [ true, true, false, true ] ); // $ExpectError
37+
bifurcate( 5, [ true, true, false, true ] ); // $ExpectError
38+
}
39+
40+
// The compiler throws an error if the function is provided a last argument which is not a collection...
41+
{
42+
const arr = [ 'beep', 'boop', 'foo', 'bar' ];
43+
bifurcate( arr, false ); // $ExpectError
44+
bifurcate( arr, true ); // $ExpectError
45+
bifurcate( arr, 32 ); // $ExpectError
46+
bifurcate( arr, {} ); // $ExpectError
47+
48+
bifurcate( arr, {}, false ); // $ExpectError
49+
bifurcate( arr, {}, true ); // $ExpectError
50+
bifurcate( arr, {}, 32 ); // $ExpectError
51+
bifurcate( arr, {}, {} ); // $ExpectError
52+
}
53+
54+
// The compiler throws an error if the function is provided an options argument which is not an object...
55+
{
56+
const arr = [ 'beep', 'boop', 'foo', 'bar' ];
57+
const filter = [ true, true, false, true ];
58+
bifurcate( arr, null, filter ); // $ExpectError
59+
}
60+
61+
// The compiler throws an error if the function is provided a `returns` option which is not one of 'indices', 'values', or '*'...
62+
{
63+
const arr = [ 'beep', 'boop', 'foo', 'bar' ];
64+
const filter = [ true, true, false, true ];
65+
bifurcate( arr, { 'returns': '5' }, filter ); // $ExpectError
66+
bifurcate( arr, { 'returns': 123 }, filter ); // $ExpectError
67+
bifurcate( arr, { 'returns': [] }, filter ); // $ExpectError
68+
bifurcate( arr, { 'returns': {} }, filter ); // $ExpectError
69+
bifurcate( arr, { 'returns': ( x: number ): number => x }, filter ); // $ExpectError
70+
}
71+
72+
// The compiler throws an error if the function is provided an invalid number of arguments...
73+
{
74+
const arr = [ 'beep', 'boop', 'foo', 'bar' ];
75+
const filter = [ true, true, false, true ];
76+
bifurcate(); // $ExpectError
77+
bifurcate( arr ); // $ExpectError
78+
bifurcate( arr, {}, filter, 16 ); // $ExpectError
79+
}

0 commit comments

Comments
 (0)