@ohos-ports/stdlib-object 0.0.0-stage → 0.4.1-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.
Files changed (207) hide show
  1. package/LICENSE +177 -0
  2. package/NOTICE +1 -0
  3. package/README.md +262 -2
  4. package/SECURITY.md +5 -0
  5. package/any-in-by/README.md +217 -0
  6. package/any-in-by/docs/repl.txt +41 -0
  7. package/any-in-by/docs/types/index.d.ts +102 -0
  8. package/any-in-by/docs/types/test.ts +53 -0
  9. package/any-in-by/lib/index.js +50 -0
  10. package/any-in-by/lib/main.js +75 -0
  11. package/any-in-by/package.json +66 -0
  12. package/any-own-by/README.md +221 -0
  13. package/any-own-by/docs/repl.txt +43 -0
  14. package/any-own-by/docs/types/index.d.ts +101 -0
  15. package/any-own-by/docs/types/test.ts +63 -0
  16. package/any-own-by/lib/index.js +46 -0
  17. package/any-own-by/lib/main.js +77 -0
  18. package/any-own-by/package.json +70 -0
  19. package/assign/README.md +139 -0
  20. package/assign/docs/repl.txt +34 -0
  21. package/assign/docs/types/index.d.ts +113 -0
  22. package/assign/docs/types/test.ts +47 -0
  23. package/assign/lib/builtin.js +55 -0
  24. package/assign/lib/has_object_assign.js +33 -0
  25. package/assign/lib/index.js +52 -0
  26. package/assign/lib/polyfill.js +86 -0
  27. package/assign/package.json +64 -0
  28. package/assign-in/README.md +145 -0
  29. package/assign-in/docs/repl.txt +34 -0
  30. package/assign-in/docs/types/index.d.ts +175 -0
  31. package/assign-in/docs/types/test.ts +44 -0
  32. package/assign-in/lib/index.js +54 -0
  33. package/assign-in/lib/main.js +92 -0
  34. package/assign-in/package.json +60 -0
  35. package/bifurcate-in/README.md +298 -0
  36. package/bifurcate-in/docs/repl.txt +68 -0
  37. package/bifurcate-in/docs/types/index.d.ts +189 -0
  38. package/bifurcate-in/docs/types/test.ts +97 -0
  39. package/bifurcate-in/lib/index.js +106 -0
  40. package/bifurcate-in/lib/main.js +148 -0
  41. package/bifurcate-in/lib/return_keys.js +81 -0
  42. package/bifurcate-in/lib/return_pairs.js +87 -0
  43. package/bifurcate-in/lib/return_values.js +87 -0
  44. package/bifurcate-in/lib/validate.js +76 -0
  45. package/bifurcate-in/package.json +72 -0
  46. package/bifurcate-own/README.md +255 -0
  47. package/bifurcate-own/docs/repl.txt +63 -0
  48. package/bifurcate-own/docs/types/index.d.ts +183 -0
  49. package/bifurcate-own/docs/types/test.ts +97 -0
  50. package/bifurcate-own/lib/index.js +87 -0
  51. package/bifurcate-own/lib/main.js +127 -0
  52. package/bifurcate-own/lib/return_keys.js +81 -0
  53. package/bifurcate-own/lib/return_pairs.js +87 -0
  54. package/bifurcate-own/lib/return_values.js +87 -0
  55. package/bifurcate-own/lib/validate.js +76 -0
  56. package/bifurcate-own/package.json +71 -0
  57. package/capitalize-keys/README.md +139 -0
  58. package/capitalize-keys/docs/repl.txt +28 -0
  59. package/capitalize-keys/docs/types/index.d.ts +46 -0
  60. package/capitalize-keys/docs/types/test.ts +33 -0
  61. package/capitalize-keys/lib/index.js +45 -0
  62. package/capitalize-keys/lib/main.js +69 -0
  63. package/capitalize-keys/package.json +76 -0
  64. package/common-keys/README.md +125 -0
  65. package/common-keys/docs/repl.txt +29 -0
  66. package/common-keys/docs/types/index.d.ts +70 -0
  67. package/common-keys/docs/types/test.ts +33 -0
  68. package/common-keys/lib/index.js +51 -0
  69. package/common-keys/lib/main.js +106 -0
  70. package/common-keys/package.json +70 -0
  71. package/common-keys-in/README.md +125 -0
  72. package/common-keys-in/docs/repl.txt +29 -0
  73. package/common-keys-in/docs/types/index.d.ts +70 -0
  74. package/common-keys-in/docs/types/test.ts +33 -0
  75. package/common-keys-in/lib/index.js +51 -0
  76. package/common-keys-in/lib/main.js +106 -0
  77. package/common-keys-in/package.json +72 -0
  78. package/ctor/README.md +536 -0
  79. package/ctor/docs/repl.txt +592 -0
  80. package/ctor/docs/types/index.d.ts +56 -0
  81. package/ctor/docs/types/test.ts +33 -0
  82. package/ctor/lib/index.js +54 -0
  83. package/ctor/lib/main.js +58 -0
  84. package/ctor/package.json +58 -0
  85. package/deep-get/README.md +181 -0
  86. package/deep-get/docs/repl.txt +63 -0
  87. package/deep-get/docs/types/index.d.ts +125 -0
  88. package/deep-get/docs/types/test.ts +109 -0
  89. package/deep-get/lib/defaults.js +38 -0
  90. package/deep-get/lib/dget.js +57 -0
  91. package/deep-get/lib/factory.js +94 -0
  92. package/deep-get/lib/index.js +58 -0
  93. package/deep-get/lib/main.js +101 -0
  94. package/deep-get/lib/validate.js +66 -0
  95. package/deep-get/package.json +68 -0
  96. package/deep-set/README.md +273 -0
  97. package/deep-set/docs/repl.txt +87 -0
  98. package/deep-set/docs/types/index.d.ts +180 -0
  99. package/deep-set/docs/types/test.ts +134 -0
  100. package/deep-set/lib/defaults.js +39 -0
  101. package/deep-set/lib/dset.js +80 -0
  102. package/deep-set/lib/factory.js +99 -0
  103. package/deep-set/lib/index.js +58 -0
  104. package/deep-set/lib/main.js +120 -0
  105. package/deep-set/lib/validate.js +74 -0
  106. package/deep-set/package.json +69 -0
  107. package/docs/types/index.d.ts +964 -0
  108. package/every-in-by/README.md +156 -0
  109. package/every-in-by/docs/repl.txt +43 -0
  110. package/every-in-by/docs/types/index.d.ts +83 -0
  111. package/every-in-by/docs/types/test.ts +60 -0
  112. package/every-in-by/lib/index.js +51 -0
  113. package/every-in-by/lib/main.js +70 -0
  114. package/every-in-by/package.json +67 -0
  115. package/every-own-by/README.md +223 -0
  116. package/every-own-by/docs/repl.txt +43 -0
  117. package/every-own-by/docs/types/index.d.ts +102 -0
  118. package/every-own-by/docs/types/test.ts +62 -0
  119. package/every-own-by/lib/index.js +46 -0
  120. package/every-own-by/lib/main.js +77 -0
  121. package/every-own-by/package.json +68 -0
  122. package/for-in/README.md +218 -0
  123. package/for-in/docs/repl.txt +44 -0
  124. package/for-in/docs/types/index.d.ts +65 -0
  125. package/for-in/docs/types/test.ts +50 -0
  126. package/for-in/lib/index.js +54 -0
  127. package/for-in/lib/main.js +82 -0
  128. package/for-in/package.json +74 -0
  129. package/for-own/README.md +209 -0
  130. package/for-own/docs/repl.txt +49 -0
  131. package/for-own/docs/types/index.d.ts +63 -0
  132. package/for-own/docs/types/test.ts +50 -0
  133. package/for-own/lib/index.js +50 -0
  134. package/for-own/lib/main.js +85 -0
  135. package/for-own/package.json +71 -0
  136. package/inverse/README.md +163 -0
  137. package/inverse/docs/repl.txt +53 -0
  138. package/inverse/docs/types/index.d.ts +66 -0
  139. package/inverse/docs/types/test.ts +60 -0
  140. package/inverse/lib/index.js +59 -0
  141. package/inverse/lib/main.js +123 -0
  142. package/inverse/package.json +69 -0
  143. package/inverse-by/README.md +205 -0
  144. package/inverse-by/docs/repl.txt +67 -0
  145. package/inverse-by/docs/types/index.d.ts +160 -0
  146. package/inverse-by/docs/types/test.ts +81 -0
  147. package/inverse-by/lib/index.js +78 -0
  148. package/inverse-by/lib/main.js +148 -0
  149. package/inverse-by/package.json +75 -0
  150. package/lib/index.js +276 -0
  151. package/lowercase-keys/README.md +139 -0
  152. package/lowercase-keys/docs/repl.txt +28 -0
  153. package/lowercase-keys/docs/types/index.d.ts +46 -0
  154. package/lowercase-keys/docs/types/test.ts +33 -0
  155. package/lowercase-keys/lib/index.js +45 -0
  156. package/lowercase-keys/lib/main.js +63 -0
  157. package/lowercase-keys/package.json +74 -0
  158. package/move-property/README.md +144 -0
  159. package/move-property/docs/repl.txt +38 -0
  160. package/move-property/docs/types/index.d.ts +53 -0
  161. package/move-property/docs/types/test.ts +46 -0
  162. package/move-property/lib/index.js +46 -0
  163. package/move-property/lib/main.js +74 -0
  164. package/move-property/package.json +69 -0
  165. package/none-in-by/README.md +241 -0
  166. package/none-in-by/docs/repl.txt +42 -0
  167. package/none-in-by/docs/types/index.d.ts +101 -0
  168. package/none-in-by/docs/types/test.ts +61 -0
  169. package/none-in-by/lib/index.js +46 -0
  170. package/none-in-by/lib/main.js +71 -0
  171. package/none-in-by/package.json +68 -0
  172. package/none-own-by/README.md +177 -0
  173. package/none-own-by/docs/repl.txt +42 -0
  174. package/none-own-by/docs/types/index.d.ts +102 -0
  175. package/none-own-by/docs/types/test.ts +61 -0
  176. package/none-own-by/lib/index.js +50 -0
  177. package/none-own-by/lib/main.js +75 -0
  178. package/none-own-by/package.json +68 -0
  179. package/package.json +66 -4
  180. package/some-in-by/README.md +232 -0
  181. package/some-in-by/docs/repl.txt +45 -0
  182. package/some-in-by/docs/types/index.d.ts +104 -0
  183. package/some-in-by/docs/types/test.ts +66 -0
  184. package/some-in-by/lib/index.js +46 -0
  185. package/some-in-by/lib/main.js +87 -0
  186. package/some-in-by/package.json +75 -0
  187. package/some-own-by/README.md +251 -0
  188. package/some-own-by/docs/repl.txt +45 -0
  189. package/some-own-by/docs/types/index.d.ts +103 -0
  190. package/some-own-by/docs/types/test.ts +66 -0
  191. package/some-own-by/lib/index.js +46 -0
  192. package/some-own-by/lib/main.js +85 -0
  193. package/some-own-by/package.json +72 -0
  194. package/uncapitalize-keys/README.md +139 -0
  195. package/uncapitalize-keys/docs/repl.txt +28 -0
  196. package/uncapitalize-keys/docs/types/index.d.ts +46 -0
  197. package/uncapitalize-keys/docs/types/test.ts +33 -0
  198. package/uncapitalize-keys/lib/index.js +45 -0
  199. package/uncapitalize-keys/lib/main.js +69 -0
  200. package/uncapitalize-keys/package.json +76 -0
  201. package/uppercase-keys/README.md +139 -0
  202. package/uppercase-keys/docs/repl.txt +28 -0
  203. package/uppercase-keys/docs/types/index.d.ts +46 -0
  204. package/uppercase-keys/docs/types/test.ts +33 -0
  205. package/uppercase-keys/lib/index.js +45 -0
  206. package/uppercase-keys/lib/main.js +63 -0
  207. package/uppercase-keys/package.json +74 -0
