Skip to content

Commit a369230

Browse files
committed
Auto-generated commit
1 parent b0cf84c commit a369230

File tree

12 files changed

+787
-1
lines changed

12 files changed

+787
-1
lines changed

CHANGELOG.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
55
<section class="release" id="unreleased">
66

7-
## Unreleased (2025-05-05)
7+
## Unreleased (2025-05-07)
88

99
<section class="features">
1010

1111
### Features
1212

13+
- [`2ab5cd8`](https://github.com/stdlib-js/stdlib/commit/2ab5cd84a76425d34ed204d222c33a000107b8d0) - add `anyHasProp` to namespace
14+
- [`ccd5ca6`](https://github.com/stdlib-js/stdlib/commit/ccd5ca60ccf12f9480f930547afb60da9732bf59) - add `array/base/assert/any-has-property`
1315
- [`5edbc25`](https://github.com/stdlib-js/stdlib/commit/5edbc2524bf509bd0bbde5c6432c77f06e55a65d) - add index data type kinds
1416
- [`6606a96`](https://github.com/stdlib-js/stdlib/commit/6606a96c6f200945d5506523f82f232538a2bc2d) - add index data type defaults
1517
- [`28a1564`](https://github.com/stdlib-js/stdlib/commit/28a1564b9977c9c0aebb9806c2a4cbb10336b234) - add `reshape` to namespace
@@ -168,6 +170,9 @@ A total of 31 issues were closed in this release:
168170

169171
<details>
170172

173+
- [`d1a712d`](https://github.com/stdlib-js/stdlib/commit/d1a712db9218350f4e37926ac993b97573b65ba9) - **docs:** demonstrate prototype property _(by Athan Reines)_
174+
- [`2ab5cd8`](https://github.com/stdlib-js/stdlib/commit/2ab5cd84a76425d34ed204d222c33a000107b8d0) - **feat:** add `anyHasProp` to namespace _(by Athan Reines)_
175+
- [`ccd5ca6`](https://github.com/stdlib-js/stdlib/commit/ccd5ca60ccf12f9480f930547afb60da9732bf59) - **feat:** add `array/base/assert/any-has-property` _(by Athan Reines)_
171176
- [`ecdd35d`](https://github.com/stdlib-js/stdlib/commit/ecdd35d1580a9b4460e6a220f47bcf252c8e77bc) - **chore:** fix EditorConfig lint errors [(#6932)](https://github.com/stdlib-js/stdlib/pull/6932) _(by Lalit Narayan Yadav)_
172177
- [`ddff844`](https://github.com/stdlib-js/stdlib/commit/ddff84477a48d5f684eb4c828a2067a90849382d) - **chore:** fix EditorConfig lint errors [(#6869)](https://github.com/stdlib-js/stdlib/pull/6869) _(by zhanggy)_
173178
- [`1f7e55f`](https://github.com/stdlib-js/stdlib/commit/1f7e55f344d26c42e0c2ae001f8ac3ce16f1999a) - **docs:** remove unused packages [(#6837)](https://github.com/stdlib-js/stdlib/pull/6837) _(by Shabareesh Shetty)_
+136
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2025 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+
# anyHasProp
22+
23+
> Test whether at least one element in a provided array has a specified property, either own or inherited.
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 anyHasProp = require( '@stdlib/array/base/assert/any-has-property' );
41+
```
42+
43+
#### anyHasProp( arr, property )
44+
45+
Tests whether at least one element in a provided array has a specified property, either own or inherited.
46+
47+
```javascript
48+
var o1 = {
49+
'a': 1
50+
};
51+
var o2 = {
52+
'b': 2
53+
};
54+
var o3 = {
55+
'c': 3
56+
};
57+
58+
var bool = anyHasProp( [ o1, o2, o3 ], 'b' );
59+
// returns true
60+
61+
bool = anyHasProp( [ o1, o2, o3 ], 'd' );
62+
// returns false
63+
64+
bool = anyHasProp( [ o1, o2, o3 ], 'toString' );
65+
// returns true
66+
```
67+
68+
</section>
69+
70+
<!-- /.usage -->
71+
72+
<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
73+
74+
<section class="notes">
75+
76+
</section>
77+
78+
<!-- /.notes -->
79+
80+
<!-- Package usage examples. -->
81+
82+
<section class="examples">
83+
84+
## Examples
85+
86+
<!-- eslint no-undef: "error" -->
87+
88+
```javascript
89+
var fromCodePoint = require( '@stdlib/string/from-code-point' );
90+
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
91+
var filledBy = require( '@stdlib/array/filled-by' );
92+
var anyHasProp = require( '@stdlib/array/base/assert/any-has-property' );
93+
94+
function randomObject() {
95+
var o = {};
96+
o[ fromCodePoint( 97+discreteUniform( 0, 25 ) ) ] = 0;
97+
return o;
98+
}
99+
100+
var arr = filledBy( 10, 'generic', randomObject );
101+
console.log( arr );
102+
103+
var bool = anyHasProp( arr, 'a' );
104+
console.log( 'a: %s', bool );
105+
106+
bool = anyHasProp( arr, 'b' );
107+
console.log( 'b: %s', bool );
108+
```
109+
110+
</section>
111+
112+
<!-- /.examples -->
113+
114+
<!-- 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. -->
115+
116+
<section class="references">
117+
118+
</section>
119+
120+
<!-- /.references -->
121+
122+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
123+
124+
<section class="related">
125+
126+
</section>
127+
128+
<!-- /.related -->
129+
130+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
131+
132+
<section class="links">
133+
134+
</section>
135+
136+
<!-- /.links -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 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 bench = require( '@stdlib/bench' );
24+
var pow = require( '@stdlib/math/base/special/pow' );
25+
var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive;
26+
var filled = require( './../../../../filled' );
27+
var pkg = require( './../package.json' ).name;
28+
var anyHasProp = require( './../lib' );
29+
30+
31+
// FUNCTIONS //
32+
33+
/**
34+
* Creates a benchmark function.
35+
*
36+
* @private
37+
* @param {PositiveInteger} len - array length
38+
* @returns {Function} benchmark function
39+
*/
40+
function createBenchmark( len ) {
41+
var x = filled( {}, len, 'generic' );
42+
return benchmark;
43+
44+
/**
45+
* Benchmark function.
46+
*
47+
* @private
48+
* @param {Benchmark} b - benchmark instance
49+
*/
50+
function benchmark( b ) {
51+
var out;
52+
var i;
53+
54+
b.tic();
55+
for ( i = 0; i < b.iterations; i++ ) {
56+
out = anyHasProp( x, 'foo' );
57+
if ( typeof out !== 'boolean' ) {
58+
b.fail( 'should return a boolean' );
59+
}
60+
}
61+
b.toc();
62+
if ( !isBoolean( out ) ) {
63+
b.fail( 'should return a boolean' );
64+
}
65+
b.pass( 'benchmark finished' );
66+
b.end();
67+
}
68+
}
69+
70+
71+
// MAIN //
72+
73+
/**
74+
* Main execution sequence.
75+
*
76+
* @private
77+
*/
78+
function main() {
79+
var len;
80+
var min;
81+
var max;
82+
var f;
83+
var i;
84+
85+
min = 1; // 10^min
86+
max = 6; // 10^max
87+
88+
for ( i = min; i <= max; i++ ) {
89+
len = pow( 10, i );
90+
91+
f = createBenchmark( len );
92+
bench( pkg+':dtype=generic,len='+len, f );
93+
}
94+
}
95+
96+
main();
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
{{alias}}( arr, property )
3+
Tests whether at least one element in a provided indexed array has a
4+
specified property, either own or inherited.
5+
6+
Parameters
7+
----------
8+
arr: Array|TypedArray|Object
9+
Input array.
10+
11+
property: string|symbol|number
12+
Property.
13+
14+
Returns
15+
-------
16+
bool: boolean
17+
Result.
18+
19+
Examples
20+
--------
21+
> var o1 = { 'a': 1 };
22+
> var o2 = { 'b': 2 };
23+
> var o3 = { 'c': 3 };
24+
> var x = [ o1, o2, o3 ];
25+
> var out = {{alias}}( x, 'a' )
26+
true
27+
> out = {{alias}}( x, 'd' )
28+
false
29+
> out = {{alias}}( x, 'toString' )
30+
true
31+
32+
See Also
33+
--------
34+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
// TypeScript Version: 4.1
20+
21+
/// <reference types="@stdlib/types"/>
22+
23+
import { Collection, AccessorArrayLike } from '@stdlib/types/array';
24+
import { PropertyName } from '@stdlib/types/object';
25+
26+
/**
27+
* Tests whether at least one element in a provided array has a specified property, either own or inherited.
28+
*
29+
* @param arr - input array
30+
* @param prop - property
31+
* @returns result
32+
*
33+
* @example
34+
* var o1 = {
35+
* 'a': 1
36+
* };
37+
* var o2 = {
38+
* 'b': 2
39+
* };
40+
* var o3 = {
41+
* 'c': 3
42+
* };
43+
*
44+
* var bool = anyHasProp( [ o1, o2, o3 ], 'b' );
45+
* // returns true
46+
*
47+
* bool = anyHasProp( [ o1, o2, o3 ], 'd' );
48+
* // returns false
49+
*
50+
* bool = anyHasProp( [ o1, o2, o3 ], 'toString' );
51+
* // returns true
52+
*/
53+
declare function anyHasProp( arr: Collection<unknown> | AccessorArrayLike<unknown>, prop: PropertyName | number ): boolean;
54+
55+
56+
// EXPORTS //
57+
58+
export = anyHasProp;

0 commit comments

Comments
 (0)