@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.
- package/LICENSE +177 -0
- package/NOTICE +1 -0
- package/README.md +262 -2
- package/SECURITY.md +5 -0
- package/any-in-by/README.md +217 -0
- package/any-in-by/docs/repl.txt +41 -0
- package/any-in-by/docs/types/index.d.ts +102 -0
- package/any-in-by/docs/types/test.ts +53 -0
- package/any-in-by/lib/index.js +50 -0
- package/any-in-by/lib/main.js +75 -0
- package/any-in-by/package.json +66 -0
- package/any-own-by/README.md +221 -0
- package/any-own-by/docs/repl.txt +43 -0
- package/any-own-by/docs/types/index.d.ts +101 -0
- package/any-own-by/docs/types/test.ts +63 -0
- package/any-own-by/lib/index.js +46 -0
- package/any-own-by/lib/main.js +77 -0
- package/any-own-by/package.json +70 -0
- package/assign/README.md +139 -0
- package/assign/docs/repl.txt +34 -0
- package/assign/docs/types/index.d.ts +113 -0
- package/assign/docs/types/test.ts +47 -0
- package/assign/lib/builtin.js +55 -0
- package/assign/lib/has_object_assign.js +33 -0
- package/assign/lib/index.js +52 -0
- package/assign/lib/polyfill.js +86 -0
- package/assign/package.json +64 -0
- package/assign-in/README.md +145 -0
- package/assign-in/docs/repl.txt +34 -0
- package/assign-in/docs/types/index.d.ts +175 -0
- package/assign-in/docs/types/test.ts +44 -0
- package/assign-in/lib/index.js +54 -0
- package/assign-in/lib/main.js +92 -0
- package/assign-in/package.json +60 -0
- package/bifurcate-in/README.md +298 -0
- package/bifurcate-in/docs/repl.txt +68 -0
- package/bifurcate-in/docs/types/index.d.ts +189 -0
- package/bifurcate-in/docs/types/test.ts +97 -0
- package/bifurcate-in/lib/index.js +106 -0
- package/bifurcate-in/lib/main.js +148 -0
- package/bifurcate-in/lib/return_keys.js +81 -0
- package/bifurcate-in/lib/return_pairs.js +87 -0
- package/bifurcate-in/lib/return_values.js +87 -0
- package/bifurcate-in/lib/validate.js +76 -0
- package/bifurcate-in/package.json +72 -0
- package/bifurcate-own/README.md +255 -0
- package/bifurcate-own/docs/repl.txt +63 -0
- package/bifurcate-own/docs/types/index.d.ts +183 -0
- package/bifurcate-own/docs/types/test.ts +97 -0
- package/bifurcate-own/lib/index.js +87 -0
- package/bifurcate-own/lib/main.js +127 -0
- package/bifurcate-own/lib/return_keys.js +81 -0
- package/bifurcate-own/lib/return_pairs.js +87 -0
- package/bifurcate-own/lib/return_values.js +87 -0
- package/bifurcate-own/lib/validate.js +76 -0
- package/bifurcate-own/package.json +71 -0
- package/capitalize-keys/README.md +139 -0
- package/capitalize-keys/docs/repl.txt +28 -0
- package/capitalize-keys/docs/types/index.d.ts +46 -0
- package/capitalize-keys/docs/types/test.ts +33 -0
- package/capitalize-keys/lib/index.js +45 -0
- package/capitalize-keys/lib/main.js +69 -0
- package/capitalize-keys/package.json +76 -0
- package/common-keys/README.md +125 -0
- package/common-keys/docs/repl.txt +29 -0
- package/common-keys/docs/types/index.d.ts +70 -0
- package/common-keys/docs/types/test.ts +33 -0
- package/common-keys/lib/index.js +51 -0
- package/common-keys/lib/main.js +106 -0
- package/common-keys/package.json +70 -0
- package/common-keys-in/README.md +125 -0
- package/common-keys-in/docs/repl.txt +29 -0
- package/common-keys-in/docs/types/index.d.ts +70 -0
- package/common-keys-in/docs/types/test.ts +33 -0
- package/common-keys-in/lib/index.js +51 -0
- package/common-keys-in/lib/main.js +106 -0
- package/common-keys-in/package.json +72 -0
- package/ctor/README.md +536 -0
- package/ctor/docs/repl.txt +592 -0
- package/ctor/docs/types/index.d.ts +56 -0
- package/ctor/docs/types/test.ts +33 -0
- package/ctor/lib/index.js +54 -0
- package/ctor/lib/main.js +58 -0
- package/ctor/package.json +58 -0
- package/deep-get/README.md +181 -0
- package/deep-get/docs/repl.txt +63 -0
- package/deep-get/docs/types/index.d.ts +125 -0
- package/deep-get/docs/types/test.ts +109 -0
- package/deep-get/lib/defaults.js +38 -0
- package/deep-get/lib/dget.js +57 -0
- package/deep-get/lib/factory.js +94 -0
- package/deep-get/lib/index.js +58 -0
- package/deep-get/lib/main.js +101 -0
- package/deep-get/lib/validate.js +66 -0
- package/deep-get/package.json +68 -0
- package/deep-set/README.md +273 -0
- package/deep-set/docs/repl.txt +87 -0
- package/deep-set/docs/types/index.d.ts +180 -0
- package/deep-set/docs/types/test.ts +134 -0
- package/deep-set/lib/defaults.js +39 -0
- package/deep-set/lib/dset.js +80 -0
- package/deep-set/lib/factory.js +99 -0
- package/deep-set/lib/index.js +58 -0
- package/deep-set/lib/main.js +120 -0
- package/deep-set/lib/validate.js +74 -0
- package/deep-set/package.json +69 -0
- package/docs/types/index.d.ts +964 -0
- package/every-in-by/README.md +156 -0
- package/every-in-by/docs/repl.txt +43 -0
- package/every-in-by/docs/types/index.d.ts +83 -0
- package/every-in-by/docs/types/test.ts +60 -0
- package/every-in-by/lib/index.js +51 -0
- package/every-in-by/lib/main.js +70 -0
- package/every-in-by/package.json +67 -0
- package/every-own-by/README.md +223 -0
- package/every-own-by/docs/repl.txt +43 -0
- package/every-own-by/docs/types/index.d.ts +102 -0
- package/every-own-by/docs/types/test.ts +62 -0
- package/every-own-by/lib/index.js +46 -0
- package/every-own-by/lib/main.js +77 -0
- package/every-own-by/package.json +68 -0
- package/for-in/README.md +218 -0
- package/for-in/docs/repl.txt +44 -0
- package/for-in/docs/types/index.d.ts +65 -0
- package/for-in/docs/types/test.ts +50 -0
- package/for-in/lib/index.js +54 -0
- package/for-in/lib/main.js +82 -0
- package/for-in/package.json +74 -0
- package/for-own/README.md +209 -0
- package/for-own/docs/repl.txt +49 -0
- package/for-own/docs/types/index.d.ts +63 -0
- package/for-own/docs/types/test.ts +50 -0
- package/for-own/lib/index.js +50 -0
- package/for-own/lib/main.js +85 -0
- package/for-own/package.json +71 -0
- package/inverse/README.md +163 -0
- package/inverse/docs/repl.txt +53 -0
- package/inverse/docs/types/index.d.ts +66 -0
- package/inverse/docs/types/test.ts +60 -0
- package/inverse/lib/index.js +59 -0
- package/inverse/lib/main.js +123 -0
- package/inverse/package.json +69 -0
- package/inverse-by/README.md +205 -0
- package/inverse-by/docs/repl.txt +67 -0
- package/inverse-by/docs/types/index.d.ts +160 -0
- package/inverse-by/docs/types/test.ts +81 -0
- package/inverse-by/lib/index.js +78 -0
- package/inverse-by/lib/main.js +148 -0
- package/inverse-by/package.json +75 -0
- package/lib/index.js +276 -0
- package/lowercase-keys/README.md +139 -0
- package/lowercase-keys/docs/repl.txt +28 -0
- package/lowercase-keys/docs/types/index.d.ts +46 -0
- package/lowercase-keys/docs/types/test.ts +33 -0
- package/lowercase-keys/lib/index.js +45 -0
- package/lowercase-keys/lib/main.js +63 -0
- package/lowercase-keys/package.json +74 -0
- package/move-property/README.md +144 -0
- package/move-property/docs/repl.txt +38 -0
- package/move-property/docs/types/index.d.ts +53 -0
- package/move-property/docs/types/test.ts +46 -0
- package/move-property/lib/index.js +46 -0
- package/move-property/lib/main.js +74 -0
- package/move-property/package.json +69 -0
- package/none-in-by/README.md +241 -0
- package/none-in-by/docs/repl.txt +42 -0
- package/none-in-by/docs/types/index.d.ts +101 -0
- package/none-in-by/docs/types/test.ts +61 -0
- package/none-in-by/lib/index.js +46 -0
- package/none-in-by/lib/main.js +71 -0
- package/none-in-by/package.json +68 -0
- package/none-own-by/README.md +177 -0
- package/none-own-by/docs/repl.txt +42 -0
- package/none-own-by/docs/types/index.d.ts +102 -0
- package/none-own-by/docs/types/test.ts +61 -0
- package/none-own-by/lib/index.js +50 -0
- package/none-own-by/lib/main.js +75 -0
- package/none-own-by/package.json +68 -0
- package/package.json +66 -4
- package/some-in-by/README.md +232 -0
- package/some-in-by/docs/repl.txt +45 -0
- package/some-in-by/docs/types/index.d.ts +104 -0
- package/some-in-by/docs/types/test.ts +66 -0
- package/some-in-by/lib/index.js +46 -0
- package/some-in-by/lib/main.js +87 -0
- package/some-in-by/package.json +75 -0
- package/some-own-by/README.md +251 -0
- package/some-own-by/docs/repl.txt +45 -0
- package/some-own-by/docs/types/index.d.ts +103 -0
- package/some-own-by/docs/types/test.ts +66 -0
- package/some-own-by/lib/index.js +46 -0
- package/some-own-by/lib/main.js +85 -0
- package/some-own-by/package.json +72 -0
- package/uncapitalize-keys/README.md +139 -0
- package/uncapitalize-keys/docs/repl.txt +28 -0
- package/uncapitalize-keys/docs/types/index.d.ts +46 -0
- package/uncapitalize-keys/docs/types/test.ts +33 -0
- package/uncapitalize-keys/lib/index.js +45 -0
- package/uncapitalize-keys/lib/main.js +69 -0
- package/uncapitalize-keys/package.json +76 -0
- package/uppercase-keys/README.md +139 -0
- package/uppercase-keys/docs/repl.txt +28 -0
- package/uppercase-keys/docs/types/index.d.ts +46 -0
- package/uppercase-keys/docs/types/test.ts +33 -0
- package/uppercase-keys/lib/index.js +45 -0
- package/uppercase-keys/lib/main.js +63 -0
- package/uppercase-keys/package.json +74 -0
|
@@ -0,0 +1,177 @@
|
|
|
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
|
+
# noneOwnBy
|
|
22
|
+
|
|
23
|
+
> Tests whether every own 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 noneOwnBy = require( '@stdlib/object/none-own-by' );
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
#### noneOwnBy( object, predicate\[, thisArg ] )
|
|
44
|
+
|
|
45
|
+
Tests whether every `own` 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 = noneOwnBy( 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 = noneOwnBy( obj, isUnderage );
|
|
76
|
+
// returns false
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
</section>
|
|
80
|
+
|
|
81
|
+
<!-- /.usage -->
|
|
82
|
+
|
|
83
|
+
<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
|
84
|
+
|
|
85
|
+
<section class="notes">
|
|
86
|
+
|
|
87
|
+
## Notes
|
|
88
|
+
|
|
89
|
+
- If the 1st argument is not an object or the second argument is not a function, the function throws a Type Error.
|
|
90
|
+
|
|
91
|
+
- If provided an empty object, the function returns `true`.
|
|
92
|
+
|
|
93
|
+
```javascript
|
|
94
|
+
function truthy() {
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
var bool = noneOwnBy( {}, truthy );
|
|
98
|
+
// returns true
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
</section>
|
|
102
|
+
|
|
103
|
+
<!-- /.notes -->
|
|
104
|
+
|
|
105
|
+
<!-- Package usage examples. -->
|
|
106
|
+
|
|
107
|
+
<section class="examples">
|
|
108
|
+
|
|
109
|
+
## Examples
|
|
110
|
+
|
|
111
|
+
<!-- eslint no-undef: "error" -->
|
|
112
|
+
|
|
113
|
+
```javascript
|
|
114
|
+
var noneOwnBy = require( '@stdlib/object/none-own-by' );
|
|
115
|
+
|
|
116
|
+
function isUnderage( age ) {
|
|
117
|
+
return age < 18;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
var obj = {
|
|
121
|
+
'a': 26,
|
|
122
|
+
'b': 20,
|
|
123
|
+
'c': 25
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
var bool = noneOwnBy( obj, isUnderage );
|
|
127
|
+
// returns true
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
</section>
|
|
131
|
+
|
|
132
|
+
<!-- /.examples -->
|
|
133
|
+
|
|
134
|
+
<!-- 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. -->
|
|
135
|
+
|
|
136
|
+
<section class="references">
|
|
137
|
+
|
|
138
|
+
</section>
|
|
139
|
+
|
|
140
|
+
<!-- /.references -->
|
|
141
|
+
|
|
142
|
+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
|
|
143
|
+
|
|
144
|
+
<section class="related">
|
|
145
|
+
|
|
146
|
+
* * *
|
|
147
|
+
|
|
148
|
+
## See Also
|
|
149
|
+
|
|
150
|
+
- <span class="package-name">[`@stdlib/object/any-own-by`][@stdlib/object/any-own-by]</span><span class="delimiter">: </span><span class="description">test whether whether any 'own' property of a provided object satisfies a predicate function.</span>
|
|
151
|
+
- <span class="package-name">[`@stdlib/object/every-own-by`][@stdlib/object/every-own-by]</span><span class="delimiter">: </span><span class="description">test whether all own properties of an object pass a test implemented by a predicate function.</span>
|
|
152
|
+
- <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>
|
|
153
|
+
- <span class="package-name">[`@stdlib/object/some-own-by`][@stdlib/object/some-own-by]</span><span class="delimiter">: </span><span class="description">test whether some `own` properties of a provided object satisfy a predicate function for at least `n` properties.</span>
|
|
154
|
+
|
|
155
|
+
</section>
|
|
156
|
+
|
|
157
|
+
<!-- /.related -->
|
|
158
|
+
|
|
159
|
+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
|
|
160
|
+
|
|
161
|
+
<section class="links">
|
|
162
|
+
|
|
163
|
+
<!-- <related-links> -->
|
|
164
|
+
|
|
165
|
+
[@stdlib/object/any-own-by]: https://github.com/stdlib-js/object/tree/main/any-own-by
|
|
166
|
+
|
|
167
|
+
[@stdlib/object/every-own-by]: https://github.com/stdlib-js/object/tree/main/every-own-by
|
|
168
|
+
|
|
169
|
+
[@stdlib/utils/none-by]: https://www.npmjs.com/package/@stdlib/utils-none-by
|
|
170
|
+
|
|
171
|
+
[@stdlib/object/some-own-by]: https://github.com/stdlib-js/object/tree/main/some-own-by
|
|
172
|
+
|
|
173
|
+
<!-- </related-links> -->
|
|
174
|
+
|
|
175
|
+
</section>
|
|
176
|
+
|
|
177
|
+
<!-- /.links -->
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
|
|
2
|
+
{{alias}}( object, predicate[, thisArg ] )
|
|
3
|
+
Tests whether every own property of an object fails a test implemented
|
|
4
|
+
by a predicate function.
|
|
5
|
+
|
|
6
|
+
The predicate function is provided three arguments:
|
|
7
|
+
|
|
8
|
+
- value: property value.
|
|
9
|
+
- index: property 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.
|
|
20
|
+
|
|
21
|
+
predicate: Function
|
|
22
|
+
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 own properties; otherwise, the function returns `false`.
|
|
32
|
+
|
|
33
|
+
Examples
|
|
34
|
+
--------
|
|
35
|
+
> function isUnderage( v ) { return ( v < 18 ); };
|
|
36
|
+
> var obj = { 'a': 11, 'b': 12, 'c': 22 };
|
|
37
|
+
> var bool = {{alias}}( obj, isUnderage )
|
|
38
|
+
false
|
|
39
|
+
|
|
40
|
+
See Also
|
|
41
|
+
--------
|
|
42
|
+
|
|
@@ -0,0 +1,102 @@
|
|
|
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
|
+
/**
|
|
25
|
+
* Checks whether an own property of the object passes the test.
|
|
26
|
+
*
|
|
27
|
+
* @returns boolean indicating whether an own property of the object passes the test
|
|
28
|
+
*/
|
|
29
|
+
type Nullary<U> = ( this: U ) => boolean;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Checks whether an own property of the object passes the test.
|
|
33
|
+
*
|
|
34
|
+
* @param value - property value
|
|
35
|
+
* @returns boolean indicating whether an own property of the object passes the test
|
|
36
|
+
*/
|
|
37
|
+
type Unary<T, U> = ( this: U, value: T ) => boolean;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Checks whether an own property of the object passes the test.
|
|
41
|
+
*
|
|
42
|
+
* @param value - property value
|
|
43
|
+
* @param key - property key
|
|
44
|
+
* @returns boolean indicating whether an own property of the object passes the test
|
|
45
|
+
*/
|
|
46
|
+
type Binary<T, U> = ( this: U, value: T, key: number ) => boolean;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Checks whether an own property of the object passes the test.
|
|
50
|
+
*
|
|
51
|
+
* @param value - property value
|
|
52
|
+
* @param key - property key
|
|
53
|
+
* @param object - input object
|
|
54
|
+
* @returns boolean indicating whether an own property of the object passes the test
|
|
55
|
+
*/
|
|
56
|
+
type Ternary<T, U> = ( this: U, value: T, key: number, object: Object ) => boolean;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Checks whether an own property of the object passes the test.
|
|
60
|
+
*
|
|
61
|
+
* @param value - object value
|
|
62
|
+
* @param key - object key
|
|
63
|
+
* @param object - input object
|
|
64
|
+
* @returns boolean indicating whether an own property of the object passes the test
|
|
65
|
+
*/
|
|
66
|
+
type Predicate<T, U> = Nullary<U> | Unary<T, U> | Binary<T, U> | Ternary<T, U>;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Tests whether every property of an object fails a test implemented by a predicate function.
|
|
70
|
+
*
|
|
71
|
+
* ## Notes
|
|
72
|
+
*
|
|
73
|
+
* - The predicate function is provided three arguments:
|
|
74
|
+
*
|
|
75
|
+
* - `value`: property value
|
|
76
|
+
* - `key`: property key
|
|
77
|
+
* - `object`: the input object
|
|
78
|
+
*
|
|
79
|
+
* - The function immediately returns upon encountering a truthy return value.
|
|
80
|
+
* - If provided an empty object, the function returns `true`.
|
|
81
|
+
*
|
|
82
|
+
* @param object - input object
|
|
83
|
+
* @param predicate - test function
|
|
84
|
+
* @param thisArg - execution context
|
|
85
|
+
* @returns boolean indicating whether every property fails a test
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* function isUnderage( v ) {
|
|
89
|
+
* return ( v < 18 );
|
|
90
|
+
* }
|
|
91
|
+
*
|
|
92
|
+
* var obj = { 'a': 20, 'b': 22, 'c': 25 };
|
|
93
|
+
*
|
|
94
|
+
* var bool = noneOwnBy( obj, isUnderage );
|
|
95
|
+
* // returns true
|
|
96
|
+
*/
|
|
97
|
+
declare function noneOwnBy<T = unknown, U = unknown>( object: Record<string, unknown>, predicate: Predicate<T, U>, thisArg?: ThisParameterType<Predicate<T, U>> ): boolean;
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
// EXPORTS //
|
|
101
|
+
|
|
102
|
+
export = noneOwnBy;
|
|
@@ -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 noneOwnBy = require( './index' );
|
|
20
|
+
|
|
21
|
+
const isUnderAge = ( v: number ): boolean => {
|
|
22
|
+
return ( v < 18 );
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// TESTS //
|
|
26
|
+
|
|
27
|
+
const obj = {
|
|
28
|
+
'a': 10,
|
|
29
|
+
'b': 12,
|
|
30
|
+
'c': 22
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// The function returns a boolean...
|
|
34
|
+
{
|
|
35
|
+
noneOwnBy( obj, isUnderAge ); // $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
|
+
noneOwnBy( 2, isUnderAge ); // $ExpectError
|
|
41
|
+
noneOwnBy( false, isUnderAge ); // $ExpectError
|
|
42
|
+
noneOwnBy( true, isUnderAge ); // $ExpectError
|
|
43
|
+
noneOwnBy( [ 1, 2 ], isUnderAge ); // $ExpectError
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// The compiler throws an error if the function is provided a second argument which is not a function...
|
|
47
|
+
{
|
|
48
|
+
noneOwnBy( obj , 2 ); // $ExpectError
|
|
49
|
+
noneOwnBy( obj , false ); // $ExpectError
|
|
50
|
+
noneOwnBy( obj , true ); // $ExpectError
|
|
51
|
+
noneOwnBy( obj , 'abc' ); // $ExpectError
|
|
52
|
+
noneOwnBy( obj , {} ); // $ExpectError
|
|
53
|
+
noneOwnBy( obj , [] ); // $ExpectError
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// The compiler throws an error if the function is provided an invalid number of arguments...
|
|
57
|
+
{
|
|
58
|
+
noneOwnBy(); // $ExpectError
|
|
59
|
+
noneOwnBy( [ 1, 2, 3 ] ); // $ExpectError
|
|
60
|
+
noneOwnBy( [ 1, 2, 3 ], isUnderAge, {}, 3 ); // $ExpectError
|
|
61
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
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 "own" property of a provided object fails a test implemented by a predicate function.
|
|
23
|
+
*
|
|
24
|
+
* @module @stdlib/object/none-own-by
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* var noneOwnBy = require( '@ohos-ports/stdlib-object/none-own-by' );
|
|
28
|
+
*
|
|
29
|
+
* function isUnderage( age ) {
|
|
30
|
+
* return age < 18;
|
|
31
|
+
* }
|
|
32
|
+
*
|
|
33
|
+
* var obj = {
|
|
34
|
+
* 'a': 10,
|
|
35
|
+
* 'b': 12,
|
|
36
|
+
* 'c': 15
|
|
37
|
+
* };
|
|
38
|
+
*
|
|
39
|
+
* var bool = noneOwnBy( obj, isUnderage );
|
|
40
|
+
* // returns false
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
// MODULES //
|
|
44
|
+
|
|
45
|
+
var main = require( './main.js' );
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
// EXPORTS //
|
|
49
|
+
|
|
50
|
+
module.exports = main;
|
|
@@ -0,0 +1,75 @@
|
|
|
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 hasOwnProp = require( '@ohos-ports/stdlib-assert/has-own-property' );
|
|
24
|
+
var isFunction = require( '@ohos-ports/stdlib-assert/is-function' );
|
|
25
|
+
var isObject = require( '@ohos-ports/stdlib-assert/is-object' );
|
|
26
|
+
var format = require( '@ohos-ports/stdlib-string/format' );
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
// MAIN //
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Tests whether every own property of an object fails a test implemented by a predicate function.
|
|
33
|
+
*
|
|
34
|
+
* @param {Object} obj - input object
|
|
35
|
+
* @param {Function} predicate - test function
|
|
36
|
+
* @param {*} [thisArg] - execution context
|
|
37
|
+
* @throws {TypeError} first argument must be an object
|
|
38
|
+
* @throws {TypeError} second argument must be a function
|
|
39
|
+
* @returns {boolean} boolean indicating whether all elements fail a test
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* function isUnderage( age ) {
|
|
43
|
+
* return ( age < 18 );
|
|
44
|
+
* }
|
|
45
|
+
*
|
|
46
|
+
* var obj = {
|
|
47
|
+
* 'a': 10,
|
|
48
|
+
* 'b': 12,
|
|
49
|
+
* 'c': 15
|
|
50
|
+
* };
|
|
51
|
+
*
|
|
52
|
+
* var bool = noneOwnBy( obj, isUnderage );
|
|
53
|
+
* // returns false
|
|
54
|
+
*/
|
|
55
|
+
function noneOwnBy( obj, predicate, thisArg ) {
|
|
56
|
+
var key;
|
|
57
|
+
|
|
58
|
+
if ( !isObject( obj ) ) {
|
|
59
|
+
throw new TypeError( format( 'invalid argument. First argument must be an object. Value: `%s`.', obj ) );
|
|
60
|
+
}
|
|
61
|
+
if ( !isFunction( predicate ) ) {
|
|
62
|
+
throw new TypeError( format( 'invalid argument. Second argument must be a function. Value: `%s`.', predicate ) );
|
|
63
|
+
}
|
|
64
|
+
for ( key in obj ) {
|
|
65
|
+
if ( hasOwnProp( obj, key ) && predicate.call( thisArg, obj[key], key, obj ) ) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
// EXPORTS //
|
|
74
|
+
|
|
75
|
+
module.exports = noneOwnBy;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@stdlib/object/none-own-by",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Tests whether every own property of 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
|
+
"object",
|
|
65
|
+
"iterate",
|
|
66
|
+
"validate"
|
|
67
|
+
]
|
|
68
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,68 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ohos-ports/stdlib-object",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.4.1-beta.0",
|
|
4
|
+
"description": "Object.",
|
|
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
|
+
},
|
|
21
|
+
"types": "./docs/types",
|
|
22
|
+
"scripts": {},
|
|
23
|
+
"homepage": "https://stdlib.io",
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git://github.com/stdlib-js/object.git"
|
|
27
|
+
},
|
|
28
|
+
"bugs": {
|
|
29
|
+
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@ohos-ports/stdlib-assert": "^0.4.1-beta.2",
|
|
33
|
+
"@ohos-ports/stdlib-string": "^0.4.1-beta.2",
|
|
34
|
+
"@ohos-ports/stdlib-types": "^0.5.1-beta.1",
|
|
35
|
+
"@ohos-ports/stdlib-utils": "^0.4.1-beta.1"
|
|
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
|
+
"openharmony"
|
|
53
|
+
],
|
|
54
|
+
"keywords": [
|
|
55
|
+
"stdlib",
|
|
56
|
+
"standard",
|
|
57
|
+
"library",
|
|
58
|
+
"std",
|
|
59
|
+
"lib",
|
|
60
|
+
"object",
|
|
61
|
+
"namespace",
|
|
62
|
+
"ns"
|
|
63
|
+
],
|
|
64
|
+
"funding": {
|
|
65
|
+
"type": "opencollective",
|
|
66
|
+
"url": "https://opencollective.com/stdlib"
|
|
67
|
+
}
|
|
68
|
+
}
|