Skip to content

Commit e46e23c

Browse files
committed
Auto-generated commit
1 parent bf44aa5 commit e46e23c

File tree

22 files changed

+1655
-0
lines changed

22 files changed

+1655
-0
lines changed

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010

1111
### Features
1212

13+
- [`0f6d4e7`](https://github.com/stdlib-js/stdlib/commit/0f6d4e7694d458f76dc077d5b618e405f6cfed37) - add `anyIsEntry` to namespace
14+
- [`fbffea0`](https://github.com/stdlib-js/stdlib/commit/fbffea0a7be15b6013111fd0b613548d7c09a1b7) - add `array/base/assert/any-is-entry`
15+
- [`dc8942d`](https://github.com/stdlib-js/stdlib/commit/dc8942da05af3ed631f67fc679c7c1730954e1be) - add `anyIsEntryIn` to namespace
16+
- [`c9edc1a`](https://github.com/stdlib-js/stdlib/commit/c9edc1ab611674fe14def4df00cf8ca407ec4cce) - add `array/base/assert/any-is-entry-in`
1317
- [`8b2c875`](https://github.com/stdlib-js/stdlib/commit/8b2c875e56586bdff1698fd768cec5d568ab24a0) - add `anyHasOwnProp` to namespace
1418
- [`533df61`](https://github.com/stdlib-js/stdlib/commit/533df61c24c654e67a6d3dbf84b878ec0f8c9520) - add `array/base/assert/any-has-own-property`
1519
- [`2ab5cd8`](https://github.com/stdlib-js/stdlib/commit/2ab5cd84a76425d34ed204d222c33a000107b8d0) - add `anyHasProp` to namespace
@@ -172,6 +176,10 @@ A total of 31 issues were closed in this release:
172176

173177
<details>
174178

179+
- [`0f6d4e7`](https://github.com/stdlib-js/stdlib/commit/0f6d4e7694d458f76dc077d5b618e405f6cfed37) - **feat:** add `anyIsEntry` to namespace _(by Athan Reines)_
180+
- [`fbffea0`](https://github.com/stdlib-js/stdlib/commit/fbffea0a7be15b6013111fd0b613548d7c09a1b7) - **feat:** add `array/base/assert/any-is-entry` _(by Athan Reines)_
181+
- [`dc8942d`](https://github.com/stdlib-js/stdlib/commit/dc8942da05af3ed631f67fc679c7c1730954e1be) - **feat:** add `anyIsEntryIn` to namespace _(by Athan Reines)_
182+
- [`c9edc1a`](https://github.com/stdlib-js/stdlib/commit/c9edc1ab611674fe14def4df00cf8ca407ec4cce) - **feat:** add `array/base/assert/any-is-entry-in` _(by Athan Reines)_
175183
- [`8b2c875`](https://github.com/stdlib-js/stdlib/commit/8b2c875e56586bdff1698fd768cec5d568ab24a0) - **feat:** add `anyHasOwnProp` to namespace _(by Athan Reines)_
176184
- [`533df61`](https://github.com/stdlib-js/stdlib/commit/533df61c24c654e67a6d3dbf84b878ec0f8c9520) - **feat:** add `array/base/assert/any-has-own-property` _(by Athan Reines)_
177185
- [`80b1cec`](https://github.com/stdlib-js/stdlib/commit/80b1cec874dbe423a50ed26c1a6c3a7f5fc05cd9) - **docs:** update examples _(by Athan Reines)_

base/assert/any-is-entry-in/README.md

+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+
# anyIsEntryIn
22+
23+
> Test whether at least one element in a provided array has a specified property key-value pair, 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 anyIsEntryIn = require( '@stdlib/array/base/assert/any-is-entry-in' );
41+
```
42+
43+
#### anyIsEntryIn( arr, property )
44+
45+
Tests whether at least one element in a provided array has a specified property key-value pair, 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 = anyIsEntryIn( [ o1, o2, o3 ], 'b', 2 );
59+
// returns true
60+
61+
bool = anyIsEntryIn( [ o1, o2, o3 ], 'd', 0 );
62+
// returns false
63+
64+
bool = anyIsEntryIn( [ o1, o2, o3 ], 'b', 0 );
65+
// returns false
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 anyIsEntryIn = require( '@stdlib/array/base/assert/any-is-entry-in' );
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 = anyIsEntryIn( arr, 'a', 0 );
104+
console.log( 'a: %s', bool );
105+
106+
bool = anyIsEntryIn( arr, 'b', 0 );
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 anyIsEntryIn = 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 = anyIsEntryIn( x, 'foo', 'bar' );
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();
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
{{alias}}( arr, property, value )
3+
Tests whether at least one element in a provided indexed array has a
4+
specified property key-value pair, 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+
value: any
15+
Property value.
16+
17+
Returns
18+
-------
19+
bool: boolean
20+
Result.
21+
22+
Examples
23+
--------
24+
> var o1 = { 'a': 1 };
25+
> var o2 = { 'b': 2 };
26+
> var o3 = { 'c': 3 };
27+
> var x = [ o1, o2, o3 ];
28+
> var out = {{alias}}( x, 'a', 1 )
29+
true
30+
> out = {{alias}}( x, 'b', 0 )
31+
false
32+
> out = {{alias}}( x, 'b', 2 )
33+
true
34+
35+
See Also
36+
--------
37+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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 key-value pair, either own or inherited.
28+
*
29+
* @param arr - input array
30+
* @param prop - property
31+
* @param value - property value
32+
* @returns result
33+
*
34+
* @example
35+
* var o1 = {
36+
* 'a': 1
37+
* };
38+
* var o2 = {
39+
* 'b': 2
40+
* };
41+
* var o3 = {
42+
* 'c': 3
43+
* };
44+
*
45+
* var bool = anyIsEntryIn( [ o1, o2, o3 ], 'b', 2 );
46+
* // returns true
47+
*
48+
* bool = anyIsEntryIn( [ o1, o2, o3 ], 'b', 3 );
49+
* // returns false
50+
*
51+
* bool = anyIsEntryIn( [ o1, o2, o3 ], 'd', 0 );
52+
* // returns false
53+
*/
54+
declare function anyIsEntryIn( arr: Collection<unknown> | AccessorArrayLike<unknown>, prop: PropertyName | number, value: unknown ): boolean;
55+
56+
57+
// EXPORTS //
58+
59+
export = anyIsEntryIn;

0 commit comments

Comments
 (0)