Skip to content

Commit c9949c5

Browse files
committed
Auto-generated commit
1 parent a7f1507 commit c9949c5

File tree

16 files changed

+1722
-2
lines changed

16 files changed

+1722
-2
lines changed

CHANGELOG.md

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,40 @@ This release closes the following issue:
225225

226226
<!-- /.package -->
227227

228+
<section class="package" id="array-base-cuevery-by-right-unreleased">
229+
230+
#### [@stdlib/array/base/cuevery-by-right](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/cuevery-by-right)
231+
232+
<details>
233+
234+
<section class="features">
235+
236+
##### Features
237+
238+
- [`5a50038`](https://github.com/stdlib-js/stdlib/commit/5a50038db6a457856adc51d5e6e3fd7161f45085) - add `array/base/cuevery-by-right` [(#2802)](https://github.com/stdlib-js/stdlib/pull/2802)
239+
240+
</section>
241+
242+
<!-- /.features -->
243+
244+
<section class="issues">
245+
246+
##### Closed Issues
247+
248+
This release closes the following issue:
249+
250+
[#2328](https://github.com/stdlib-js/stdlib/issues/2328)
251+
252+
</section>
253+
254+
<!-- /.issues -->
255+
256+
</details>
257+
258+
</section>
259+
260+
<!-- /.package -->
261+
228262
<section class="package" id="array-base-cunone-by-unreleased">
229263

230264
#### [@stdlib/array/base/cunone-by](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/cunone-by)
@@ -651,9 +685,9 @@ This release closes the following issue:
651685

652686
### Closed Issues
653687

654-
A total of 2 issues were closed in this release:
688+
A total of 3 issues were closed in this release:
655689

656-
[#2326](https://github.com/stdlib-js/stdlib/issues/2326), [#2327](https://github.com/stdlib-js/stdlib/issues/2327)
690+
[#2326](https://github.com/stdlib-js/stdlib/issues/2326), [#2327](https://github.com/stdlib-js/stdlib/issues/2327), [#2328](https://github.com/stdlib-js/stdlib/issues/2328)
657691

658692
</section>
659693

@@ -684,6 +718,7 @@ A total of 8 people contributed to this release. Thank you to the following cont
684718

685719
<details>
686720

721+
- [`5a50038`](https://github.com/stdlib-js/stdlib/commit/5a50038db6a457856adc51d5e6e3fd7161f45085) - **feat:** add `array/base/cuevery-by-right` [(#2802)](https://github.com/stdlib-js/stdlib/pull/2802) _(by HarshaNP, Philipp Burckhardt)_
687722
- [`006e24c`](https://github.com/stdlib-js/stdlib/commit/006e24cbe344a32a48d883dfa9991e7a381a0b98) - **chore:** update package meta data [(#2964)](https://github.com/stdlib-js/stdlib/pull/2964 ) _(by stdlib-bot)_
688723
- [`9835dae`](https://github.com/stdlib-js/stdlib/commit/9835dae5a4dba0aae50d8582b97ad69d17fefe6d) - **feat:** add `array/base/cusome-by` [(#2953)](https://github.com/stdlib-js/stdlib/pull/2953) _(by Aditya Sapra, Philipp Burckhardt)_
689724
- [`abf0407`](https://github.com/stdlib-js/stdlib/commit/abf040787f6598438b0100a729a8331b7f80f62f) - **chore:** resolve lint errors in TS files _(by Philipp Burckhardt)_

base/cuevery-by-right/README.md

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
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+
# cueveryByRight
22+
23+
> Cumulatively test whether every array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left.
24+
25+
<section class="usage">
26+
27+
## Usage
28+
29+
```javascript
30+
var cueveryByRight = require( '@stdlib/array/base/cuevery-by-right' );
31+
```
32+
33+
#### cueveryByRight( x, predicate\[, thisArg ] )
34+
35+
Cumulatively tests whether every array element in a provided array passes a test implemented by a `predicate` function, while iterating from right-to-left.
36+
37+
```javascript
38+
function fcn( value ) {
39+
return value > 0;
40+
}
41+
42+
var x = [ 0, 0, 1, 1, 1 ];
43+
44+
var y = cueveryByRight( x, fcn );
45+
// returns [ true, true, true, false, false ];
46+
```
47+
48+
#### cueveryByRight.assign( x, out, stride, offset, predicate\[, thisArg ] )
49+
50+
Cumulatively tests whether every array element in a provided array passes a test implemented by a `predicate` function, while iterating from right-to-left, and assigns the results to the elements in the output array.
51+
52+
```javascript
53+
function fcn( v ) {
54+
return v > 0;
55+
}
56+
57+
var x = [ 0, 0, 1, 1, 1 ];
58+
var y = [ false, null, false, null, false, null, false, null, false, null ];
59+
60+
var out = cueveryByRight.assign( x, y, 2, 0, fcn );
61+
// returns [ true, null, true, null, true, null, false, null, false, null ]
62+
63+
var bool = ( out === y );
64+
// returns true
65+
```
66+
67+
The invoked `predicate` function is provided three arguments:
68+
69+
- **value**: collection element,
70+
- **index**: collection index,
71+
- **collection**: input collection,
72+
73+
To set the function execution context, provide a `thisArg`.
74+
75+
```javascript
76+
function fcn( v ) {
77+
this.count += 1;
78+
return ( v > 0 );
79+
}
80+
81+
var x = [ 0, 0, 1, 1, 1 ];
82+
83+
var context = {
84+
'count': 0
85+
};
86+
87+
var bool = cueveryByRight( x, fcn, context );
88+
// returns [ true, true, true, false, false ]
89+
90+
var count = context.count;
91+
// returns 4
92+
```
93+
94+
</section>
95+
96+
<!-- /.usage -->
97+
98+
<section class="notes">
99+
100+
</section>
101+
102+
<!-- /.notes -->
103+
104+
<section class="examples">
105+
106+
## Examples
107+
108+
<!-- eslint no-undef: "error" -->
109+
110+
```javascript
111+
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
112+
var cueveryByRight = require( '@stdlib/array/base/cuevery-by-right' );
113+
114+
function isPositive( value ) {
115+
return ( value > 0 );
116+
}
117+
118+
// Create an array of random values:
119+
var x = discreteUniform( 10, -10, 10 );
120+
console.log( x );
121+
122+
// Cumulatively test whether every array element passes a test, while iterating from right-to-left:
123+
var out = cueveryByRight( x, isPositive );
124+
console.log( out );
125+
```
126+
127+
</section>
128+
129+
<!-- /.examples -->
130+
131+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
132+
133+
<section class="related">
134+
135+
</section>
136+
137+
<!-- /.related -->
138+
139+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
140+
141+
<section class="links">
142+
143+
</section>
144+
145+
<!-- /.links -->
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
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 isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive;
27+
var filled = require( './../../../base/filled' );
28+
var pkg = require( './../package.json' ).name;
29+
var cueveryByRight = 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 x = filled( 1.5, len );
43+
return benchmark;
44+
45+
/**
46+
* Benchmark function.
47+
*
48+
* @private
49+
* @param {Benchmark} b - benchmark instance
50+
*/
51+
function benchmark( b ) {
52+
var y;
53+
var v;
54+
var i;
55+
56+
y = filled( false, len );
57+
58+
b.tic();
59+
for ( i = 0; i < b.iterations; i++ ) {
60+
v = cueveryByRight.assign( x, y, 1, 0, isPositiveInteger );
61+
if ( typeof v !== 'object' ) {
62+
b.fail( 'should return an array' );
63+
}
64+
}
65+
b.toc();
66+
if ( !isArray( v ) ) {
67+
b.fail( 'should return an array' );
68+
}
69+
b.pass( 'benchmark finished' );
70+
b.end();
71+
}
72+
}
73+
74+
75+
// MAIN //
76+
77+
/**
78+
* Main execution sequence.
79+
*
80+
* @private
81+
*/
82+
function main() {
83+
var len;
84+
var min;
85+
var max;
86+
var f;
87+
var i;
88+
89+
min = 1; // 10^min
90+
max = 6; // 10^max
91+
92+
for ( i = min; i <= max; i++ ) {
93+
len = pow( 10, i );
94+
f = createBenchmark( len );
95+
bench( pkg+':assign:len='+len, f );
96+
}
97+
}
98+
99+
main();
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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 isArray = require( '@stdlib/assert/is-array' );
25+
var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive;
26+
var pkg = require( './../package.json' ).name;
27+
var cueveryByRight = require( './../lib' );
28+
29+
30+
// MAIN //
31+
32+
bench( pkg, function benchmark( b ) {
33+
var x;
34+
var i;
35+
var v;
36+
37+
x = [ 0, 0, 1, 1, 1 ];
38+
39+
b.tic();
40+
for ( i = 0; i < b.iterations; i++ ) {
41+
v = cueveryByRight( x, isPositiveInteger );
42+
if ( typeof v !== 'object' ) {
43+
b.fail( 'should return an array' );
44+
}
45+
}
46+
b.toc();
47+
if ( !isArray( v ) ) {
48+
b.fail( 'should return an array' );
49+
}
50+
b.pass( 'benchmark finished' );
51+
b.end();
52+
});

0 commit comments

Comments
 (0)