@stdlib/array-base-cuevery-by-right 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,236 @@
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
+ # cueveryByRight
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 every array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left.
37
+
38
+ <section class="installation">
39
+
40
+ ## Installation
41
+
42
+ ```bash
43
+ npm install @stdlib/array-base-cuevery-by-right
44
+ ```
45
+
46
+ </section>
47
+
48
+ <section class="usage">
49
+
50
+ ## Usage
51
+
52
+ ```javascript
53
+ var cueveryByRight = require( '@stdlib/array-base-cuevery-by-right' );
54
+ ```
55
+
56
+ #### cueveryByRight( x, predicate\[, thisArg ] )
57
+
58
+ Cumulatively tests whether every array element in a provided array passes a test implemented by a `predicate` function, while iterating from right-to-left.
59
+
60
+ ```javascript
61
+ function fcn( value ) {
62
+ return value > 0;
63
+ }
64
+
65
+ var x = [ 0, 0, 1, 1, 1 ];
66
+
67
+ var y = cueveryByRight( x, fcn );
68
+ // returns [ true, true, true, false, false ];
69
+ ```
70
+
71
+ #### cueveryByRight.assign( x, out, stride, offset, predicate\[, thisArg ] )
72
+
73
+ 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.
74
+
75
+ ```javascript
76
+ function fcn( v ) {
77
+ return v > 0;
78
+ }
79
+
80
+ var x = [ 0, 0, 1, 1, 1 ];
81
+ var y = [ false, null, false, null, false, null, false, null, false, null ];
82
+
83
+ var out = cueveryByRight.assign( x, y, 2, 0, fcn );
84
+ // returns [ true, null, true, null, true, null, false, null, false, null ]
85
+
86
+ var bool = ( out === y );
87
+ // returns true
88
+ ```
89
+
90
+ The invoked `predicate` function is provided three arguments:
91
+
92
+ - **value**: collection element.
93
+ - **index**: collection index.
94
+ - **collection**: input collection.
95
+
96
+ To set the function execution context, provide a `thisArg`.
97
+
98
+ ```javascript
99
+ function fcn( v ) {
100
+ this.count += 1;
101
+ return ( v > 0 );
102
+ }
103
+
104
+ var x = [ 0, 0, 1, 1, 1 ];
105
+
106
+ var context = {
107
+ 'count': 0
108
+ };
109
+
110
+ var bool = cueveryByRight( x, fcn, context );
111
+ // returns [ true, true, true, false, false ]
112
+
113
+ var count = context.count;
114
+ // returns 4
115
+ ```
116
+
117
+ </section>
118
+
119
+ <!-- /.usage -->
120
+
121
+ <section class="notes">
122
+
123
+ </section>
124
+
125
+ <!-- /.notes -->
126
+
127
+ <section class="examples">
128
+
129
+ ## Examples
130
+
131
+ <!-- eslint no-undef: "error" -->
132
+
133
+ ```javascript
134
+ var discreteUniform = require( '@stdlib/random-array-discrete-uniform' );
135
+ var cueveryByRight = require( '@stdlib/array-base-cuevery-by-right' );
136
+
137
+ function isPositive( value ) {
138
+ return ( value > 0 );
139
+ }
140
+
141
+ // Create an array of random values:
142
+ var x = discreteUniform( 10, -10, 10 );
143
+ console.log( x );
144
+
145
+ // Cumulatively test whether every array element passes a test, while iterating from right-to-left:
146
+ var out = cueveryByRight( x, isPositive );
147
+ console.log( out );
148
+ ```
149
+
150
+ </section>
151
+
152
+ <!-- /.examples -->
153
+
154
+ <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
155
+
156
+ <section class="related">
157
+
158
+ </section>
159
+
160
+ <!-- /.related -->
161
+
162
+ <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
163
+
164
+
165
+ <section class="main-repo" >
166
+
167
+ * * *
168
+
169
+ ## Notice
170
+
171
+ 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.
172
+
173
+ 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].
174
+
175
+ #### Community
176
+
177
+ [![Chat][chat-image]][chat-url]
178
+
179
+ ---
180
+
181
+ ## License
182
+
183
+ See [LICENSE][stdlib-license].
184
+
185
+
186
+ ## Copyright
187
+
188
+ Copyright &copy; 2016-2026. The Stdlib [Authors][stdlib-authors].
189
+
190
+ </section>
191
+
192
+ <!-- /.stdlib -->
193
+
194
+ <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
195
+
196
+ <section class="links">
197
+
198
+ [npm-image]: http://img.shields.io/npm/v/@stdlib/array-base-cuevery-by-right.svg
199
+ [npm-url]: https://npmjs.org/package/@stdlib/array-base-cuevery-by-right
200
+
201
+ [test-image]: https://github.com/stdlib-js/array-base-cuevery-by-right/actions/workflows/test.yml/badge.svg?branch=v0.1.0
202
+ [test-url]: https://github.com/stdlib-js/array-base-cuevery-by-right/actions/workflows/test.yml?query=branch:v0.1.0
203
+
204
+ [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/array-base-cuevery-by-right/main.svg
205
+ [coverage-url]: https://codecov.io/github/stdlib-js/array-base-cuevery-by-right?branch=main
206
+
207
+ <!--
208
+
209
+ [dependencies-image]: https://img.shields.io/david/stdlib-js/array-base-cuevery-by-right.svg
210
+ [dependencies-url]: https://david-dm.org/stdlib-js/array-base-cuevery-by-right/main
211
+
212
+ -->
213
+
214
+ [chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
215
+ [chat-url]: https://stdlib.zulipchat.com
216
+
217
+ [stdlib]: https://github.com/stdlib-js/stdlib
218
+
219
+ [stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
220
+
221
+ [umd]: https://github.com/umdjs/umd
222
+ [es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
223
+
224
+ [deno-url]: https://github.com/stdlib-js/array-base-cuevery-by-right/tree/deno
225
+ [deno-readme]: https://github.com/stdlib-js/array-base-cuevery-by-right/blob/deno/README.md
226
+ [umd-url]: https://github.com/stdlib-js/array-base-cuevery-by-right/tree/umd
227
+ [umd-readme]: https://github.com/stdlib-js/array-base-cuevery-by-right/blob/umd/README.md
228
+ [esm-url]: https://github.com/stdlib-js/array-base-cuevery-by-right/tree/esm
229
+ [esm-readme]: https://github.com/stdlib-js/array-base-cuevery-by-right/blob/esm/README.md
230
+ [branches-url]: https://github.com/stdlib-js/array-base-cuevery-by-right/blob/main/branches.md
231
+
232
+ [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/array-base-cuevery-by-right/main/LICENSE
233
+
234
+ </section>
235
+
236
+ <!-- /.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 cueveryByRight from '../docs/types/index';
3
+ export = cueveryByRight;
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 P(a,r,t,i,o,c){var e,s,n;for(e=!0,s=i,n=a.length-1;n>=0;n--)e&&!o.call(c,a[n],n,a)&&(e=!1),r[s]=e,s+=t;return r}function R(a,r,t,i,o,c){var e,s,n,g,u,l,v;for(e=a.data,s=r.data,n=a.accessors[0],g=r.accessors[1],l=i,u=!0,v=e.length-1;v>=0;v--)u&&!o.call(c,n(e,v),v,e)&&(u=!1),g(s,l,u),l+=t;return s}function b(a,r,t,i,o,c){var e,s;return e=q(a),s=q(r),e.accessorProtocol||s.accessorProtocol?(R(e,s,t,i,o,c),r):(P(a,r,t,i,o,c),r)}y.exports=b
3
+ });var p=d(function(C,h){
4
+ var j=require('@stdlib/array-base-filled/dist'),k=f();function m(a,r,t){var i=j(!0,a.length);return k(a,i,1,0,r,t)}h.exports=m
5
+ });var B=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),x=p(),O=f();B(x,"assign",O);module.exports=x;
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 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 elements in the provided output array.\n*\n* @private\n* @param {Collection} x - input array\n* @param {Collection} out - 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 fcn( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 0, 1, 1, 1 ];\n*\n* var out = [ 0, 0, 0, 0, 0 ];\n* var arr = indexed( x, out, 1, 0, fcn );\n* // returns [ true, true, true, false, false ]\n*/\nfunction indexed( x, out, stride, offset, predicate, thisArg ) {\n\tvar flg;\n\tvar io;\n\tvar i;\n\n\tflg = true;\n\tio = offset;\n\tfor ( i = x.length - 1; i >= 0; i-- ) {\n\t\tif ( flg && !predicate.call( thisArg, x[ i ], i, x ) ) {\n\t\t\tflg = false;\n\t\t}\n\t\tout[ io ] = flg;\n\t\tio += stride;\n\t}\n\treturn out;\n}\n\n/**\n* Cumulatively tests whether every array element in a provided accessor array passes a test implemented by a predicate function, while iterating from right-to-left, and assigns the results to elements in the accessor output array.\n*\n* @private\n* @param {Object} x - input array object\n* @param {Object} out - 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* function fcn( value ) {\n* return ( value > 0 );\n* }\n*\n* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' );\n* var arraylike2object = require( '@stdlib/array-base-arraylike2object' );\n*\n* var x = toAccessorArray( [ 0, 0, 1, 1, 1 ] );\n*\n* var out = toAccessorArray( [ 0, 0, 0, 0, 0 ] );\n* var arr = accessors( arraylike2object( x ), arraylike2object( out ), 1, 0, fcn );\n*\n* var v = arr.get( 4 );\n* // returns false\n*/\nfunction accessors( x, out, stride, offset, predicate, thisArg ) {\n\tvar xdata;\n\tvar odata;\n\tvar xget;\n\tvar oset;\n\tvar flg;\n\tvar io;\n\tvar i;\n\n\txdata = x.data;\n\todata = out.data;\n\n\txget = x.accessors[ 0 ];\n\toset = out.accessors[ 1 ];\n\n\tio = offset;\n\tflg = true;\n\tfor ( i = xdata.length - 1; i >= 0; i-- ) {\n\t\tif ( flg && !predicate.call( thisArg, xget( xdata, i ), i, xdata ) ) {\n\t\t\tflg = false;\n\t\t}\n\t\toset( odata, io, flg );\n\t\tio += stride;\n\t}\n\treturn odata;\n}\n\n\n// MAIN //\n\n/**\n* Cumulatively tests whether every element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left, and assigns the results to elements in the output array.\n*\n* @param {Collection} x - input array\n* @param {Collection} out - 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 fcn( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 0, 1, 1 ];\n*\n* var y = [ false, null, false, null, false, null, false, null ];\n* var out = assign( x, y, 2, 0, fcn );\n* // returns [ true, null, true, null, false, null, false, null ]\n*\n* var bool = ( y === out );\n* // returns true\n*/\nfunction assign( x, out, stride, offset, predicate, thisArg ) {\n\tvar xo;\n\tvar oo;\n\n\txo = arraylike2object( x );\n\too = arraylike2object( out );\n\tif (\n\t\txo.accessorProtocol ||\n\t\too.accessorProtocol\n\t) {\n\t\taccessors( xo, oo, stride, offset, predicate, thisArg );\n\t\treturn out;\n\t}\n\tindexed( x, out, stride, offset, predicate, thisArg );\n\treturn out;\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 every array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left.\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 fcn( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 0, 1, 1, 1 ];\n*\n* var y = cueveryByRight( x, fcn );\n* // returns [ true, true, true, false, false ]\n*/\nfunction cueveryByRight( x, predicate, thisArg ) {\n\tvar out = filled( true, x.length );\n\treturn assign( x, out, 1, 0, predicate, thisArg );\n}\n\n\n// EXPORTS //\n\nmodule.exports = cueveryByRight;\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 every element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left.\n*\n* @module @stdlib/array-base-cuevery-by-right\n*\n* @example\n* var cueveryByRight = require( '@stdlib/array-base-cuevery-by-right' );\n*\n* function fcn( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 0, 1, 1, 1 ];\n*\n* var y = cueveryByRight( x, fcn );\n* //returns [ true, true, true, false, false ]\n*\n* @example\n* var cueveryByRight = require( '@stdlib/array-base-cuevery-by-right' );\n*\n* function fcn( value ) {\n* return ( value > 0 );\n* }\n*\n* var x = [ 0, 0, 1, 1, 1 ];\n*\n* var y1 = cueveryByRight( x, fcn );\n* // returns [ true, true, true, false, false ]\n*\n* var y2 = [ false, null, false, null, false, null, false, null, false, null ];\n* var out = cueveryByRight.assign( x, y2, 2, 0, fcn );\n* // returns [ true, null, true, null, true, null, false, null, false, null ]\n*\n* var bool = ( out === y2 );\n* // returns true\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,EAAKC,EAAQC,EAAQC,EAAWC,EAAU,CAC9D,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAM,GACNC,EAAKJ,EACCK,EAAIR,EAAE,OAAS,EAAGQ,GAAK,EAAGA,IAC1BF,GAAO,CAACF,EAAU,KAAMC,EAASL,EAAGQ,CAAE,EAAGA,EAAGR,CAAE,IAClDM,EAAM,IAEPL,EAAKM,CAAG,EAAID,EACZC,GAAML,EAEP,OAAOD,CACR,CA8BA,SAASQ,EAAWT,EAAGC,EAAKC,EAAQC,EAAQC,EAAWC,EAAU,CAChE,IAAIK,EACAC,EACAC,EACAC,EACAP,EACAC,EACAC,EAUJ,IARAE,EAAQV,EAAE,KACVW,EAAQV,EAAI,KAEZW,EAAOZ,EAAE,UAAW,CAAE,EACtBa,EAAOZ,EAAI,UAAW,CAAE,EAExBM,EAAKJ,EACLG,EAAM,GACAE,EAAIE,EAAM,OAAS,EAAGF,GAAK,EAAGA,IAC9BF,GAAO,CAACF,EAAU,KAAMC,EAASO,EAAMF,EAAOF,CAAE,EAAGA,EAAGE,CAAM,IAChEJ,EAAM,IAEPO,EAAMF,EAAOJ,EAAID,CAAI,EACrBC,GAAML,EAEP,OAAOS,CACR,CA8BA,SAASG,EAAQd,EAAGC,EAAKC,EAAQC,EAAQC,EAAWC,EAAU,CAC7D,IAAIU,EACAC,EAIJ,OAFAD,EAAKjB,EAAkBE,CAAE,EACzBgB,EAAKlB,EAAkBG,CAAI,EAE1Bc,EAAG,kBACHC,EAAG,kBAEHP,EAAWM,EAAIC,EAAId,EAAQC,EAAQC,EAAWC,CAAQ,EAC/CJ,IAERF,EAASC,EAAGC,EAAKC,EAAQC,EAAQC,EAAWC,CAAQ,EAC7CJ,EACR,CAKAJ,EAAO,QAAUiB,IC1KjB,IAAAG,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAS,QAAS,2BAA4B,EAC9CC,EAAS,IAuBb,SAASC,EAAgBC,EAAGC,EAAWC,EAAU,CAChD,IAAIC,EAAMN,EAAQ,GAAMG,EAAE,MAAO,EACjC,OAAOF,EAAQE,EAAGG,EAAK,EAAG,EAAGF,EAAWC,CAAQ,CACjD,CAKAN,EAAO,QAAUG,ICKjB,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", "out", "stride", "offset", "predicate", "thisArg", "flg", "io", "i", "accessors", "xdata", "odata", "xget", "oset", "assign", "xo", "oo", "require_main", "__commonJSMin", "exports", "module", "filled", "assign", "cueveryByRight", "x", "predicate", "thisArg", "out", "setReadOnly", "main", "assign"]
7
+ }
@@ -0,0 +1,199 @@
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
+ * Checks whether an element in a collection passes a test.
27
+ *
28
+ * @returns boolean indicating whether an element in a collection passes a test
29
+ */
30
+ type Nullary<U> = ( this: U ) => boolean;
31
+
32
+ /**
33
+ * Checks whether an element in a collection passes a test.
34
+ *
35
+ * @param value - collection value
36
+ * @returns boolean indicating whether an element in a collection passes a test
37
+ */
38
+ type Unary<T, U> = ( this: U, value: T ) => boolean;
39
+
40
+ /**
41
+ * Checks whether an element in a collection passes a test.
42
+ *
43
+ * @param value - collection value
44
+ * @param index - collection index
45
+ * @returns boolean indicating whether an element in a collection passes a test
46
+ */
47
+ type Binary<T, U> = ( this: U, value: T, index: number ) => boolean;
48
+
49
+ /**
50
+ * Checks whether an element in a collection passes a test.
51
+ *
52
+ * @param value - collection value
53
+ * @param index - collection index
54
+ * @param collection - input collection
55
+ * @returns boolean indicating whether an element in a collection passes a test
56
+ */
57
+ type Ternary<T, U> = ( this: U, value: T, index: number, collection: Collection<T> ) => boolean;
58
+
59
+ /**
60
+ * Checks whether an element in a collection passes a test.
61
+ *
62
+ * @param value - collection value
63
+ * @param index - collection index
64
+ * @param collection - input collection
65
+ * @returns boolean indicating whether an element in a collection 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 `cueveryByRight`.
71
+ */
72
+ interface CueveryByRight {
73
+ /**
74
+ * Cumulatively tests whether every array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left.
75
+ *
76
+ * @param x - input array
77
+ * @param predicate - test function
78
+ * @param thisArg - execution context
79
+ * @returns output array
80
+ *
81
+ * @example
82
+ * function isPositive( v ) {
83
+ * return v > 0;
84
+ * }
85
+ * var x = [ 1, 0, 0, 1, 1 ];
86
+ *
87
+ * var y = cueveryByRight( x, isPositive );
88
+ * // returns [ true, true, false, false, false ];
89
+ */
90
+ <T = unknown, U = unknown>( x: Collection<T> | AccessorArrayLike<T>, predicate: Predicate<T, U>, thisArg?: ThisParameterType<Predicate<T, U>> ): Array<boolean>;
91
+
92
+ /**
93
+ * 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 provided output array.
94
+ *
95
+ * @param x - input array
96
+ * @param y - output array
97
+ * @param stride - output array stride
98
+ * @param offset - output array offset
99
+ * @param predicate - test function
100
+ * @param thisArg - execution context
101
+ * @returns output array
102
+ *
103
+ * @example
104
+ * function isPositive( v ) {
105
+ * return v > 0;
106
+ * }
107
+ * var x = [ 0, 0, 1, 1, 1 ];
108
+ * var y = [ false, null, false, null, false, null, false, null, false, null ];
109
+ *
110
+ * var arr = cueveryByRight.assign( x, y, 2, 0, isPositive );
111
+ * // returns [ true, null, true, null, true, null, false, null, false, null ];
112
+ */
113
+ 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>;
114
+
115
+ /**
116
+ * 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 provided output array.
117
+ *
118
+ * @param x - input array
119
+ * @param out - output array
120
+ * @param stride - output array stride
121
+ * @param offset - output array offset
122
+ * @param predicate - test function
123
+ * @param thisArg - execution context
124
+ * @returns output array
125
+ *
126
+ * @example
127
+ * var BooleanArray = require( '@stdlib/array-bool' );
128
+ *
129
+ * function isPositive( v ) {
130
+ * return ( v > 0 );
131
+ * }
132
+ * var x = [ 0, 0, 0, 1, 0 ];
133
+ * var y = new BooleanArray( [ false, false, false, false, false, false, false, false, false, false ] );
134
+ *
135
+ * var arr = cueveryByRight.assign( x, y, 2, 0, isPositive );
136
+ * // returns <BooleanArray>
137
+ *
138
+ * var v = arr.get( 4 );
139
+ * // returns false
140
+ */
141
+ 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;
142
+
143
+ /**
144
+ * 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 provided output array.
145
+ *
146
+ * @param x - input array
147
+ * @param y - output array
148
+ * @param stride - output array stride
149
+ * @param offset - output array offset
150
+ * @param predicate - test function
151
+ * @param thisArg - execution context
152
+ * @returns output array
153
+ *
154
+ * @example
155
+ * function isPositive( v ) {
156
+ * return v > 0;
157
+ * }
158
+ * var x = [ 0, 0, 1, 1, 1 ];
159
+ * var y = [ false, null, false, null, false, null, false, null, false, null ];
160
+ *
161
+ * var arr = cueveryByRight.assign( x, y, 2, 0, isPositive );
162
+ * // returns [ true, null, true, null, true, null, false, null, false, null ];
163
+ */
164
+ 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>;
165
+ }
166
+
167
+ /**
168
+ * Cumulatively tests whether every array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left.
169
+ *
170
+ * @param x - input array
171
+ * @param predicate - test function
172
+ * @param thisArg - execution context
173
+ * @returns output array
174
+ *
175
+ * @example
176
+ * function isPositive( v ) {
177
+ * return v > 0;
178
+ * }
179
+ * var x = [ 0, 0, 1, 1, 1 ];
180
+ *
181
+ * var result = cueveryByRight( x, isPositive );
182
+ * // returns [ true, true, true, false, false ]
183
+ *
184
+ * @example
185
+ * function isPositive( v ) {
186
+ * return v > 0;
187
+ * }
188
+ * var x = [ 1, 0, 0, 1, 1 ];
189
+ * var y = [ false, null, false, null, false, null, false, null, false, null ];
190
+ *
191
+ * var arr = cueveryByRight.assign( x, y, 2, 0, isPositive );
192
+ * // returns [ true, null, true, null, false, null, false, null, false, null ]
193
+ */
194
+ declare var cueveryByRight: CueveryByRight;
195
+
196
+
197
+ // EXPORTS //
198
+
199
+ export = cueveryByRight;
package/lib/assign.js ADDED
@@ -0,0 +1,171 @@
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 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 elements in the provided output array.
30
+ *
31
+ * @private
32
+ * @param {Collection} x - input array
33
+ * @param {Collection} out - 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 fcn( value ) {
42
+ * return ( value > 0 );
43
+ * }
44
+ *
45
+ * var x = [ 0, 0, 1, 1, 1 ];
46
+ *
47
+ * var out = [ 0, 0, 0, 0, 0 ];
48
+ * var arr = indexed( x, out, 1, 0, fcn );
49
+ * // returns [ true, true, true, false, false ]
50
+ */
51
+ function indexed( x, out, stride, offset, predicate, thisArg ) {
52
+ var flg;
53
+ var io;
54
+ var i;
55
+
56
+ flg = true;
57
+ io = offset;
58
+ for ( i = x.length - 1; i >= 0; i-- ) {
59
+ if ( flg && !predicate.call( thisArg, x[ i ], i, x ) ) {
60
+ flg = false;
61
+ }
62
+ out[ io ] = flg;
63
+ io += stride;
64
+ }
65
+ return out;
66
+ }
67
+
68
+ /**
69
+ * Cumulatively tests whether every array element in a provided accessor array passes a test implemented by a predicate function, while iterating from right-to-left, and assigns the results to elements in the accessor output array.
70
+ *
71
+ * @private
72
+ * @param {Object} x - input array object
73
+ * @param {Object} out - 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
+ * function fcn( value ) {
82
+ * return ( value > 0 );
83
+ * }
84
+ *
85
+ * var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' );
86
+ * var arraylike2object = require( '@stdlib/array-base-arraylike2object' );
87
+ *
88
+ * var x = toAccessorArray( [ 0, 0, 1, 1, 1 ] );
89
+ *
90
+ * var out = toAccessorArray( [ 0, 0, 0, 0, 0 ] );
91
+ * var arr = accessors( arraylike2object( x ), arraylike2object( out ), 1, 0, fcn );
92
+ *
93
+ * var v = arr.get( 4 );
94
+ * // returns false
95
+ */
96
+ function accessors( x, out, stride, offset, predicate, thisArg ) {
97
+ var xdata;
98
+ var odata;
99
+ var xget;
100
+ var oset;
101
+ var flg;
102
+ var io;
103
+ var i;
104
+
105
+ xdata = x.data;
106
+ odata = out.data;
107
+
108
+ xget = x.accessors[ 0 ];
109
+ oset = out.accessors[ 1 ];
110
+
111
+ io = offset;
112
+ flg = true;
113
+ for ( i = xdata.length - 1; i >= 0; i-- ) {
114
+ if ( flg && !predicate.call( thisArg, xget( xdata, i ), i, xdata ) ) {
115
+ flg = false;
116
+ }
117
+ oset( odata, io, flg );
118
+ io += stride;
119
+ }
120
+ return odata;
121
+ }
122
+
123
+
124
+ // MAIN //
125
+
126
+ /**
127
+ * Cumulatively tests whether every element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left, and assigns the results to elements in the output array.
128
+ *
129
+ * @param {Collection} x - input array
130
+ * @param {Collection} out - output array
131
+ * @param {integer} stride - output array stride
132
+ * @param {NonNegativeInteger} offset - output array offset
133
+ * @param {Function} predicate - test function
134
+ * @param {*} [thisArg] - execution context
135
+ * @returns {Collection} output array
136
+ *
137
+ * @example
138
+ * function fcn( value ) {
139
+ * return ( value > 0 );
140
+ * }
141
+ *
142
+ * var x = [ 0, 0, 1, 1 ];
143
+ *
144
+ * var y = [ false, null, false, null, false, null, false, null ];
145
+ * var out = assign( x, y, 2, 0, fcn );
146
+ * // returns [ true, null, true, null, false, null, false, null ]
147
+ *
148
+ * var bool = ( y === out );
149
+ * // returns true
150
+ */
151
+ function assign( x, out, stride, offset, predicate, thisArg ) {
152
+ var xo;
153
+ var oo;
154
+
155
+ xo = arraylike2object( x );
156
+ oo = arraylike2object( out );
157
+ if (
158
+ xo.accessorProtocol ||
159
+ oo.accessorProtocol
160
+ ) {
161
+ accessors( xo, oo, stride, offset, predicate, thisArg );
162
+ return out;
163
+ }
164
+ indexed( x, out, stride, offset, predicate, thisArg );
165
+ return out;
166
+ }
167
+
168
+
169
+ // EXPORTS //
170
+
171
+ module.exports = assign;
package/lib/index.js ADDED
@@ -0,0 +1,72 @@
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 every element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left.
23
+ *
24
+ * @module @stdlib/array-base-cuevery-by-right
25
+ *
26
+ * @example
27
+ * var cueveryByRight = require( '@stdlib/array-base-cuevery-by-right' );
28
+ *
29
+ * function fcn( value ) {
30
+ * return ( value > 0 );
31
+ * }
32
+ *
33
+ * var x = [ 0, 0, 1, 1, 1 ];
34
+ *
35
+ * var y = cueveryByRight( x, fcn );
36
+ * //returns [ true, true, true, false, false ]
37
+ *
38
+ * @example
39
+ * var cueveryByRight = require( '@stdlib/array-base-cuevery-by-right' );
40
+ *
41
+ * function fcn( value ) {
42
+ * return ( value > 0 );
43
+ * }
44
+ *
45
+ * var x = [ 0, 0, 1, 1, 1 ];
46
+ *
47
+ * var y1 = cueveryByRight( x, fcn );
48
+ * // returns [ true, true, true, false, false ]
49
+ *
50
+ * var y2 = [ false, null, false, null, false, null, false, null, false, null ];
51
+ * var out = cueveryByRight.assign( x, y2, 2, 0, fcn );
52
+ * // returns [ true, null, true, null, true, null, false, null, false, null ]
53
+ *
54
+ * var bool = ( out === y2 );
55
+ * // returns true
56
+ */
57
+
58
+ // MODULES //
59
+
60
+ var setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );
61
+ var main = require( './main.js' );
62
+ var assign = require( './assign.js' );
63
+
64
+
65
+ // MAIN //
66
+
67
+ setReadOnly( main, 'assign', assign );
68
+
69
+
70
+ // EXPORTS //
71
+
72
+ 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 every array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left.
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 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
+ function cueveryByRight( x, predicate, thisArg ) {
48
+ var out = filled( true, x.length );
49
+ return assign( x, out, 1, 0, predicate, thisArg );
50
+ }
51
+
52
+
53
+ // EXPORTS //
54
+
55
+ module.exports = cueveryByRight;
package/package.json ADDED
@@ -0,0 +1,74 @@
1
+ {
2
+ "name": "@stdlib/array-base-cuevery-by-right",
3
+ "version": "0.1.0",
4
+ "description": "Cumulatively test whether every array element in a provided array passes a test implemented by a predicate function, while iterating from right-to-left.",
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-cuevery-by-right.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
+ "utils",
57
+ "generic",
58
+ "array",
59
+ "cumulative",
60
+ "data",
61
+ "structure",
62
+ "test",
63
+ "predicate",
64
+ "all",
65
+ "every",
66
+ "array.every",
67
+ "array-like",
68
+ "validate"
69
+ ],
70
+ "funding": {
71
+ "type": "opencollective",
72
+ "url": "https://opencollective.com/stdlib"
73
+ }
74
+ }