Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Feb 26, 2024
1 parent 1a0162c commit 9286669
Show file tree
Hide file tree
Showing 12 changed files with 632 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ branches.md
.postinstall.json
Makefile

# Ignore `binding.gyp` file to avoid compilation of native addon when installing package:
# Ignore files to avoid compilation of native addon when installing package:
binding.gyp
include.gypi

# Directories #
###############
Expand Down
3 changes: 3 additions & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -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]>
Expand All @@ -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]>
Expand All @@ -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]>
Expand Down
106 changes: 106 additions & 0 deletions is-ragged-nested-array/README.md
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 -->
89 changes: 89 additions & 0 deletions is-ragged-nested-array/benchmark/benchmark.js
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();
});
26 changes: 26 additions & 0 deletions is-ragged-nested-array/docs/repl.txt
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
--------

44 changes: 44 additions & 0 deletions is-ragged-nested-array/docs/types/index.d.ts
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;
35 changes: 35 additions & 0 deletions is-ragged-nested-array/docs/types/test.ts
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
}
50 changes: 50 additions & 0 deletions is-ragged-nested-array/examples/index.js
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
Loading

0 comments on commit 9286669

Please sign in to comment.