-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1a0162c
commit 9286669
Showing
12 changed files
with
632 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ Dominik Moritz <[email protected]> | |
Dorrin Sotoudeh <[email protected]> | ||
Frank Kovacs <[email protected]> | ||
GUNJ JOSHI <[email protected]> | ||
Golden <[email protected]> | ||
Harshita Kalani <[email protected]> | ||
James Gelok <[email protected]> | ||
Jaysukh Makvana <[email protected]> | ||
|
@@ -24,6 +25,7 @@ Jordan Gallivan <[email protected]> | |
Joris Labie <[email protected]> | ||
Justin Dennison <[email protected]> | ||
Karthik Prakash <[email protected]> | ||
Khaldon <[email protected]> | ||
Marcus Fantham <[email protected]> | ||
Matt Cochrane <[email protected]> | ||
Milan Raj <[email protected]> | ||
|
@@ -32,6 +34,7 @@ Naresh Jagadeesan <[email protected]> | |
Nithin Katta <[email protected]> | ||
Ognjen Jevremović <[email protected]> | ||
Philipp Burckhardt <[email protected]> | ||
Prajwal Kulkarni <[email protected]> | ||
Pranav Goswami <[email protected]> | ||
Ricky Reusser <[email protected]> | ||
Robert Gislason <[email protected]> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<!-- | ||
@license Apache-2.0 | ||
Copyright (c) 2024 The Stdlib Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
|
||
# isRaggedNestedArray | ||
|
||
> Test if a value is a ragged nested array. | ||
<section class="usage"> | ||
|
||
## Usage | ||
|
||
```javascript | ||
var isRaggedNestedArray = require( '@stdlib/assert/is-ragged-nested-array' ); | ||
``` | ||
|
||
#### isRaggedNestedArray( value ) | ||
|
||
Tests if a value is a ragged nested array. | ||
|
||
```javascript | ||
var bool = isRaggedNestedArray( [ [ 1, 2, 3 ], [ 4, 5 ] ] ); | ||
// returns true | ||
|
||
bool = isRaggedNestedArray( [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] ); | ||
// returns false | ||
``` | ||
|
||
</section> | ||
|
||
<!-- /.usage --> | ||
|
||
<section class="examples"> | ||
|
||
## Examples | ||
|
||
<!-- eslint-disable no-empty-function, no-restricted-syntax --> | ||
|
||
<!-- eslint no-undef: "error" --> | ||
|
||
```javascript | ||
var isRaggedNestedArray = require( '@stdlib/assert/is-ragged-nested-array' ); | ||
|
||
var bool = isRaggedNestedArray( [ [ 1, 2, 3 ], [ 4, 5 ] ] ); | ||
// returns true | ||
|
||
bool = isRaggedNestedArray( [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] ); | ||
// returns false | ||
|
||
bool = isRaggedNestedArray( 'beep' ); | ||
// returns false | ||
|
||
bool = isRaggedNestedArray( null ); | ||
// returns false | ||
|
||
bool = isRaggedNestedArray( void 0 ); | ||
// returns false | ||
|
||
bool = isRaggedNestedArray( 5 ); | ||
// returns false | ||
|
||
bool = isRaggedNestedArray( true ); | ||
// returns false | ||
|
||
bool = isRaggedNestedArray( {} ); | ||
// returns false | ||
|
||
bool = isRaggedNestedArray( function noop() {} ); | ||
// returns false | ||
``` | ||
|
||
</section> | ||
|
||
<!-- /.examples --> | ||
|
||
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> | ||
|
||
<section class="related"> | ||
|
||
</section> | ||
|
||
<!-- /.related --> | ||
|
||
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> | ||
|
||
<section class="links"> | ||
|
||
</section> | ||
|
||
<!-- /.links --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/** | ||
* @license Apache-2.0 | ||
* | ||
* Copyright (c) 2024 The Stdlib Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
// MODULES // | ||
|
||
var bench = require( '@stdlib/bench' ); | ||
var pkg = require( './../package.json' ).name; | ||
var isRaggedNestedArray = require( './../lib' ); | ||
|
||
|
||
// MAIN // | ||
|
||
bench( pkg+'::ragged_array', function benchmark( b ) { | ||
var bool; | ||
var arr; | ||
var i; | ||
|
||
b.tic(); | ||
for ( i = 0; i < b.iterations; i++ ) { | ||
arr = [ [ i, i+1, i+2 ], [ i-1, i-2 ] ]; | ||
bool = isRaggedNestedArray( arr ); | ||
if ( typeof bool !== 'boolean' ) { | ||
b.fail( 'should return a boolean' ); | ||
} | ||
} | ||
b.toc(); | ||
if ( !bool ) { | ||
b.fail( 'should return true' ); | ||
} | ||
b.pass( 'benchmark finished' ); | ||
b.end(); | ||
}); | ||
|
||
bench( pkg+'::non_ragged_array', function benchmark( b ) { | ||
var bool; | ||
var arr; | ||
var i; | ||
|
||
b.tic(); | ||
for ( i = 0; i < b.iterations; i++ ) { | ||
arr = [ [ i, i+1], [i-1, i ] ]; | ||
bool = isRaggedNestedArray( arr ); | ||
if ( typeof bool !== 'boolean' ) { | ||
b.fail( 'should return a boolean' ); | ||
} | ||
} | ||
b.toc(); | ||
if ( bool ) { | ||
b.fail( 'should return false' ); | ||
} | ||
b.pass( 'benchmark finished' ); | ||
b.end(); | ||
}); | ||
|
||
bench( pkg+'::non_array', function benchmark( b ) { | ||
var bool; | ||
var i; | ||
|
||
b.tic(); | ||
for ( i = 0; i < b.iterations; i++ ) { | ||
bool = isRaggedNestedArray( i ); | ||
if ( typeof bool !== 'boolean' ) { | ||
b.fail( 'should return a boolean' ); | ||
} | ||
} | ||
b.toc(); | ||
if ( bool ) { | ||
b.fail( 'should return false' ); | ||
} | ||
b.pass( 'benchmark finished' ); | ||
b.end(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
{{alias}}( value ) | ||
Tests if a value is a ragged nested array. | ||
|
||
Parameters | ||
---------- | ||
value: any | ||
Value to test. | ||
|
||
Returns | ||
------- | ||
bool: boolean | ||
Boolean indicating whether a value is a ragged nested array. | ||
|
||
Examples | ||
-------- | ||
> var bool = {{alias}}( [ [ 1, 2, 3 ], [ 4, 5 ] ] ) | ||
true | ||
> bool = {{alias}}( [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] ) | ||
false | ||
> bool = {{alias}}( 'beep' ) | ||
false | ||
|
||
See Also | ||
-------- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* @license Apache-2.0 | ||
* | ||
* Copyright (c) 2024 The Stdlib Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
// TypeScript Version: 4.1 | ||
|
||
/** | ||
* Tests if a value is a ragged nested array. | ||
* | ||
* @param value - value to test | ||
* @returns boolean indicating if a value is a ragged nested array | ||
* | ||
* @example | ||
* var bool = isRaggedNestedArray( [ [ 1, 2, 3 ], [ 4, 5 ] ] ); | ||
* // returns true | ||
* | ||
* @example | ||
* var bool = isRaggedNestedArray( [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] ); | ||
* // returns false | ||
* | ||
* @example | ||
* var bool = isRaggedNestedArray( 'beep' ); | ||
* // returns false | ||
*/ | ||
declare function isRaggedNestedArray( value: any ): boolean; | ||
|
||
|
||
// EXPORTS // | ||
|
||
export = isRaggedNestedArray; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* @license Apache-2.0 | ||
* | ||
* Copyright (c) 2024 The Stdlib Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import isRaggedNestedArray = require( './index' ); | ||
|
||
|
||
// TESTS // | ||
|
||
// The function returns a boolean... | ||
{ | ||
isRaggedNestedArray( [ [ 1, 2, 3 ], [ 4, 5 ] ] ); // $ExpectType boolean | ||
isRaggedNestedArray( [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] ); // $ExpectType boolean | ||
isRaggedNestedArray( 'beep' ); // $ExpectType boolean | ||
} | ||
|
||
// The compiler throws an error if the function is provided an unsupported number of arguments... | ||
{ | ||
isRaggedNestedArray(); // $ExpectError | ||
isRaggedNestedArray( [], 123 ); // $ExpectError | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** | ||
* @license Apache-2.0 | ||
* | ||
* Copyright (c) 2024 The Stdlib Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* eslint-disable no-empty-function, no-restricted-syntax */ | ||
|
||
'use strict'; | ||
|
||
var isRaggedNestedArray = require( './../lib' ); | ||
|
||
console.log( isRaggedNestedArray( [ [ 1, 2, 3 ], [ 4, 5 ] ] ) ); | ||
// => true | ||
|
||
console.log( isRaggedNestedArray( [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] ) ); | ||
// => false | ||
|
||
console.log( isRaggedNestedArray( 'beep' ) ); | ||
// => false | ||
|
||
console.log( isRaggedNestedArray( null ) ); | ||
// => false | ||
|
||
console.log( isRaggedNestedArray( void 0 ) ); | ||
// => false | ||
|
||
console.log( isRaggedNestedArray( 5 ) ); | ||
// => false | ||
|
||
console.log( isRaggedNestedArray( true ) ); | ||
// => false | ||
|
||
console.log( isRaggedNestedArray( {} ) ); | ||
// => false | ||
|
||
console.log( isRaggedNestedArray( function noop() {} ) ); | ||
// => false |
Oops, something went wrong.