Skip to content

Commit f6acfae

Browse files
committed
Auto-generated commit
1 parent 1226c95 commit f6acfae

28 files changed

+3780
-412
lines changed

CHANGELOG.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
<section class="release" id="unreleased">
66

7-
## Unreleased (2024-08-16)
7+
## Unreleased (2024-08-17)
88

99
<section class="packages">
1010

@@ -77,6 +77,7 @@
7777

7878
##### Features
7979

80+
- [`297e4d5`](https://github.com/stdlib-js/stdlib/commit/297e4d5c9c1b015ccf8c7bb77c672e9ac1328898) - add `without` to namespace
8081
- [`29641e1`](https://github.com/stdlib-js/stdlib/commit/29641e155d07e3aa7e71340d47ada3e43d1edaa5) - add `cunone` to namespace
8182
- [`a596d0c`](https://github.com/stdlib-js/stdlib/commit/a596d0c68b97049ec249e9c51caf7e2d34190f4a) - add `removeAt` to namespace
8283
- [`00fd68d`](https://github.com/stdlib-js/stdlib/commit/00fd68ddf80a71b08e5353c63c297fca4daaf873) - update namespace TypeScript declarations [(#2415)](https://github.com/stdlib-js/stdlib/pull/2415)
@@ -1308,12 +1309,45 @@ This release closes the following issue:
13081309

13091310
##### Features
13101311

1312+
- [`15c9b0e`](https://github.com/stdlib-js/stdlib/commit/15c9b0e711e44c7e06ba768ab577d8cffdc5647d) - add support for assigning to an output array
13111313
- [`4253607`](https://github.com/stdlib-js/stdlib/commit/425360790cca3ef7b1747b3c1828ab5825306441) - add `array/base/with` [(#1374)](https://github.com/stdlib-js/stdlib/pull/1374)
13121314

13131315
</section>
13141316

13151317
<!-- /.features -->
13161318

1319+
<section class="bug-fixes">
1320+
1321+
##### Bug Fixes
1322+
1323+
- [`45bfdb6`](https://github.com/stdlib-js/stdlib/commit/45bfdb698f5b5b31e1782efe846b76ee64ab032a) - update error messages to accommodate signed integers
1324+
1325+
</section>
1326+
1327+
<!-- /.bug-fixes -->
1328+
1329+
</details>
1330+
1331+
</section>
1332+
1333+
<!-- /.package -->
1334+
1335+
<section class="package" id="array-base-without-unreleased">
1336+
1337+
#### [@stdlib/array/base/without](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/without)
1338+
1339+
<details>
1340+
1341+
<section class="features">
1342+
1343+
##### Features
1344+
1345+
- [`f6df528`](https://github.com/stdlib-js/stdlib/commit/f6df52818f504fd55987a80f586ad55b40405d58) - add `array/base/without`
1346+
1347+
</section>
1348+
1349+
<!-- /.features -->
1350+
13171351
</details>
13181352

13191353
</section>
@@ -2435,6 +2469,12 @@ A total of 10 people contributed to this release. Thank you to the following con
24352469

24362470
<details>
24372471

2472+
- [`297e4d5`](https://github.com/stdlib-js/stdlib/commit/297e4d5c9c1b015ccf8c7bb77c672e9ac1328898) - **feat:** add `without` to namespace _(by Athan Reines)_
2473+
- [`f6df528`](https://github.com/stdlib-js/stdlib/commit/f6df52818f504fd55987a80f586ad55b40405d58) - **feat:** add `array/base/without` _(by Athan Reines)_
2474+
- [`e22b37a`](https://github.com/stdlib-js/stdlib/commit/e22b37aaf13a81aa9c8536d54b8a43871e4bdd16) - **docs:** add example _(by Athan Reines)_
2475+
- [`1f1c2df`](https://github.com/stdlib-js/stdlib/commit/1f1c2dfc7314a343282c8d4904a8ad05c500f80d) - **docs:** fix example _(by Athan Reines)_
2476+
- [`15c9b0e`](https://github.com/stdlib-js/stdlib/commit/15c9b0e711e44c7e06ba768ab577d8cffdc5647d) - **feat:** add support for assigning to an output array _(by Athan Reines)_
2477+
- [`45bfdb6`](https://github.com/stdlib-js/stdlib/commit/45bfdb698f5b5b31e1782efe846b76ee64ab032a) - **fix:** update error messages to accommodate signed integers _(by Athan Reines)_
24382478
- [`29641e1`](https://github.com/stdlib-js/stdlib/commit/29641e155d07e3aa7e71340d47ada3e43d1edaa5) - **feat:** add `cunone` to namespace _(by Athan Reines)_
24392479
- [`a596d0c`](https://github.com/stdlib-js/stdlib/commit/a596d0c68b97049ec249e9c51caf7e2d34190f4a) - **feat:** add `removeAt` to namespace _(by Athan Reines)_
24402480
- [`400fcbb`](https://github.com/stdlib-js/stdlib/commit/400fcbb91753cc2a47d428a65a29ee455a208768) - **refactor:** avoid unnecessary copies, update examples, and refactor benchmarks _(by Athan Reines)_

base/lib/index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1548,6 +1548,15 @@ setReadOnly( ns, 'where', require( './../../base/where' ) );
15481548
*/
15491549
setReadOnly( ns, 'arrayWith', require( './../../base/with' ) );
15501550

1551+
/**
1552+
* @name without
1553+
* @memberof ns
1554+
* @readonly
1555+
* @type {Function}
1556+
* @see {@link module:@stdlib/array/base/without}
1557+
*/
1558+
setReadOnly( ns, 'without', require( './../../base/without' ) );
1559+
15511560
/**
15521561
* @name zeroTo
15531562
* @memberof ns

base/with/README.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,37 @@ var out = arrayWith( x, 0, 5 );
5252

5353
out = arrayWith( x, -1, 6 );
5454
// returns [ 1, 2, 3, 6 ]
55+
```
56+
57+
The function accepts the following arguments:
58+
59+
- **x**: an input array.
60+
- **index**: element index.
61+
- **value**: replacement value.
62+
63+
### arrayWith.assign( x, index, value, out, stride, offset )
64+
65+
Copies elements from one array to another array and sets the element at the specified index to a provided value.
66+
67+
```javascript
68+
var x = [ 1, 2, 3, 4 ];
69+
70+
var out = [ 0, 0, 0, 0 ];
71+
var arr = arrayWith.assign( x, 0, 5, out, 1, 0 );
72+
// returns [ 5, 2, 3, 4 ]
5573

74+
var bool = ( arr === out );
75+
// returns true
5676
```
5777

5878
The function accepts the following arguments:
5979

6080
- **x**: an input array.
6181
- **index**: element index.
6282
- **value**: replacement value.
83+
- **out**: output array.
84+
- **stride**: output array stride.
85+
- **offset**: output array offset.
6386

6487
</section>
6588

@@ -71,13 +94,13 @@ The function accepts the following arguments:
7194

7295
## Notes
7396

74-
- If provided an array-like object having a `with` method, the function defers execution to that method and assumes that the method has the following signature:
97+
- If provided an array-like object having a `with` method, the `arrayWith` function defers execution to that method and assumes that the method has the following signature:
7598

7699
```text
77100
x.with( index, value )
78101
```
79102
80-
If provided an array-like object without a `with` method, the function shallow copies input array data to a new generic array, normalizes a provided index, and sets a specified element.
103+
If provided an array-like object without a `with` method, the `arrayWith` function shallow copies input array data to a new generic array, normalizes a provided index, and sets a specified element.
81104
82105
- Negative indices are resolved relative to the last array element, with the last element corresponding to `-1`.
83106
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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 ones = require( './../../../base/ones' );
27+
var zeros = require( './../../../base/zeros' );
28+
var pkg = require( './../package.json' ).name;
29+
var arrayWith = require( './../lib' );
30+
31+
32+
// FUNCTIONS //
33+
34+
/**
35+
* Creates a benchmark function.
36+
*
37+
* @private
38+
* @param {PositiveInteger} len - array length
39+
* @returns {Function} benchmark function
40+
*/
41+
function createBenchmark( len ) {
42+
var out = zeros( len );
43+
var x = ones( len );
44+
return benchmark;
45+
46+
/**
47+
* Benchmark function.
48+
*
49+
* @private
50+
* @param {Benchmark} b - benchmark instance
51+
*/
52+
function benchmark( b ) {
53+
var v;
54+
var i;
55+
56+
b.tic();
57+
for ( i = 0; i < b.iterations; i++ ) {
58+
v = arrayWith.assign( x, i%len, i, out, 1, 0 );
59+
if ( typeof v !== 'object' ) {
60+
b.fail( 'should return an array' );
61+
}
62+
}
63+
b.toc();
64+
if ( !isArray( v ) ) {
65+
b.fail( 'should return an array' );
66+
}
67+
b.pass( 'benchmark finished' );
68+
b.end();
69+
}
70+
}
71+
72+
73+
// MAIN //
74+
75+
/**
76+
* Main execution sequence.
77+
*
78+
* @private
79+
*/
80+
function main() {
81+
var len;
82+
var min;
83+
var max;
84+
var f;
85+
var i;
86+
87+
min = 1; // 10^min
88+
max = 6; // 10^max
89+
90+
for ( i = min; i <= max; i++ ) {
91+
len = pow( 10, i );
92+
93+
f = createBenchmark( len );
94+
bench( pkg+':assign:dtype=generic,len='+len, f );
95+
}
96+
}
97+
98+
main();

base/with/docs/repl.txt

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,48 @@
4242
> x
4343
[ 1, 2, 3, 4 ]
4444

45+
46+
{{alias}}.assign( x, index, value, out, stride, offset )
47+
Copies elements from one array to another array and sets the element at the
48+
specified index to a provided value.
49+
50+
Negative indices are resolved relative to the last array element, with the
51+
last element corresponding to `-1`.
52+
53+
Parameters
54+
----------
55+
x: ArrayLikeObject
56+
Input array.
57+
58+
index: integer
59+
Index of the element to be replaced.
60+
61+
value: any
62+
Replacement value.
63+
64+
out: ArrayLikeObject
65+
Output array.
66+
67+
stride: integer
68+
Output array stride.
69+
70+
offset: integer
71+
Output array offset.
72+
73+
Returns
74+
-------
75+
out: ArrayLikeObject
76+
Output array.
77+
78+
Examples
79+
--------
80+
> var x = [ 1, 2, 3, 4 ];
81+
> var out = [ 0, 0, 0, 0 ];
82+
> var arr = {{alias}}.assign( x, 0, 5, out, 1, 0 )
83+
[ 5, 2, 3, 4 ]
84+
> var bool = ( arr === out )
85+
true
86+
4587
See Also
4688
--------
4789

0 commit comments

Comments
 (0)