Skip to content

Commit 0e823ea

Browse files
committed
Auto-generated commit
1 parent 4e3d920 commit 0e823ea

File tree

12 files changed

+591
-0
lines changed

12 files changed

+591
-0
lines changed

CHANGELOG.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,28 @@
1010

1111
### Packages
1212

13+
<section class="package" id="array-base-unreleased">
14+
15+
#### [@stdlib/array/base](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base)
16+
17+
<details>
18+
19+
<section class="features">
20+
21+
##### Features
22+
23+
- [`42664da`](https://github.com/stdlib-js/stdlib/commit/42664dafb94e72a8b8eca80ede6669caaaf57e68) - add `nulls` to namespace
24+
25+
</section>
26+
27+
<!-- /.features -->
28+
29+
</details>
30+
31+
</section>
32+
33+
<!-- /.package -->
34+
1335
<section class="package" id="array-base-assert-unreleased">
1436

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

154176
<!-- /.package -->
155177

178+
<section class="package" id="array-base-nulls-unreleased">
179+
180+
#### [@stdlib/array/base/nulls](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/nulls)
181+
182+
<details>
183+
184+
<section class="features">
185+
186+
##### Features
187+
188+
- [`6d91993`](https://github.com/stdlib-js/stdlib/commit/6d9199381c3e949420349ba3506ecd59c692be44) - add `array/base/nulls`
189+
190+
</section>
191+
192+
<!-- /.features -->
193+
194+
</details>
195+
196+
</section>
197+
198+
<!-- /.package -->
199+
156200
<section class="package" id="array-bool-unreleased">
157201

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

290334
<details>
291335

336+
- [`42664da`](https://github.com/stdlib-js/stdlib/commit/42664dafb94e72a8b8eca80ede6669caaaf57e68) - **feat:** add `nulls` to namespace _(by Athan Reines)_
337+
- [`6d91993`](https://github.com/stdlib-js/stdlib/commit/6d9199381c3e949420349ba3506ecd59c692be44) - **feat:** add `array/base/nulls` _(by Athan Reines)_
292338
- [`b723a6e`](https://github.com/stdlib-js/stdlib/commit/b723a6eaec97adad2da4ffbecb532a3d1ae1e0ba) - **docs:** fix errors in comments and clean-up _(by Philipp Burckhardt)_
293339
- [`eb82943`](https://github.com/stdlib-js/stdlib/commit/eb82943ec2ac2b3023377cbc320486d333f47e48) - **chore:** minor clean-up _(by Philipp Burckhardt)_
294340
- [`3c8bcb9`](https://github.com/stdlib-js/stdlib/commit/3c8bcb938befe35d784ba3fe0dea124dd4b20b36) - **chore:** minor clean-up _(by Philipp Burckhardt)_

base/lib/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,6 +1116,15 @@ setReadOnly( ns, 'noneBy', require( './../../base/none-by' ) );
11161116
*/
11171117
setReadOnly( ns, 'noneByRight', require( './../../base/none-by-right' ) );
11181118

1119+
/**
1120+
* @name nulls
1121+
* @memberof ns
1122+
* @readonly
1123+
* @type {Function}
1124+
* @see {@link module:@stdlib/array/base/nulls}
1125+
*/
1126+
setReadOnly( ns, 'nulls', require( './../../base/nulls' ) );
1127+
11191128
/**
11201129
* @name oneTo
11211130
* @memberof ns

base/nulls/README.md

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2024 The Stdlib Authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
21+
# nulls
22+
23+
> Create a "generic" array filled with null values.
24+
25+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
26+
27+
<section class="intro">
28+
29+
</section>
30+
31+
<!-- /.intro -->
32+
33+
<!-- Package usage documentation. -->
34+
35+
<section class="usage">
36+
37+
## Usage
38+
39+
```javascript
40+
var nulls = require( '@stdlib/array/base/nulls' );
41+
```
42+
43+
#### nulls( len )
44+
45+
Returns a "generic" array filled with `null` values.
46+
47+
```javascript
48+
var out = nulls( 3 );
49+
// returns [ null, null, null ]
50+
```
51+
52+
</section>
53+
54+
<!-- /.usage -->
55+
56+
<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
57+
58+
<section class="notes">
59+
60+
</section>
61+
62+
<!-- /.notes -->
63+
64+
<!-- Package usage examples. -->
65+
66+
<section class="examples">
67+
68+
## Examples
69+
70+
<!-- eslint no-undef: "error" -->
71+
72+
```javascript
73+
var nulls = require( '@stdlib/array/base/nulls' );
74+
75+
// Create a null value array:
76+
var arr = nulls( 10 );
77+
78+
console.log( arr );
79+
// => [ null, null, null, null, null, null, null, null, null, null ]
80+
```
81+
82+
</section>
83+
84+
<!-- /.examples -->
85+
86+
<!-- 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. -->
87+
88+
<section class="references">
89+
90+
</section>
91+
92+
<!-- /.references -->
93+
94+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
95+
96+
<section class="related">
97+
98+
</section>
99+
100+
<!-- /.related -->
101+
102+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
103+
104+
<section class="links">
105+
106+
</section>
107+
108+
<!-- /.links -->
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2024 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+
'use strict';
20+
21+
// MODULES //
22+
23+
var bench = require( '@stdlib/bench' );
24+
var pow = require( '@stdlib/math/base/special/pow' );
25+
var isArray = require( '@stdlib/assert/is-array' );
26+
var pkg = require( './../package.json' ).name;
27+
var nulls = require( './../lib' );
28+
29+
30+
// FUNCTIONS //
31+
32+
/**
33+
* Creates a benchmark function.
34+
*
35+
* @private
36+
* @param {PositiveInteger} len - array length
37+
* @returns {Function} benchmark function
38+
*/
39+
function createBenchmark( len ) {
40+
return benchmark;
41+
42+
/**
43+
* Benchmark function.
44+
*
45+
* @private
46+
* @param {Benchmark} b - benchmark instance
47+
*/
48+
function benchmark( b ) {
49+
var out;
50+
var i;
51+
52+
b.tic();
53+
for ( i = 0; i < b.iterations; i++ ) {
54+
out = nulls( len );
55+
if ( out.length !== len ) {
56+
b.fail( 'unexpected length' );
57+
}
58+
}
59+
b.toc();
60+
if ( !isArray( out ) ) {
61+
b.fail( 'should return an array' );
62+
}
63+
b.pass( 'benchmark finished' );
64+
b.end();
65+
}
66+
}
67+
68+
69+
// MAIN //
70+
71+
/**
72+
* Main execution sequence.
73+
*
74+
* @private
75+
*/
76+
function main() {
77+
var len;
78+
var min;
79+
var max;
80+
var f;
81+
var i;
82+
83+
min = 1; // 10^min
84+
max = 6; // 10^max
85+
86+
for ( i = min; i <= max; i++ ) {
87+
len = pow( 10, i );
88+
89+
f = createBenchmark( len );
90+
bench( pkg+':len='+len, f );
91+
}
92+
}
93+
94+
main();

base/nulls/docs/repl.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
{{alias}}( len )
3+
Returns a "generic" array filled with null values.
4+
5+
Parameters
6+
----------
7+
len: integer
8+
Array length.
9+
10+
Returns
11+
-------
12+
out: Array
13+
Output array.
14+
15+
Examples
16+
--------
17+
> var out = {{alias}}( 3 )
18+
[ null, null, null ]
19+
20+
See Also
21+
--------
22+

base/nulls/docs/types/index.d.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2024 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: 4.1
20+
21+
/**
22+
* Returns a "generic" array filled with nulls.
23+
*
24+
* @param len - array length
25+
* @returns output array
26+
*
27+
* @example
28+
* var out = nulls( 3 );
29+
* // returns [ null, null, null ]
30+
*/
31+
declare function nulls( len: number ): Array<null>;
32+
33+
34+
// EXPORTS //
35+
36+
export = nulls;

base/nulls/docs/types/test.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2024 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 nulls = require( './index' );
20+
21+
22+
// TESTS //
23+
24+
// The function returns an array...
25+
{
26+
nulls( 3 ); // $ExpectType null[]
27+
}
28+
29+
// The compiler throws an error if the function is provided an argument which is not a number...
30+
{
31+
nulls( 'abc' ); // $ExpectError
32+
nulls( true ); // $ExpectError
33+
nulls( false ); // $ExpectError
34+
nulls( null ); // $ExpectError
35+
nulls( [] ); // $ExpectError
36+
nulls( {} ); // $ExpectError
37+
nulls( ( x: number ): number => x ); // $ExpectError
38+
}
39+
40+
// The compiler throws an error if the function is provided an unsupported number of arguments...
41+
{
42+
nulls(); // $ExpectError
43+
nulls( 3, 2 ); // $ExpectError
44+
}

0 commit comments

Comments
 (0)