@stdlib/array-base-cuany-by 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,177 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
package/NOTICE ADDED
@@ -0,0 +1 @@
1
+ Copyright (c) 2016-2026 The Stdlib Authors.
package/README.md ADDED
@@ -0,0 +1,244 @@
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
+
22
+ <details>
23
+ <summary>
24
+ About stdlib...
25
+ </summary>
26
+ <p>We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.</p>
27
+ <p>The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.</p>
28
+ <p>When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.</p>
29
+ <p>To join us in bringing numerical computing to the web, get started by checking us out on <a href="https://github.com/stdlib-js/stdlib">GitHub</a>, and please consider <a href="https://opencollective.com/stdlib">financially supporting stdlib</a>. We greatly appreciate your continued support!</p>
30
+ </details>
31
+
32
+ # cuanyBy
33
+
34
+ [![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
35
+
36
+ > Cumulatively test whether at least one element in a provided array passes a test implemented by a predicate function.
37
+
38
+ <section class="installation">
39
+
40
+ ## Installation
41
+
42
+ ```bash
43
+ npm install @stdlib/array-base-cuany-by
44
+ ```
45
+
46
+ </section>
47
+
48
+ <section class="usage">
49
+
50
+ ## Usage
51
+
52
+ ```javascript
53
+ var cuanyBy = require( '@stdlib/array-base-cuany-by' );
54
+ ```
55
+
56
+ #### cuanyBy( x, predicate\[, thisArg] )
57
+
58
+ Cumulatively tests whether at least one element in a provided array passes a test implemented by a `predicate` function.
59
+
60
+ ```javascript
61
+ function isPositive( value ) {
62
+ return ( value > 0 );
63
+ }
64
+
65
+ var x = [ 0, 0, 0, 1, 0 ];
66
+
67
+ var y = cuanyBy( x, isPositive );
68
+ // returns [ false, false, false, true, true ]
69
+ ```
70
+
71
+ The `predicate` function is provided three arguments:
72
+
73
+ - **value**: current array element.
74
+ - **index**: current array element index.
75
+ - **arr**: input array.
76
+
77
+ To set the `predicate` function execution context, provide a `thisArg`.
78
+
79
+ ```javascript
80
+ function isPositive( value ) {
81
+ this.count += 1;
82
+ return ( value > 0 );
83
+ }
84
+
85
+ var x = [ 0, 0, 0, 1, 0 ];
86
+
87
+ var context = {
88
+ 'count': 0
89
+ };
90
+
91
+ var out = cuanyBy( x, isPositive, context );
92
+ // returns [ false, false, false, true, true ]
93
+
94
+ var cnt = context.count;
95
+ // returns 4
96
+ ```
97
+
98
+ #### cuanyBy.assign( x, out, stride, offset, predicate\[, thisArg] )
99
+
100
+ Cumulatively tests whether at least one element in a provided array passes a test implemented by a `predicate` function and assigns results to a provided output array.
101
+
102
+ ```javascript
103
+ function isPositive( value ) {
104
+ return ( value > 0 );
105
+ }
106
+
107
+ var x = [ 0, 0, 0, 1, 0 ];
108
+ var y = [ false, null, false, null, false, null, false, null, false, null ];
109
+
110
+ var out = cuanyBy.assign( x, y, 2, 0, isPositive );
111
+ // returns [ false, null, false, null, false, null, true, null, true, null ]
112
+
113
+ var bool = ( out === y );
114
+ // returns true
115
+ ```
116
+
117
+ The function supports the following parameters:
118
+
119
+ - **x**: input array.
120
+ - **out**: output array.
121
+ - **stride**: output array stride.
122
+ - **offset**: output array offset.
123
+ - **predicate**: test function.
124
+
125
+ </section>
126
+
127
+ <!-- /.usage -->
128
+
129
+ <section class="notes">
130
+
131
+ </section>
132
+
133
+ <!-- /.notes -->
134
+
135
+ <section class="examples">
136
+
137
+ ## Examples
138
+
139
+ <!-- eslint no-undef: "error" -->
140
+
141
+ ```javascript
142
+ var bernoulli = require( '@stdlib/random-array-bernoulli' );
143
+ var cuanyBy = require( '@stdlib/array-base-cuany-by' );
144
+
145
+ function isPositive( value ) {
146
+ return ( value > 0 );
147
+ }
148
+
149
+ // Create an array of random values:
150
+ var x = bernoulli( 10, 0.1 );
151
+ console.log( x );
152
+
153
+ // Cumulatively determine whether at least one element is positive:
154
+ var out = cuanyBy( x, isPositive );
155
+ console.log( out );
156
+ ```
157
+
158
+ </section>
159
+
160
+ <!-- /.examples -->
161
+
162
+ <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
163
+
164
+ <section class="related">
165
+
166
+ </section>
167
+
168
+ <!-- /.related -->
169
+
170
+ <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
171
+
172
+
173
+ <section class="main-repo" >
174
+
175
+ * * *
176
+
177
+ ## Notice
178
+
179
+ This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
180
+
181
+ For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib].
182
+
183
+ #### Community
184
+
185
+ [![Chat][chat-image]][chat-url]
186
+
187
+ ---
188
+
189
+ ## License
190
+
191
+ See [LICENSE][stdlib-license].
192
+
193
+
194
+ ## Copyright
195
+
196
+ Copyright &copy; 2016-2026. The Stdlib [Authors][stdlib-authors].
197
+
198
+ </section>
199
+
200
+ <!-- /.stdlib -->
201
+
202
+ <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
203
+
204
+ <section class="links">
205
+
206
+ [npm-image]: http://img.shields.io/npm/v/@stdlib/array-base-cuany-by.svg
207
+ [npm-url]: https://npmjs.org/package/@stdlib/array-base-cuany-by
208
+
209
+ [test-image]: https://github.com/stdlib-js/array-base-cuany-by/actions/workflows/test.yml/badge.svg?branch=v0.1.0
210
+ [test-url]: https://github.com/stdlib-js/array-base-cuany-by/actions/workflows/test.yml?query=branch:v0.1.0
211
+
212
+ [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/array-base-cuany-by/main.svg
213
+ [coverage-url]: https://codecov.io/github/stdlib-js/array-base-cuany-by?branch=main
214
+
215
+ <!--
216
+
217
+ [dependencies-image]: https://img.shields.io/david/stdlib-js/array-base-cuany-by.svg
218
+ [dependencies-url]: https://david-dm.org/stdlib-js/array-base-cuany-by/main
219
+
220
+ -->
221
+
222
+ [chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
223
+ [chat-url]: https://stdlib.zulipchat.com
224
+
225
+ [stdlib]: https://github.com/stdlib-js/stdlib
226
+
227
+ [stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
228
+
229
+ [umd]: https://github.com/umdjs/umd
230
+ [es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
231
+
232
+ [deno-url]: https://github.com/stdlib-js/array-base-cuany-by/tree/deno
233
+ [deno-readme]: https://github.com/stdlib-js/array-base-cuany-by/blob/deno/README.md
234
+ [umd-url]: https://github.com/stdlib-js/array-base-cuany-by/tree/umd
235
+ [umd-readme]: https://github.com/stdlib-js/array-base-cuany-by/blob/umd/README.md
236
+ [esm-url]: https://github.com/stdlib-js/array-base-cuany-by/tree/esm
237
+ [esm-readme]: https://github.com/stdlib-js/array-base-cuany-by/blob/esm/README.md
238
+ [branches-url]: https://github.com/stdlib-js/array-base-cuany-by/blob/main/branches.md
239
+
240
+ [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/array-base-cuany-by/main/LICENSE
241
+
242
+ </section>
243
+
244
+ <!-- /.links -->
package/SECURITY.md ADDED
@@ -0,0 +1,5 @@
1
+ # Security
2
+
3
+ > Policy for reporting security vulnerabilities.
4
+
5
+ See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security).
@@ -0,0 +1,3 @@
1
+ /// <reference path="../docs/types/index.d.ts" />
2
+ import cuanyBy from '../docs/types/index';
3
+ export = cuanyBy;
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";var d=function(a,r){return function(){return r||a((r={exports:{}}).exports,r),r.exports}};var f=d(function(z,y){
2
+ var q=require('@stdlib/array-base-arraylike2object/dist');function b(a,r,t,i,o,c){var e,s,n;for(e=!1,s=i,n=0;n<a.length;n++)!e&&o.call(c,a[n],n,a)&&(e=!0),r[s]=e,s+=t;return r}function j(a,r,t,i,o,c){var e,s,n,g,v,l,u;for(e=a.data,s=r.data,n=a.accessors[0],g=r.accessors[1],v=!1,l=i,u=0;u<e.length;u++)!v&&o.call(c,n(e,u),u,a)&&(v=!0),g(s,l,v),l+=t;return s}function k(a,r,t,i,o,c){var e=q(a),s=q(r);return e.accessorProtocol||s.accessorProtocol?j(e,s,t,i,o,c):(b(a,r,t,i,o,c),r)}y.exports=k
3
+ });var p=d(function(C,h){
4
+ var m=require('@stdlib/array-base-filled/dist'),x=f();function B(a,r,t){var i=m(!1,a.length);return x(a,i,1,0,r,t)}h.exports=B
5
+ });var O=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),P=p(),R=f();O(P,"assign",R);module.exports=P;
6
+ /** @license Apache-2.0 */
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../lib/assign.js", "../lib/main.js", "../lib/index.js"],
4
+ "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar arraylike2object = require( '@stdlib/array-base-arraylike2object' );\n\n\n// FUNCTIONS //\n\n/**\n* Cumulatively tests whether at least one element in a provided array passes a test implemented by a predicate function.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Collection} y - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @param {Function} predicate - test function\n* @param {*} thisArg - execution context\n* @returns {Collection} output array\n*\n* @example\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = [ false, false, false, true, false ];\n* var y = [ false, null, false, null, false, null, false, null, false, null ];\n*\n* var out = indexed( x, y, 2, 0, isPositive );\n* // returns [ false, null, false, null, false, null, true, null, true, null ]\n*/\nfunction indexed( x, y, stride, offset, predicate, thisArg ) {\n\tvar flg;\n\tvar io;\n\tvar i;\n\n\tflg = false;\n\tio = offset;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( !flg && predicate.call(thisArg, x[ i ], i, x ) ) {\n\t\t\tflg = true;\n\t\t}\n\t\ty[ io ] = flg;\n\t\tio += stride;\n\t}\n\treturn y;\n}\n\n/**\n* Cumulatively tests whether at least one element in a provided array passes a test implemented by a predicate function.\n*\n* @private\n* @param {Object} x - input array object\n* @param {Object} y - output array object\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @param {Function} predicate - test function\n* @param {*} thisArg - execution context\n* @returns {Collection} output array\n*\n* @example\n* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' );\n* var arraylike2object = require( '@stdlib/array-base-arraylike2object' );\n*\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = toAccessorArray( [ false, false, false, true, false ] );\n* var y = toAccessorArray( [ false, null, false, null, false, null, false, null, false, null ] );\n*\n* var arr = accessors( arraylike2object( x ), arraylike2object( y ), 2, 0, isPositive );\n*\n* var v = y.get( 0 );\n* // returns false\n*\n* v = y.get( 2 );\n* // returns false\n*\n* v = y.get( 4 );\n* // returns false\n*\n* v = y.get( 6 );\n* // returns true\n*\n* v = y.get( 8 );\n* // returns true\n*/\nfunction accessors( x, y, stride, offset, predicate, thisArg ) {\n\tvar xdata;\n\tvar ydata;\n\tvar xget;\n\tvar yset;\n\tvar flg;\n\tvar io;\n\tvar i;\n\n\txdata = x.data;\n\tydata = y.data;\n\n\txget = x.accessors[ 0 ];\n\tyset = y.accessors[ 1 ];\n\n\tflg = false;\n\tio = offset;\n\tfor ( i = 0; i < xdata.length; i++ ) {\n\t\tif ( !flg && predicate.call( thisArg, xget( xdata, i ), i, x ) ) {\n\t\t\tflg = true;\n\t\t}\n\t\tyset( ydata, io, flg );\n\t\tio += stride;\n\t}\n\treturn ydata;\n}\n\n\n// MAIN //\n\n/**\n* Cumulatively tests whether at least one element in a provided array passes a test implemented by a predicate function and assigns results to a provided output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} y - output array\n* @param {integer} stride - output array stride\n* @param {NonNegativeInteger} offset - output array offset\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - execution context\n* @returns {Collection} output array\n*\n* @example\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = [ 0, 0, 0, 1, 0 ];\n* var y = [ false, null, false, null, false, null, false, null, false, null ];\n*\n* var out = assign( x, y, 2, 0, isPositive );\n// returns [ false, null, false, null, false, null, true, null, true, null ]\n*\n* var bool = ( y === out );\n* // returns true\n*/\nfunction assign( x, y, stride, offset, predicate, thisArg ) {\n\tvar xo = arraylike2object( x );\n\tvar yo = arraylike2object( y );\n\n\tif (\n\t\txo.accessorProtocol ||\n\t\tyo.accessorProtocol\n\t) {\n\t\treturn accessors( xo, yo, stride, offset, predicate, thisArg );\n\t}\n\tindexed( x, y, stride, offset, predicate, thisArg );\n\treturn y;\n}\n\n\n// EXPORTS //\n\nmodule.exports = assign;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar filled = require( '@stdlib/array-base-filled' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\n/**\n* Cumulatively tests whether at least one element in a provided array passes a test implemented by a predicate function.\n*\n* @param {Collection} x - input array\n* @param {Function} predicate - test function\n* @param {*} [thisArg] - execution context\n* @returns {Array} output array\n*\n* @example\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = [ 0, 0, 0, 1, 0 ];\n*\n* var y = cuanyBy( x, isPositive );\n* // returns [ false, false, false, true, true ]\n*/\nfunction cuanyBy( x, predicate, thisArg ) {\n\tvar y = filled( false, x.length );\n\treturn assign( x, y, 1, 0, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nmodule.exports = cuanyBy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Cumulatively test whether at least one element in a provided array passes a test implemented by a predicate function.\n*\n* @module @stdlib/array-base-cuany-by\n*\n* @example\n* var cuanyBy = require( '@stdlib/array-base-cuany-by' );\n*\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = [ 0, 0, 0, 1, 0 ];\n*\n* var y = cuanyBy( x, isPositive );\n* // returns [ false, false, false, true, true ]\n*\n* @example\n* var cuanyBy = require( '@stdlib/array-base-cuany-by' );\n*\n* function isPositive( v ) {\n* return v > 0;\n* }\n*\n* var x = [ 0, 0, 0, 1, 0 ];\n* var y = [ false, null, false, null, false, null, false, null, false, null ];\n*\n* var arr = cuanyBy.assign( x, y, 2, 0, isPositive );\n* // returns [ false, null, false, null, false, null, true, null, true, null ]\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar assign = require( './assign.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'assign', assign );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
5
+ "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAmB,QAAS,qCAAsC,EA4BtE,SAASC,EAASC,EAAGC,EAAGC,EAAQC,EAAQC,EAAWC,EAAU,CAC5D,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAM,GACNC,EAAKJ,EACCK,EAAI,EAAGA,EAAIR,EAAE,OAAQQ,IACrB,CAACF,GAAOF,EAAU,KAAKC,EAASL,EAAGQ,CAAE,EAAGA,EAAGR,CAAE,IACjDM,EAAM,IAEPL,EAAGM,CAAG,EAAID,EACVC,GAAML,EAEP,OAAOD,CACR,CA0CA,SAASQ,EAAWT,EAAGC,EAAGC,EAAQC,EAAQC,EAAWC,EAAU,CAC9D,IAAIK,EACAC,EACAC,EACAC,EACAP,EACAC,EACAC,EAUJ,IARAE,EAAQV,EAAE,KACVW,EAAQV,EAAE,KAEVW,EAAOZ,EAAE,UAAW,CAAE,EACtBa,EAAOZ,EAAE,UAAW,CAAE,EAEtBK,EAAM,GACNC,EAAKJ,EACCK,EAAI,EAAGA,EAAIE,EAAM,OAAQF,IACzB,CAACF,GAAOF,EAAU,KAAMC,EAASO,EAAMF,EAAOF,CAAE,EAAGA,EAAGR,CAAE,IAC5DM,EAAM,IAEPO,EAAMF,EAAOJ,EAAID,CAAI,EACrBC,GAAML,EAEP,OAAOS,CACR,CA8BA,SAASG,EAAQd,EAAGC,EAAGC,EAAQC,EAAQC,EAAWC,EAAU,CAC3D,IAAIU,EAAKjB,EAAkBE,CAAE,EACzBgB,EAAKlB,EAAkBG,CAAE,EAE7B,OACCc,EAAG,kBACHC,EAAG,iBAEIP,EAAWM,EAAIC,EAAId,EAAQC,EAAQC,EAAWC,CAAQ,GAE9DN,EAASC,EAAGC,EAAGC,EAAQC,EAAQC,EAAWC,CAAQ,EAC3CJ,EACR,CAKAJ,EAAO,QAAUiB,ICnLjB,IAAAG,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAS,QAAS,2BAA4B,EAC9CC,EAAS,IAuBb,SAASC,EAASC,EAAGC,EAAWC,EAAU,CACzC,IAAIC,EAAIN,EAAQ,GAAOG,EAAE,MAAO,EAChC,OAAOF,EAAQE,EAAGG,EAAG,EAAG,EAAGF,EAAWC,CAAQ,CAC/C,CAKAN,EAAO,QAAUG,ICDjB,IAAIK,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAS,IAKbF,EAAaC,EAAM,SAAUC,CAAO,EAKpC,OAAO,QAAUD",
6
+ "names": ["require_assign", "__commonJSMin", "exports", "module", "arraylike2object", "indexed", "x", "y", "stride", "offset", "predicate", "thisArg", "flg", "io", "i", "accessors", "xdata", "ydata", "xget", "yset", "assign", "xo", "yo", "require_main", "__commonJSMin", "exports", "module", "filled", "assign", "cuanyBy", "x", "predicate", "thisArg", "y", "setReadOnly", "main", "assign"]
7
+ }
@@ -0,0 +1,202 @@
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
+ /// <reference types="@stdlib/types"/>
22
+
23
+ import { Collection, AccessorArrayLike, TypedArray, BooleanArray } from '@stdlib/types/array';
24
+
25
+ /**
26
+ * Returns a boolean indicating whether an element passes a test.
27
+ *
28
+ * @returns boolean indicating whether an element passes a test
29
+ */
30
+ type Nullary<U> = ( this: U ) => boolean;
31
+
32
+ /**
33
+ * Returns a boolean indicating whether an element passes a test.
34
+ *
35
+ * @param value - current array element
36
+ * @returns boolean indicating whether an element passes a test
37
+ */
38
+ type Unary<T, U> = ( this: U, value: T ) => boolean;
39
+
40
+ /**
41
+ * Returns a boolean indicating whether an element passes a test.
42
+ *
43
+ * @param value - current array element
44
+ * @param index - current array element index
45
+ * @returns boolean indicating whether an element passes a test
46
+ */
47
+ type Binary<T, U> = ( this: U, value: T, index: number ) => boolean;
48
+
49
+ /**
50
+ * Returns a boolean indicating whether an element passes a test.
51
+ *
52
+ * @param value - current array element
53
+ * @param index - current array element index
54
+ * @param arr - input array
55
+ * @returns boolean indicating whether an element passes a test
56
+ */
57
+ type Ternary<T, U> = ( this: U, value: T, index: number, arr: Collection<T> | AccessorArrayLike<T> ) => boolean;
58
+
59
+ /**
60
+ * Returns a boolean indicating whether an element passes a test.
61
+ *
62
+ * @param value - current array element
63
+ * @param index - current array element index
64
+ * @param arr - input array
65
+ * @returns boolean indicating whether an element passes a test
66
+ */
67
+ type Predicate<T, U> = Nullary<U> | Unary<T, U> | Binary<T, U> | Ternary<T, U>;
68
+
69
+ /**
70
+ * Interface describing `cuanyBy`.
71
+ */
72
+ interface CuAnyBy {
73
+ /**
74
+ * Cumulatively tests whether at least one element in a provided array passes a test implemented by a predicate function.
75
+ *
76
+ * @param x - input array
77
+ * @param predicate - predicate function
78
+ * @param thisArg - predicate function execution context
79
+ * @returns output array
80
+ *
81
+ * @example
82
+ * function isPositive( v ) {
83
+ * return v > 0;
84
+ * }
85
+ *
86
+ * var x = [ 0, 0, 0, 1, 0 ];
87
+ *
88
+ * var y = cuanyBy( x, isPositive );
89
+ * // returns [ false, false, false, true, true ];
90
+ */
91
+ <T = unknown, U = unknown>( x: Collection<T> | AccessorArrayLike<T>, predicate: Predicate<T, U>, thisArg?: ThisParameterType<Predicate<T, U>> ): Array<boolean>;
92
+
93
+ /**
94
+ * Cumulatively tests whether at least one element in a provided array passes a test implemented by a predicate function and assigns the results to a provided output array.
95
+ *
96
+ * @param x - input array
97
+ * @param y - output array
98
+ * @param stride - output array stride
99
+ * @param offset - output array offset
100
+ * @param predicate - predicate function
101
+ * @param thisArg - predicate function execution context
102
+ * @returns output array
103
+ *
104
+ * @example
105
+ * function isPositive( v ) {
106
+ * return v > 0;
107
+ * }
108
+ *
109
+ * var x = [ 0, 0, 0, 1, 0 ];
110
+ * var y = [ false, null, false, null, false, null, true, null, true, null ];
111
+ *
112
+ * var arr = cuanyBy.assign( x, y, 2, 0, isPositive );
113
+ * // returns [ false, null, false, null, false, null, true, null, true, null ];
114
+ */
115
+ assign<T = unknown, U = unknown, V = unknown>( x: Collection<T> | AccessorArrayLike<T>, out: Array<U>, stride: number, offset: number, predicate: Predicate<T, V>, thisArg?: ThisParameterType<Predicate<T, V>> ): Array<U | boolean>;
116
+
117
+ /**
118
+ * Cumulatively tests whether at least one array element in a provided array passes a test implemented by a predicate function and assigns the results to the provided output array.
119
+ *
120
+ * @param x - input array
121
+ * @param out - output array
122
+ * @param stride - output array stride
123
+ * @param offset - output array offset
124
+ * @param predicate - test function
125
+ * @param thisArg - execution context
126
+ * @returns output array
127
+ *
128
+ * @example
129
+ * var BooleanArray = require( '@stdlib/array-bool' );
130
+ *
131
+ * function isPositive( v ) {
132
+ * return ( v > 0 );
133
+ * }
134
+ * var x = [ 0, 1, 0, 1, 0 ];
135
+ * var y = new BooleanArray( [ false, false, false, false, false, false, false, false, false, false ] );
136
+ *
137
+ * var arr = cuanyBy.assign( x, y, 2, 0, isPositive );
138
+ * // returns <BooleanArray>
139
+ *
140
+ * var v = arr.get( 4 );
141
+ * // returns true
142
+ */
143
+ assign<T, U extends TypedArray | BooleanArray, V = unknown>( x: Collection<T> | AccessorArrayLike<T>, out: U, stride: number, offset: number, predicate: Predicate<T, V>, thisArg?: ThisParameterType<Predicate<T, V>> ): U;
144
+
145
+ /**
146
+ * Cumulatively tests whether at least one element in a provided array passes a test implemented by a predicate function and assigns the results to a provided output array.
147
+ *
148
+ * @param x - input array
149
+ * @param y - output array
150
+ * @param stride - output array stride
151
+ * @param offset - output array offset
152
+ * @param predicate - predicate function
153
+ * @param thisArg - predicate function execution context
154
+ * @returns output array
155
+ *
156
+ * @example
157
+ * function isPositive( v ) {
158
+ * return v > 0;
159
+ * }
160
+ *
161
+ * var x = [ 0, 0, 0, 1, 0 ];
162
+ * var y = [ false, null, false, null, false, null, true, null, true, null ];
163
+ *
164
+ * var arr = cuanyBy.assign( x, y, 2, 0, isPositive );
165
+ * // returns [ false, null, false, null, false, null, true, null, true, null ];
166
+ */
167
+ assign<T = unknown, U = unknown, V = unknown>( x: Collection<T> | AccessorArrayLike<T>, out: Collection<U> | AccessorArrayLike<U>, stride: number, offset: number, predicate: Predicate<T, V>, thisArg?: ThisParameterType<Predicate<T, V>> ): Collection<U | boolean> | AccessorArrayLike<U | boolean>;
168
+ }
169
+
170
+ /**
171
+ * Cumulatively tests whether at least one element in a provided array passes a test implemented by a predicate function.
172
+ *
173
+ * @param x - input array
174
+ * @returns output array
175
+ *
176
+ * @example
177
+ * function isPositive( value ) {
178
+ * return ( value > 0 );
179
+ * }
180
+ *
181
+ * var x = [ 0, 0, 0, 1, 0 ];
182
+ *
183
+ * var y = cuanyBy( x, isPositive );
184
+ * // returns [ false, false, false, true, true ]
185
+ *
186
+ * @example
187
+ * function isPositive( value ) {
188
+ * return ( value > 0 );
189
+ * }
190
+ *
191
+ * var x = [ 0, 0, 0, 1, 0 ];
192
+ * var y = [ false, null, false, null, false, null, false, null, false, null ];
193
+ *
194
+ * var arr = cuanyBy.assign( x, y, 2, 0, isPositive );
195
+ * // returns [ false, null, false, null, false, null, true, null, true, null ]
196
+ */
197
+ declare var cuanyBy: CuAnyBy;
198
+
199
+
200
+ // EXPORTS //
201
+
202
+ export = cuanyBy;
package/lib/assign.js ADDED
@@ -0,0 +1,180 @@
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 arraylike2object = require( '@stdlib/array-base-arraylike2object' );
24
+
25
+
26
+ // FUNCTIONS //
27
+
28
+ /**
29
+ * Cumulatively tests whether at least one element in a provided array passes a test implemented by a predicate function.
30
+ *
31
+ * @private
32
+ * @param {Collection} x - input array
33
+ * @param {Collection} y - output array
34
+ * @param {integer} stride - output array stride
35
+ * @param {NonNegativeInteger} offset - output array offset
36
+ * @param {Function} predicate - test function
37
+ * @param {*} thisArg - execution context
38
+ * @returns {Collection} output array
39
+ *
40
+ * @example
41
+ * function isPositive( v ) {
42
+ * return v > 0;
43
+ * }
44
+ *
45
+ * var x = [ false, false, false, true, false ];
46
+ * var y = [ false, null, false, null, false, null, false, null, false, null ];
47
+ *
48
+ * var out = indexed( x, y, 2, 0, isPositive );
49
+ * // returns [ false, null, false, null, false, null, true, null, true, null ]
50
+ */
51
+ function indexed( x, y, stride, offset, predicate, thisArg ) {
52
+ var flg;
53
+ var io;
54
+ var i;
55
+
56
+ flg = false;
57
+ io = offset;
58
+ for ( i = 0; i < x.length; i++ ) {
59
+ if ( !flg && predicate.call(thisArg, x[ i ], i, x ) ) {
60
+ flg = true;
61
+ }
62
+ y[ io ] = flg;
63
+ io += stride;
64
+ }
65
+ return y;
66
+ }
67
+
68
+ /**
69
+ * Cumulatively tests whether at least one element in a provided array passes a test implemented by a predicate function.
70
+ *
71
+ * @private
72
+ * @param {Object} x - input array object
73
+ * @param {Object} y - output array object
74
+ * @param {integer} stride - output array stride
75
+ * @param {NonNegativeInteger} offset - output array offset
76
+ * @param {Function} predicate - test function
77
+ * @param {*} thisArg - execution context
78
+ * @returns {Collection} output array
79
+ *
80
+ * @example
81
+ * var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' );
82
+ * var arraylike2object = require( '@stdlib/array-base-arraylike2object' );
83
+ *
84
+ * function isPositive( v ) {
85
+ * return v > 0;
86
+ * }
87
+ *
88
+ * var x = toAccessorArray( [ false, false, false, true, false ] );
89
+ * var y = toAccessorArray( [ false, null, false, null, false, null, false, null, false, null ] );
90
+ *
91
+ * var arr = accessors( arraylike2object( x ), arraylike2object( y ), 2, 0, isPositive );
92
+ *
93
+ * var v = y.get( 0 );
94
+ * // returns false
95
+ *
96
+ * v = y.get( 2 );
97
+ * // returns false
98
+ *
99
+ * v = y.get( 4 );
100
+ * // returns false
101
+ *
102
+ * v = y.get( 6 );
103
+ * // returns true
104
+ *
105
+ * v = y.get( 8 );
106
+ * // returns true
107
+ */
108
+ function accessors( x, y, stride, offset, predicate, thisArg ) {
109
+ var xdata;
110
+ var ydata;
111
+ var xget;
112
+ var yset;
113
+ var flg;
114
+ var io;
115
+ var i;
116
+
117
+ xdata = x.data;
118
+ ydata = y.data;
119
+
120
+ xget = x.accessors[ 0 ];
121
+ yset = y.accessors[ 1 ];
122
+
123
+ flg = false;
124
+ io = offset;
125
+ for ( i = 0; i < xdata.length; i++ ) {
126
+ if ( !flg && predicate.call( thisArg, xget( xdata, i ), i, x ) ) {
127
+ flg = true;
128
+ }
129
+ yset( ydata, io, flg );
130
+ io += stride;
131
+ }
132
+ return ydata;
133
+ }
134
+
135
+
136
+ // MAIN //
137
+
138
+ /**
139
+ * Cumulatively tests whether at least one element in a provided array passes a test implemented by a predicate function and assigns results to a provided output array.
140
+ *
141
+ * @param {Collection} x - input array
142
+ * @param {Collection} y - output array
143
+ * @param {integer} stride - output array stride
144
+ * @param {NonNegativeInteger} offset - output array offset
145
+ * @param {Function} predicate - test function
146
+ * @param {*} [thisArg] - execution context
147
+ * @returns {Collection} output array
148
+ *
149
+ * @example
150
+ * function isPositive( v ) {
151
+ * return v > 0;
152
+ * }
153
+ *
154
+ * var x = [ 0, 0, 0, 1, 0 ];
155
+ * var y = [ false, null, false, null, false, null, false, null, false, null ];
156
+ *
157
+ * var out = assign( x, y, 2, 0, isPositive );
158
+ // returns [ false, null, false, null, false, null, true, null, true, null ]
159
+ *
160
+ * var bool = ( y === out );
161
+ * // returns true
162
+ */
163
+ function assign( x, y, stride, offset, predicate, thisArg ) {
164
+ var xo = arraylike2object( x );
165
+ var yo = arraylike2object( y );
166
+
167
+ if (
168
+ xo.accessorProtocol ||
169
+ yo.accessorProtocol
170
+ ) {
171
+ return accessors( xo, yo, stride, offset, predicate, thisArg );
172
+ }
173
+ indexed( x, y, stride, offset, predicate, thisArg );
174
+ return y;
175
+ }
176
+
177
+
178
+ // EXPORTS //
179
+
180
+ module.exports = assign;
package/lib/index.js ADDED
@@ -0,0 +1,66 @@
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
+ /**
22
+ * Cumulatively test whether at least one element in a provided array passes a test implemented by a predicate function.
23
+ *
24
+ * @module @stdlib/array-base-cuany-by
25
+ *
26
+ * @example
27
+ * var cuanyBy = require( '@stdlib/array-base-cuany-by' );
28
+ *
29
+ * function isPositive( v ) {
30
+ * return v > 0;
31
+ * }
32
+ *
33
+ * var x = [ 0, 0, 0, 1, 0 ];
34
+ *
35
+ * var y = cuanyBy( x, isPositive );
36
+ * // returns [ false, false, false, true, true ]
37
+ *
38
+ * @example
39
+ * var cuanyBy = require( '@stdlib/array-base-cuany-by' );
40
+ *
41
+ * function isPositive( v ) {
42
+ * return v > 0;
43
+ * }
44
+ *
45
+ * var x = [ 0, 0, 0, 1, 0 ];
46
+ * var y = [ false, null, false, null, false, null, false, null, false, null ];
47
+ *
48
+ * var arr = cuanyBy.assign( x, y, 2, 0, isPositive );
49
+ * // returns [ false, null, false, null, false, null, true, null, true, null ]
50
+ */
51
+
52
+ // MODULES //
53
+
54
+ var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );
55
+ var main = require( './main.js' );
56
+ var assign = require( './assign.js' );
57
+
58
+
59
+ // MAIN //
60
+
61
+ setReadOnly( main, 'assign', assign );
62
+
63
+
64
+ // EXPORTS //
65
+
66
+ module.exports = main;
package/lib/main.js ADDED
@@ -0,0 +1,55 @@
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 filled = require( '@stdlib/array-base-filled' );
24
+ var assign = require( './assign.js' );
25
+
26
+
27
+ // MAIN //
28
+
29
+ /**
30
+ * Cumulatively tests whether at least one element in a provided array passes a test implemented by a predicate function.
31
+ *
32
+ * @param {Collection} x - input array
33
+ * @param {Function} predicate - test function
34
+ * @param {*} [thisArg] - execution context
35
+ * @returns {Array} output array
36
+ *
37
+ * @example
38
+ * function isPositive( v ) {
39
+ * return v > 0;
40
+ * }
41
+ *
42
+ * var x = [ 0, 0, 0, 1, 0 ];
43
+ *
44
+ * var y = cuanyBy( x, isPositive );
45
+ * // returns [ false, false, false, true, true ]
46
+ */
47
+ function cuanyBy( x, predicate, thisArg ) {
48
+ var y = filled( false, x.length );
49
+ return assign( x, y, 1, 0, predicate, thisArg );
50
+ }
51
+
52
+
53
+ // EXPORTS //
54
+
55
+ module.exports = cuanyBy;
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "@stdlib/array-base-cuany-by",
3
+ "version": "0.1.0",
4
+ "description": "Cumulatively test whether at least one element in a provided array passes a test implemented by a predicate function.",
5
+ "license": "Apache-2.0",
6
+ "author": {
7
+ "name": "The Stdlib Authors",
8
+ "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
9
+ },
10
+ "contributors": [
11
+ {
12
+ "name": "The Stdlib Authors",
13
+ "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
14
+ }
15
+ ],
16
+ "main": "./lib",
17
+ "directories": {
18
+ "doc": "./docs",
19
+ "lib": "./lib",
20
+ "dist": "./dist"
21
+ },
22
+ "types": "./docs/types",
23
+ "scripts": {},
24
+ "homepage": "https://stdlib.io",
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git://github.com/stdlib-js/array-base-cuany-by.git"
28
+ },
29
+ "bugs": {
30
+ "url": "https://github.com/stdlib-js/stdlib/issues"
31
+ },
32
+ "dependencies": {
33
+ "@stdlib/array-base-arraylike2object": "^0.2.1",
34
+ "@stdlib/array-base-filled": "^0.2.2",
35
+ "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.2"
36
+ },
37
+ "devDependencies": {},
38
+ "engines": {
39
+ "node": ">=0.10.0",
40
+ "npm": ">2.7.0"
41
+ },
42
+ "os": [
43
+ "aix",
44
+ "darwin",
45
+ "freebsd",
46
+ "linux",
47
+ "macos",
48
+ "openbsd",
49
+ "sunos",
50
+ "win32",
51
+ "windows"
52
+ ],
53
+ "keywords": [
54
+ "stdlib",
55
+ "stdtypes",
56
+ "types",
57
+ "data",
58
+ "structure",
59
+ "utils",
60
+ "generic",
61
+ "array",
62
+ "cuany",
63
+ "cumulative",
64
+ "test",
65
+ "some",
66
+ "array.some",
67
+ "validate"
68
+ ],
69
+ "funding": {
70
+ "type": "opencollective",
71
+ "url": "https://opencollective.com/stdlib"
72
+ }
73
+ }