@ohos-ports/stdlib-assert-tools-array-function 0.0.0-stage → 0.2.3-beta.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 CHANGED
@@ -1,3 +1,216 @@
1
- # Temporary Holding Version
1
+ <!--
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ @license Apache-2.0
4
+
5
+ Copyright (c) 2018 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
+ # Array Function
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
+ > Return a function which tests if every element in an array passes a test condition.
37
+
38
+ <section class="installation">
39
+
40
+ ## Installation
41
+
42
+ ```bash
43
+ npm install @stdlib/assert-tools-array-function
44
+ ```
45
+
46
+ </section>
47
+
48
+ <section class="usage">
49
+
50
+ ## Usage
51
+
52
+ ```javascript
53
+ var arrayfcn = require( '@stdlib/assert-tools-array-function' );
54
+ ```
55
+
56
+ <a name="arrayfcn"></a>
57
+
58
+ #### arrayfcn( predicate )
59
+
60
+ Returns a function which tests if every element in an [`array`][mdn-array] passes a test condition. Given an input [`array`][mdn-array], the function returns `true` if all elements pass the test and `false` otherwise.
61
+
62
+ ```javascript
63
+ var isOdd = require( '@stdlib/assert-is-odd' );
64
+
65
+ var arr1 = [ 1, 3, 5, 7 ];
66
+ var arr2 = [ 3, 5, 8 ];
67
+
68
+ var f = arrayfcn( isOdd );
69
+
70
+ var bool = f( arr1 );
71
+ // returns true
72
+
73
+ bool = f( arr2 );
74
+ // returns false
75
+ ```
76
+
77
+ </section>
78
+
79
+ <!-- /.usage -->
80
+
81
+ <section class="notes">
82
+
83
+ ## Notes
84
+
85
+ - The returned function will return `false` if **not** provided an [`array`][mdn-array].
86
+ - The returned function will return `false` if provided an empty [`array`][mdn-array].
87
+ - A `predicate` function should accept a single argument: an [`array`][mdn-array] element. If the [`array`][mdn-array] element satisfies a test condition, the `predicate` function should return `true`; otherwise, the `predicate` function should return `false`.
88
+
89
+ </section>
90
+
91
+ <!-- /.notes -->
92
+
93
+ <section class="examples">
94
+
95
+ ## Examples
96
+
97
+ <!-- eslint no-undef: "error" -->
98
+
99
+ ```javascript
100
+ var isEven = require( '@stdlib/assert-is-even' );
101
+ var arrayfcn = require( '@stdlib/assert-tools-array-function' );
102
+
103
+ var arr1;
104
+ var arr2;
105
+ var bool;
106
+ var f;
107
+ var i;
108
+
109
+ arr1 = new Array( 25 );
110
+ for ( i = 0; i < arr1.length; i++ ) {
111
+ arr1[ i ] = i;
112
+ }
113
+
114
+ arr2 = new Array( 25 );
115
+ for ( i = 0; i < arr2.length; i++ ) {
116
+ arr2[ i ] = 2 * i;
117
+ }
118
+
119
+ f = arrayfcn( isEven );
120
+
121
+ bool = f( arr1 );
122
+ // returns false
123
+
124
+ bool = f( arr2 );
125
+ // returns true
126
+ ```
127
+
128
+ </section>
129
+
130
+ <!-- /.examples -->
131
+
132
+ <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
133
+
134
+ <section class="related">
135
+
136
+ </section>
137
+
138
+ <!-- /.related -->
139
+
140
+ <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
141
+
142
+
143
+ <section class="main-repo" >
144
+
145
+ * * *
146
+
147
+ ## Notice
148
+
149
+ 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.
150
+
151
+ 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].
152
+
153
+ #### Community
154
+
155
+ [![Chat][chat-image]][chat-url]
156
+
157
+ ---
158
+
159
+ ## License
160
+
161
+ See [LICENSE][stdlib-license].
162
+
163
+
164
+ ## Copyright
165
+
166
+ Copyright &copy; 2016-2026. The Stdlib [Authors][stdlib-authors].
167
+
168
+ </section>
169
+
170
+ <!-- /.stdlib -->
171
+
172
+ <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
173
+
174
+ <section class="links">
175
+
176
+ [npm-image]: http://img.shields.io/npm/v/@stdlib/assert-tools-array-function.svg
177
+ [npm-url]: https://npmjs.org/package/@stdlib/assert-tools-array-function
178
+
179
+ [test-image]: https://github.com/stdlib-js/assert-tools-array-function/actions/workflows/test.yml/badge.svg?branch=v0.2.3
180
+ [test-url]: https://github.com/stdlib-js/assert-tools-array-function/actions/workflows/test.yml?query=branch:v0.2.3
181
+
182
+ [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/assert-tools-array-function/main.svg
183
+ [coverage-url]: https://codecov.io/github/stdlib-js/assert-tools-array-function?branch=main
184
+
185
+ <!--
186
+
187
+ [dependencies-image]: https://img.shields.io/david/stdlib-js/assert-tools-array-function.svg
188
+ [dependencies-url]: https://david-dm.org/stdlib-js/assert-tools-array-function/main
189
+
190
+ -->
191
+
192
+ [chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
193
+ [chat-url]: https://stdlib.zulipchat.com
194
+
195
+ [stdlib]: https://github.com/stdlib-js/stdlib
196
+
197
+ [stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
198
+
199
+ [umd]: https://github.com/umdjs/umd
200
+ [es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
201
+
202
+ [deno-url]: https://github.com/stdlib-js/assert-tools-array-function/tree/deno
203
+ [deno-readme]: https://github.com/stdlib-js/assert-tools-array-function/blob/deno/README.md
204
+ [umd-url]: https://github.com/stdlib-js/assert-tools-array-function/tree/umd
205
+ [umd-readme]: https://github.com/stdlib-js/assert-tools-array-function/blob/umd/README.md
206
+ [esm-url]: https://github.com/stdlib-js/assert-tools-array-function/tree/esm
207
+ [esm-readme]: https://github.com/stdlib-js/assert-tools-array-function/blob/esm/README.md
208
+ [branches-url]: https://github.com/stdlib-js/assert-tools-array-function/blob/main/branches.md
209
+
210
+ [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/assert-tools-array-function/main/LICENSE
211
+
212
+ [mdn-array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
213
+
214
+ </section>
215
+
216
+ <!-- /.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 arrayfcn from '../docs/types/index';
3
+ export = arrayfcn;
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";var a=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var u=a(function(y,f){
2
+ var s=require('@stdlib/assert-is-array/dist'),o=require('@stdlib/error-tools-fmtprodmsg/dist');function l(e){if(typeof e!="function")throw new TypeError(o('0BB3J',e));return r;function r(t){var i,n;if(!s(t)||(i=t.length,i===0))return!1;for(n=0;n<i;n++)if(e(t[n])===!1)return!1;return!0}}f.exports=l
3
+ });var v=u();module.exports=v;
4
+ /** @license Apache-2.0 */
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../lib/main.js", "../lib/index.js"],
4
+ "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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 isArray = require( '@stdlib/assert-is-array' );\nvar format = require( '@stdlib/string-format' );\n\n\n// MAIN //\n\n/**\n* Returns a function which tests if every element in an array passes a test condition.\n*\n* @param {Function} predicate - function to apply\n* @throws {TypeError} must provide a function\n* @returns {Function} an array function\n*\n* @example\n* var isOdd = require( '@stdlib/assert-is-odd' );\n*\n* var arr1 = [ 1, 3, 5, 7 ];\n* var arr2 = [ 3, 5, 8 ];\n*\n* var validate = arrayfcn( isOdd );\n*\n* var bool = validate( arr1 );\n* // returns true\n*\n* bool = validate( arr2 );\n* // returns false\n*/\nfunction arrayfcn( predicate ) {\n\tif ( typeof predicate !== 'function' ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a function. Value: `%s`.', predicate ) );\n\t}\n\treturn every;\n\n\t/**\n\t* Tests if every element in an array passes a test condition.\n\t*\n\t* @private\n\t* @param {*} value - value to test\n\t* @returns {boolean} boolean indicating whether a value is an array for which all elements pass a test condition\n\t*/\n\tfunction every( value ) {\n\t\tvar len;\n\t\tvar i;\n\t\tif ( !isArray( value ) ) {\n\t\t\treturn false;\n\t\t}\n\t\tlen = value.length;\n\t\tif ( len === 0 ) {\n\t\t\treturn false;\n\t\t}\n\t\tfor ( i = 0; i < len; i++ ) {\n\t\t\tif ( predicate( value[ i ] ) === false ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = arrayfcn;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 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* Return a function which tests if every element in an array passes a test condition.\n*\n* @module @stdlib/assert-tools-array-function\n*\n* @example\n* var isOdd = require( '@stdlib/assert-is-odd' );\n* var arrayfcn = require( '@stdlib/assert-tools-array-function' );\n*\n* var arr1 = [ 1, 3, 5, 7 ];\n* var arr2 = [ 3, 5, 8 ];\n*\n* var validate = arrayfcn( isOdd );\n*\n* var bool = validate( arr1 );\n* // returns true\n*\n* bool = validate( arr2 );\n* // returns false\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
5
+ "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAU,QAAS,yBAA0B,EAC7CC,EAAS,QAAS,uBAAwB,EA0B9C,SAASC,EAAUC,EAAY,CAC9B,GAAK,OAAOA,GAAc,WACzB,MAAM,IAAI,UAAWF,EAAQ,0DAA2DE,CAAU,CAAE,EAErG,OAAOC,EASP,SAASA,EAAOC,EAAQ,CACvB,IAAIC,EACAC,EAKJ,GAJK,CAACP,EAASK,CAAM,IAGrBC,EAAMD,EAAM,OACPC,IAAQ,GACZ,MAAO,GAER,IAAMC,EAAI,EAAGA,EAAID,EAAKC,IACrB,GAAKJ,EAAWE,EAAOE,CAAE,CAAE,IAAM,GAChC,MAAO,GAGT,MAAO,EACR,CACD,CAKAR,EAAO,QAAUG,ICzCjB,IAAIM,EAAO,IAKX,OAAO,QAAUA",
6
+ "names": ["require_main", "__commonJSMin", "exports", "module", "isArray", "format", "arrayfcn", "predicate", "every", "value", "len", "i", "main"]
7
+ }
@@ -0,0 +1,61 @@
1
+ /*
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2019 The Stdlib Authors.
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ // TypeScript Version: 4.1
20
+
21
+ /**
22
+ * Predicate function.
23
+ *
24
+ * @param elem - array element
25
+ * @returns test result
26
+ */
27
+ type PredicateFunction = ( elem: any ) => boolean;
28
+
29
+ /**
30
+ * Returns a function which tests if every element in an array passes a test condition.
31
+ *
32
+ * ## Notes
33
+ *
34
+ * - The predicate function should accept a single argument: an array element. If the array element satisfies a test condition, the function should return `true`; otherwise, the function should return `false`.
35
+ * - Given an input array, the returned function returns `true` if all elements pass the test and `false` otherwise.
36
+ * - The returned function returns `false` if provided an empty array.
37
+ * - The returned function returns `false` if not provided an array.
38
+ *
39
+ * @param predicate - function to apply
40
+ * @returns an array function
41
+ *
42
+ * @example
43
+ * var isOdd = require( '@stdlib/assert-is-odd' );
44
+ *
45
+ * var arr1 = [ 1, 3, 5, 7 ];
46
+ * var arr2 = [ 3, 5, 8 ];
47
+ *
48
+ * var validate = arrayfcn( isOdd );
49
+ *
50
+ * var bool = validate( arr1 );
51
+ * // returns true
52
+ *
53
+ * bool = validate( arr2 );
54
+ * // returns false
55
+ */
56
+ declare function arrayfcn( predicate: PredicateFunction ): Function;
57
+
58
+
59
+ // EXPORTS //
60
+
61
+ export = arrayfcn;
package/lib/index.js ADDED
@@ -0,0 +1,49 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2018 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
+ * Return a function which tests if every element in an array passes a test condition.
23
+ *
24
+ * @module @stdlib/assert-tools-array-function
25
+ *
26
+ * @example
27
+ * var isOdd = require( '@stdlib/assert-is-odd' );
28
+ * var arrayfcn = require( '@stdlib/assert-tools-array-function' );
29
+ *
30
+ * var arr1 = [ 1, 3, 5, 7 ];
31
+ * var arr2 = [ 3, 5, 8 ];
32
+ *
33
+ * var validate = arrayfcn( isOdd );
34
+ *
35
+ * var bool = validate( arr1 );
36
+ * // returns true
37
+ *
38
+ * bool = validate( arr2 );
39
+ * // returns false
40
+ */
41
+
42
+ // MODULES //
43
+
44
+ var main = require( './main.js' );
45
+
46
+
47
+ // EXPORTS //
48
+
49
+ module.exports = main;
package/lib/main.js ADDED
@@ -0,0 +1,85 @@
1
+ /**
2
+ * @license Apache-2.0
3
+ *
4
+ * Copyright (c) 2018 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 isArray = require( '@ohos-ports/stdlib-assert-is-array' );
24
+ var format = require( '@ohos-ports/stdlib-string-format' );
25
+
26
+
27
+ // MAIN //
28
+
29
+ /**
30
+ * Returns a function which tests if every element in an array passes a test condition.
31
+ *
32
+ * @param {Function} predicate - function to apply
33
+ * @throws {TypeError} must provide a function
34
+ * @returns {Function} an array function
35
+ *
36
+ * @example
37
+ * var isOdd = require( '@stdlib/assert-is-odd' );
38
+ *
39
+ * var arr1 = [ 1, 3, 5, 7 ];
40
+ * var arr2 = [ 3, 5, 8 ];
41
+ *
42
+ * var validate = arrayfcn( isOdd );
43
+ *
44
+ * var bool = validate( arr1 );
45
+ * // returns true
46
+ *
47
+ * bool = validate( arr2 );
48
+ * // returns false
49
+ */
50
+ function arrayfcn( predicate ) {
51
+ if ( typeof predicate !== 'function' ) {
52
+ throw new TypeError( format( 'invalid argument. Must provide a function. Value: `%s`.', predicate ) );
53
+ }
54
+ return every;
55
+
56
+ /**
57
+ * Tests if every element in an array passes a test condition.
58
+ *
59
+ * @private
60
+ * @param {*} value - value to test
61
+ * @returns {boolean} boolean indicating whether a value is an array for which all elements pass a test condition
62
+ */
63
+ function every( value ) {
64
+ var len;
65
+ var i;
66
+ if ( !isArray( value ) ) {
67
+ return false;
68
+ }
69
+ len = value.length;
70
+ if ( len === 0 ) {
71
+ return false;
72
+ }
73
+ for ( i = 0; i < len; i++ ) {
74
+ if ( predicate( value[ i ] ) === false ) {
75
+ return false;
76
+ }
77
+ }
78
+ return true;
79
+ }
80
+ }
81
+
82
+
83
+ // EXPORTS //
84
+
85
+ module.exports = arrayfcn;
package/package.json CHANGED
@@ -1,6 +1,73 @@
1
1
  {
2
2
  "name": "@ohos-ports/stdlib-assert-tools-array-function",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.2.3-beta.0",
4
+ "description": "Return a function which tests if every element in an array passes a test condition.",
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/assert-tools-array-function.git"
28
+ },
29
+ "bugs": {
30
+ "url": "https://github.com/stdlib-js/stdlib/issues"
31
+ },
32
+ "dependencies": {
33
+ "@ohos-ports/stdlib-assert-is-array": "^0.2.3-beta.0-beta.0",
34
+ "@ohos-ports/stdlib-string-format": "^0.2.3-beta.2",
35
+ "@ohos-ports/stdlib-error-tools-fmtprodmsg": "^0.2.3-beta.0"
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
+ "openharmony",
50
+ "sunos",
51
+ "win32",
52
+ "windows"
53
+ ],
54
+ "keywords": [
55
+ "stdlib",
56
+ "stdassert",
57
+ "tools",
58
+ "tool",
59
+ "valid",
60
+ "validate",
61
+ "assert",
62
+ "is",
63
+ "apply",
64
+ "array",
65
+ "test",
66
+ "check",
67
+ "function"
68
+ ],
69
+ "funding": {
70
+ "type": "opencollective",
71
+ "url": "https://opencollective.com/stdlib"
72
+ }
6
73
  }