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 Sep 22, 2024
1 parent 4e3d920 commit 0e823ea
Show file tree
Hide file tree
Showing 12 changed files with 591 additions and 0 deletions.
46 changes: 46 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,28 @@

### Packages

<section class="package" id="array-base-unreleased">

#### [@stdlib/array/base](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base)

<details>

<section class="features">

##### Features

- [`42664da`](https://github.com/stdlib-js/stdlib/commit/42664dafb94e72a8b8eca80ede6669caaaf57e68) - add `nulls` to namespace

</section>

<!-- /.features -->

</details>

</section>

<!-- /.package -->

<section class="package" id="array-base-assert-unreleased">

#### [@stdlib/array/base/assert](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/assert)
Expand Down Expand Up @@ -153,6 +175,28 @@

<!-- /.package -->

<section class="package" id="array-base-nulls-unreleased">

#### [@stdlib/array/base/nulls](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/nulls)

<details>

<section class="features">

##### Features

- [`6d91993`](https://github.com/stdlib-js/stdlib/commit/6d9199381c3e949420349ba3506ecd59c692be44) - add `array/base/nulls`

</section>

<!-- /.features -->

</details>

</section>

<!-- /.package -->

<section class="package" id="array-bool-unreleased">

#### [@stdlib/array/bool](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/bool)
Expand Down Expand Up @@ -289,6 +333,8 @@ A total of 5 people contributed to this release. Thank you to the following cont

<details>

- [`42664da`](https://github.com/stdlib-js/stdlib/commit/42664dafb94e72a8b8eca80ede6669caaaf57e68) - **feat:** add `nulls` to namespace _(by Athan Reines)_
- [`6d91993`](https://github.com/stdlib-js/stdlib/commit/6d9199381c3e949420349ba3506ecd59c692be44) - **feat:** add `array/base/nulls` _(by Athan Reines)_
- [`b723a6e`](https://github.com/stdlib-js/stdlib/commit/b723a6eaec97adad2da4ffbecb532a3d1ae1e0ba) - **docs:** fix errors in comments and clean-up _(by Philipp Burckhardt)_
- [`eb82943`](https://github.com/stdlib-js/stdlib/commit/eb82943ec2ac2b3023377cbc320486d333f47e48) - **chore:** minor clean-up _(by Philipp Burckhardt)_
- [`3c8bcb9`](https://github.com/stdlib-js/stdlib/commit/3c8bcb938befe35d784ba3fe0dea124dd4b20b36) - **chore:** minor clean-up _(by Philipp Burckhardt)_
Expand Down
9 changes: 9 additions & 0 deletions base/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,15 @@ setReadOnly( ns, 'noneBy', require( './../../base/none-by' ) );
*/
setReadOnly( ns, 'noneByRight', require( './../../base/none-by-right' ) );

/**
* @name nulls
* @memberof ns
* @readonly
* @type {Function}
* @see {@link module:@stdlib/array/base/nulls}
*/
setReadOnly( ns, 'nulls', require( './../../base/nulls' ) );

/**
* @name oneTo
* @memberof ns
Expand Down
108 changes: 108 additions & 0 deletions base/nulls/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<!--
@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.
-->

# nulls

> Create a "generic" array filled with null values.
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->

<section class="intro">

</section>

<!-- /.intro -->

<!-- Package usage documentation. -->

<section class="usage">

## Usage

```javascript
var nulls = require( '@stdlib/array/base/nulls' );
```

#### nulls( len )

Returns a "generic" array filled with `null` values.

```javascript
var out = nulls( 3 );
// returns [ null, null, null ]
```

</section>

<!-- /.usage -->

<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="notes">

</section>

<!-- /.notes -->

<!-- Package usage examples. -->

<section class="examples">

## Examples

<!-- eslint no-undef: "error" -->

```javascript
var nulls = require( '@stdlib/array/base/nulls' );

// Create a null value array:
var arr = nulls( 10 );

console.log( arr );
// => [ null, null, null, null, null, null, null, null, null, null ]
```

</section>

<!-- /.examples -->

<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="references">

</section>

<!-- /.references -->

<!-- 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 -->
94 changes: 94 additions & 0 deletions base/nulls/benchmark/benchmark.length.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/**
* @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 pow = require( '@stdlib/math/base/special/pow' );
var isArray = require( '@stdlib/assert/is-array' );
var pkg = require( './../package.json' ).name;
var nulls = require( './../lib' );


// FUNCTIONS //

/**
* Creates a benchmark function.
*
* @private
* @param {PositiveInteger} len - array length
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
return benchmark;

/**
* Benchmark function.
*
* @private
* @param {Benchmark} b - benchmark instance
*/
function benchmark( b ) {
var out;
var i;

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
out = nulls( len );
if ( out.length !== len ) {
b.fail( 'unexpected length' );
}
}
b.toc();
if ( !isArray( out ) ) {
b.fail( 'should return an array' );
}
b.pass( 'benchmark finished' );
b.end();
}
}


// MAIN //

/**
* Main execution sequence.
*
* @private
*/
function main() {
var len;
var min;
var max;
var f;
var i;

min = 1; // 10^min
max = 6; // 10^max

for ( i = min; i <= max; i++ ) {
len = pow( 10, i );

f = createBenchmark( len );
bench( pkg+':len='+len, f );
}
}

main();
22 changes: 22 additions & 0 deletions base/nulls/docs/repl.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

{{alias}}( len )
Returns a "generic" array filled with null values.

Parameters
----------
len: integer
Array length.

Returns
-------
out: Array
Output array.

Examples
--------
> var out = {{alias}}( 3 )
[ null, null, null ]

See Also
--------

36 changes: 36 additions & 0 deletions base/nulls/docs/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* @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

/**
* Returns a "generic" array filled with nulls.
*
* @param len - array length
* @returns output array
*
* @example
* var out = nulls( 3 );
* // returns [ null, null, null ]
*/
declare function nulls( len: number ): Array<null>;


// EXPORTS //

export = nulls;
44 changes: 44 additions & 0 deletions base/nulls/docs/types/test.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.
*/

import nulls = require( './index' );


// TESTS //

// The function returns an array...
{
nulls( 3 ); // $ExpectType null[]
}

// The compiler throws an error if the function is provided an argument which is not a number...
{
nulls( 'abc' ); // $ExpectError
nulls( true ); // $ExpectError
nulls( false ); // $ExpectError
nulls( null ); // $ExpectError
nulls( [] ); // $ExpectError
nulls( {} ); // $ExpectError
nulls( ( x: number ): number => x ); // $ExpectError
}

// The compiler throws an error if the function is provided an unsupported number of arguments...
{
nulls(); // $ExpectError
nulls( 3, 2 ); // $ExpectError
}
Loading

0 comments on commit 0e823ea

Please sign in to comment.