@@ -0,0 +1,241 @@
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
+ # noneInBy
22
+
23
+ > Test whether every property of an object fails a test implemented by a predicate function.
24
+
25
+ <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
26
+
27
+ <section class="intro">
28
+
29
+ </section>
30
+
31
+ <!-- /.intro -->
32
+
33
+ <!-- Package usage documentation. -->
34
+
35
+ <section class="usage">
36
+
37
+ ## Usage
38
+
39
+ ```javascript
40
+ var noneInBy = require( '@stdlib/object/none-in-by' );
41
+ ```
42
+
43
+ #### noneInBy( object, predicate\[, thisArg ] )
44
+
45
+ Tests whether every property of an `object` fails a test implemented by a `predicate` function.
46
+
47
+ ```javascript
48
+ function isUnderage( age ) {
49
+ return ( age < 18 );
50
+ }
51
+
52
+ var obj = {
53
+ 'a': 28,
54
+ 'b': 22,
55
+ 'c': 25
56
+ };
57
+
58
+ var bool = noneInBy( obj, isUnderage );
59
+ // returns true
60
+ ```
61
+
62
+ If a `predicate` function returns a truthy value, the function **immediately** returns `false`.
63
+
64
+ ```javascript
65
+ function isUnderage( age ) {
66
+ return ( age < 18 );
67
+ }
68
+
69
+ var obj = {
70
+ 'a': 12,
71
+ 'b': 22,
72
+ 'c': 25
73
+ };
74
+
75
+ var bool = noneInBy( obj, isUnderage );
76
+ // returns false
77
+ ```
78
+
79
+ The invoked `function` is provided three agruments:
80
+
81
+ - **value**: property value.
82
+ - **key**: property key.
83
+ - **object**: input object.
84
+
85
+ To set the function execution context, provide a `thisArg`.
86
+
87
+ ```javascript
88
+ function sum( value ) {
89
+ if ( value < 0 ) {
90
+ return true;
91
+ }
92
+ this.sum += value;
93
+ this.count += 1;
94
+ return false;
95
+ }
96
+
97
+ var obj = {
98
+ 'a': 1,
99
+ 'b': 2,
100
+ 'c': 3,
101
+ 'd': 4
102
+ };
103
+
104
+ var context = {
105
+ 'sum': 0,
106
+ 'count': 0
107
+ };
108
+
109
+ var bool = noneInBy( obj, sum, context );
110
+ // returns true
111
+
112
+ var mean = context.sum / context.count;
113
+ // returns 2.5
114
+ ```
115
+
116
+ </section>
117
+
118
+ <!-- /.usage -->
119
+
120
+ <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
121
+
122
+ <section class="notes">
123
+
124
+ ## Notes
125
+
126
+ - If the 1st argument is not an object or the second argument is not a function, the
127
+ function throws a Type Error.
128
+
129
+ - If provided an empty object, the function returns `true`.
130
+
131
+ ```javascript
132
+ function truthy() {
133
+ return true;
134
+ }
135
+ var bool = noneInBy( {}, truthy );
136
+ // returns true
137
+ ```
138
+
139
+ - The function does **not** skip `undefined` elements.
140
+
141
+ <!-- eslint-disable no-sparse-arrays, stdlib/doctest-marker -->
142
+
143
+ ```javascript
144
+ function log( value, index ) {
145
+ console.log( '%s: %s', index, value );
146
+ return false;
147
+ }
148
+
149
+ var obj = {
150
+ 'a': 1,
151
+ 'b': NaN,
152
+ 'c': NaN,
153
+ 'd': 4
154
+ };
155
+
156
+ var bool = noneInBy( arr, log );
157
+ /* =>
158
+ 0: 1
159
+ 1: undefined
160
+ 2: undefined
161
+ 3: 4
162
+ */
163
+ ```
164
+
165
+ </section>
166
+
167
+ <!-- /.notes -->
168
+
169
+ <!-- Package usage examples. -->
170
+
171
+ <section class="examples">
172
+
173
+ ## Examples
174
+
175
+ <!-- eslint no-undef: "error" -->
176
+
177
+ ```javascript
178
+ var noneInBy = require( '@stdlib/object/none-in-by' );
179
+
180
+ function isUnderage( age ) {
181
+ return age < 18;
182
+ }
183
+
184
+ var obj = {
185
+ 'a': 26,
186
+ 'b': 20,
187
+ 'c': 25
188
+ };
189
+
190
+ var bool = noneInBy( obj, isUnderage );
191
+ // returns true
192
+ ```
193
+
194
+ </section>
195
+
196
+ <!-- /.examples -->
197
+
198
+ <!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
199
+
200
+ <section class="references">
201
+
202
+ </section>
203
+
204
+ <!-- /.references -->
205
+
206
+ <!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
207
+
208
+ <section class="related">
209
+
210
+ * * *
211
+
212
+ ## See Also
213
+
214
+ - <span class="package-name">[`@stdlib/object/any-in-by`][@stdlib/object/any-in-by]</span><span class="delimiter">: </span><span class="description">test whether at least one property in an object passes a test implemented by a predicate function.</span>
215
+ - <span class="package-name">[`@stdlib/object/every-in-by`][@stdlib/object/every-in-by]</span><span class="delimiter">: </span><span class="description">test whether all properties (own and inherited) of an object pass a test implemented by a predicate function.</span>
216
+ - <span class="package-name">[`@stdlib/utils/none-by`][@stdlib/utils/none-by]</span><span class="delimiter">: </span><span class="description">test whether all elements in a collection fail a test implemented by a predicate function.</span>
217
+ - <span class="package-name">[`@stdlib/object/some-in-by`][@stdlib/object/some-in-by]</span><span class="delimiter">: </span><span class="description">test whether an object contains at least n properties (own and inherited) which pass a test implemented by a predicate function.</span>
218
+
219
+ </section>
220
+
221
+ <!-- /.related -->
222
+
223
+ <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
224
+
225
+ <section class="links">
226
+
227
+ <!-- <related-links> -->
228
+
229
+ [@stdlib/object/any-in-by]: https://github.com/stdlib-js/object/tree/main/any-in-by
230
+
231
+ [@stdlib/object/every-in-by]: https://github.com/stdlib-js/object/tree/main/every-in-by
232
+
233
+ [@stdlib/utils/none-by]: https://www.npmjs.com/package/@stdlib/utils-none-by
234
+
235
+ [@stdlib/object/some-in-by]: https://github.com/stdlib-js/object/tree/main/some-in-by
236
+
237
+ <!-- </related-links> -->
238
+
239
+ </section>
240
+
241
+ <!-- /.links -->
@@ -0,0 +1,42 @@
1
+
2
+ {{alias}}( object, predicate[, thisArg ] )
3
+ Tests whether every property in an object fails a test implemented by a
4
+ predicate function.
5
+
6
+ The predicate function is provided three arguments:
7
+
8
+ - value: object value.
9
+ - key: object key.
10
+ - object: the input object.
11
+
12
+ The function immediately returns upon encountering a truthy return value.
13
+
14
+ If provided an empty object, the function returns `true`.
15
+
16
+ Parameters
17
+ ----------
18
+ object: Object
19
+ Input object over which to iterate.
20
+
21
+ predicate: Function
22
+ The test function.
23
+
24
+ thisArg: any (optional)
25
+ Execution context.
26
+
27
+ Returns
28
+ -------
29
+ bool: boolean
30
+ The function returns `true` if the predicate function returns a falsy
31
+ value for all properties; otherwise, the function returns `false`.
32
+
33
+ Examples
34
+ --------
35
+ > function negative( v ) { return ( v < 0 ); };
36
+ > var obj = { 'a': 1, 'b': 2, 'c': 4 };
37
+ > var bool = {{alias}}( obj, negative )
38
+ true
39
+
40
+ See Also
41
+ --------
42
+
@@ -0,0 +1,101 @@
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
+ /**
24
+ * Checks whether a property in a object passes a test.
25
+ *
26
+ * @returns boolean indicating whether a property in a object passes a test
27
+ */
28
+ type Nullary<U> = ( this: U ) => boolean;
29
+
30
+ /**
31
+ * Checks whether a property in a object passes a test.
32
+ *
33
+ * @param value - property value
34
+ * @returns boolean indicating whether a property in an object passes a test
35
+ */
36
+ type Unary<T, U> = ( this: U, value: T ) => boolean;
37
+
38
+ /**
39
+ * Checks whether a property in a object passes a test.
40
+ *
41
+ * @param value - property value
42
+ * @param key - property key
43
+ * @returns boolean indicating whether a property in a object passes a test
44
+ */
45
+ type Binary<T, U> = ( this: U, value: T, key: number ) => boolean;
46
+
47
+ /**
48
+ * Checks whether a property in a object passes a test.
49
+ *
50
+ * @param value - property value
51
+ * @param key - property key
52
+ * @param object - input object
53
+ * @returns boolean indicating whether a property in a object passes a test
54
+ */
55
+ type Ternary<T, U> = ( this: U, value: T, index: number, object: Object ) => boolean;
56
+
57
+ /**
58
+ * Checks whether a property in a object passes a test.
59
+ *
60
+ * @param value - property value
61
+ * @param index - property index
62
+ * @param object - input object
63
+ * @returns boolean indicating whether a property in a object passes a test
64
+ */
65
+ type Predicate<T, U> = Nullary<U> | Unary<T, U> | Binary<T, U> | Ternary<T, U>;
66
+
67
+ /**
68
+ * Tests whether every property in a object fail a test implemented by a predicate function.
69
+ *
70
+ * ## Notes
71
+ *
72
+ * - The predicate function is provided three arguments:
73
+ *
74
+ * - `value`: property value
75
+ * - `key`: property key
76
+ * - `object`: the input object
77
+ *
78
+ * - The function immediately returns upon encountering a truthy return value.
79
+ * - If provided an empty object, the function returns `true`.
80
+ *
81
+ * @param object - input object
82
+ * @param predicate - test function
83
+ * @param thisArg - execution context
84
+ * @returns boolean indicating whether all property fails a test
85
+ *
86
+ * @example
87
+ * function isPositive( v ) {
88
+ * return ( v > 0 );
89
+ * }
90
+ *
91
+ * var obj = { 'a': -1, 'b': -2, 'c': -3, 'd': -4 };
92
+ *
93
+ * var bool = noneInBy( obj, isPositive );
94
+ * // returns true
95
+ */
96
+ declare function noneInBy<T = unknown, U = unknown>( object: Record<string, unknown>, predicate: Predicate<T, U>, thisArg?: ThisParameterType<Predicate<T, U>> ): boolean;
97
+
98
+
99
+ // EXPORTS //
100
+
101
+ export = noneInBy;
@@ -0,0 +1,61 @@
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
+ import noneInBy = require( './index' );
20
+
21
+ const isPositive = ( v: number ): boolean => {
22
+ return ( v > 0 );
23
+ };
24
+
25
+ // TESTS //
26
+
27
+ const obj = {
28
+ 'a': 1,
29
+ 'b': 2,
30
+ 'c': 4
31
+ };
32
+
33
+ // The function returns a boolean...
34
+ {
35
+ noneInBy( obj, isPositive ); // $ExpectType boolean
36
+ }
37
+
38
+ // The compiler throws an error if the function is provided a first argument which is not an object...
39
+ {
40
+ noneInBy( '2', isPositive ); // $ExpectError
41
+ noneInBy( false, isPositive ); // $ExpectError
42
+ noneInBy( true, isPositive ); // $ExpectError
43
+ noneInBy( [ 1, 2 ], isPositive ); // $ExpectError
44
+ }
45
+
46
+ // The compiler throws an error if the function is provided a second argument which is not a function...
47
+ {
48
+ noneInBy( obj, 2 ); // $ExpectError
49
+ noneInBy( obj, false ); // $ExpectError
50
+ noneInBy( obj, true ); // $ExpectError
51
+ noneInBy( obj, 'abc' ); // $ExpectError
52
+ noneInBy( obj, {} ); // $ExpectError
53
+ noneInBy( obj, [] ); // $ExpectError
54
+ }
55
+
56
+ // The compiler throws an error if the function is provided an invalid number of arguments...
57
+ {
58
+ noneInBy(); // $ExpectError
59
+ noneInBy( [ 1, 2, 3] ); // $ExpectError
60
+ noneInBy( [ 1, 2, 3], isPositive, {}, 3 ); // $ExpectError
61
+ }
@@ -0,0 +1,46 @@
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
+ * Test whether every property of an object fails a test implemented by a predicate function.
23
+ *
24
+ * @module @stdlib/object/none-in-by
25
+ *
26
+ * @example
27
+ * var noneInBy = require( '@ohos-ports/stdlib-object/none-in-by' );
28
+ *
29
+ * function isPositive( v ) {
30
+ * return ( v > 0 );
31
+ * }
32
+ *
33
+ * var obj = { 'a' : -1, 'b' : -2, 'c' : -3, 'd' : -4 };
34
+ *
35
+ * var bool = noneInBy( obj, isPositive );
36
+ * // returns true
37
+ */
38
+
39
+ // MODULES //
40
+
41
+ var main = require( './main.js' );
42
+
43
+
44
+ // EXPORTS //
45
+
46
+ module.exports = main;
@@ -0,0 +1,71 @@
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 isFunction = require( '@ohos-ports/stdlib-assert/is-function' );
24
+ var isObject = require( '@ohos-ports/stdlib-assert/is-object' );
25
+ var format = require( '@ohos-ports/stdlib-string/format' );
26
+
27
+
28
+ // MAIN //
29
+
30
+ /**
31
+ * Tests whether every property of a provided object does not satisfy a predicate function.
32
+ *
33
+ * @param {Object} obj - input object
34
+ * @param {Function} predicate - test function
35
+ * @param {*} [thisArg] - execution context
36
+ * @throws {TypeError} first argument must be an object
37
+ * @throws {TypeError} second argument must be a function
38
+ * @returns {boolean} boolean indicating whether all elements fail a test
39
+ *
40
+ * @example
41
+ * function isPositive( v ) {
42
+ * return ( v > 0 );
43
+ * }
44
+ *
45
+ * var obj = { 'a' : -1, 'b' : -2, 'c' : -3, 'd' : -4};
46
+ *
47
+ * var bool = noneInBy( obj, isPositive );
48
+ * // returns true
49
+ */
50
+ function noneInBy( obj, predicate, thisArg ) {
51
+ var key;
52
+
53
+ if ( !isObject( obj ) ) {
54
+ throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', obj ) );
55
+ }
56
+ if ( !isFunction( predicate ) ) {
57
+ throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) );
58
+ }
59
+
60
+ for ( key in obj ) {
61
+ if ( predicate.call( thisArg, obj[key], key, obj ) ) {
62
+ return false;
63
+ }
64
+ }
65
+ return true;
66
+ }
67
+
68
+
69
+ // EXPORTS //
70
+
71
+ module.exports = noneInBy;
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "@stdlib/object/none-in-by",
3
+ "version": "0.0.0",
4
+ "description": "Test whether every property in an object fails 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
+ "benchmark": "./benchmark",
19
+ "doc": "./docs",
20
+ "example": "./examples",
21
+ "lib": "./lib",
22
+ "test": "./test"
23
+ },
24
+ "types": "./docs/types",
25
+ "scripts": {},
26
+ "homepage": "https://github.com/stdlib-js/stdlib",
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "git://github.com/stdlib-js/stdlib.git"
30
+ },
31
+ "bugs": {
32
+ "url": "https://github.com/stdlib-js/stdlib/issues"
33
+ },
34
+ "dependencies": {},
35
+ "devDependencies": {},
36
+ "engines": {
37
+ "node": ">=0.10.0",
38
+ "npm": ">2.7.0"
39
+ },
40
+ "os": [
41
+ "aix",
42
+ "darwin",
43
+ "freebsd",
44
+ "linux",
45
+ "macos",
46
+ "openbsd",
47
+ "sunos",
48
+ "win32",
49
+ "windows"
50
+ ],
51
+ "keywords": [
52
+ "stdlib",
53
+ "stdutils",
54
+ "stdutil",
55
+ "utilities",
56
+ "utility",
57
+ "utils",
58
+ "util",
59
+ "test",
60
+ "predicate",
61
+ "none",
62
+ "all",
63
+ "every",
64
+ "iterate",
65
+ "object",
66
+ "validate"
67
+ ]
68
+ }