Skip to content

Commit 109d75d

Browse files
committed
Auto-generated commit
1 parent c3ee1c7 commit 109d75d

File tree

11 files changed

+697
-1
lines changed

11 files changed

+697
-1
lines changed

CHANGELOG.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,28 @@
145145

146146
<!-- /.package -->
147147

148+
<section class="package" id="assert-is-same-array-like-object-unreleased">
149+
150+
#### [@stdlib/assert/is-same-array-like-object](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-same-array-like-object)
151+
152+
<details>
153+
154+
<section class="features">
155+
156+
##### Features
157+
158+
- [`15e6c71`](https://github.com/stdlib-js/stdlib/commit/15e6c71cac991fadbb8f804a7811650daa0d5e87) - add `assert/is-same-array-like-object`
159+
160+
</section>
161+
162+
<!-- /.features -->
163+
164+
</details>
165+
166+
</section>
167+
168+
<!-- /.package -->
169+
148170
</section>
149171

150172
<!-- /.packages -->
@@ -153,12 +175,13 @@
153175

154176
### Contributors
155177

156-
A total of 4 people contributed to this release. Thank you to the following contributors:
178+
A total of 5 people contributed to this release. Thank you to the following contributors:
157179

158180
- Aayush Khanna
159181
- Athan Reines
160182
- Philipp Burckhardt
161183
- Soumajit Chatterjee
184+
- yaswanth
162185

163186
</section>
164187

@@ -170,6 +193,7 @@ A total of 4 people contributed to this release. Thank you to the following cont
170193

171194
<details>
172195

196+
- [`15e6c71`](https://github.com/stdlib-js/stdlib/commit/15e6c71cac991fadbb8f804a7811650daa0d5e87) - **feat:** add `assert/is-same-array-like-object` _(by yaswanth, Philipp Burckhardt)_
173197
- [`7bb8e20`](https://github.com/stdlib-js/stdlib/commit/7bb8e2020d334d9f9a838291e78d2f7442b24a67) - **feat:** add `@stdlib/assert/is-same-accessor-array` _(by Aayush Khanna, Philipp Burckhardt)_
174198
- [`1f6fc8b`](https://github.com/stdlib-js/stdlib/commit/1f6fc8b5b99837f9d8b378413298f7544f1cb38e) - **bench:** update benchmarks to measure affirmative/negative test values _(by Soumajit Chatterjee, Philipp Burckhardt)_
175199
- [`e97215f`](https://github.com/stdlib-js/stdlib/commit/e97215fbf9f4d1ec8548086f78ed04a0ec80a43f) - **feat:** add `hasBtoaSupport` to namespace _(by Athan Reines)_

is-same-array-like-object/README.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
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+
# isSameArrayLikeObject
22+
23+
> Test if two arguments are both [array-like objects][@stdlib/assert/is-array-like-object] and have the [same values][@stdlib/assert/is-same-value].
24+
25+
<section class="usage">
26+
27+
## Usage
28+
29+
```javascript
30+
var isSameArrayLikeObject = require( '@stdlib/assert/is-same-array-like-object' );
31+
```
32+
33+
#### isSameArrayLikeObject( v1, v2 )
34+
35+
Test if two arguments are both [array-like objects][@stdlib/assert/is-array-like-object] and have the [same values][@stdlib/assert/is-same-value].
36+
37+
```javascript
38+
var x = [ 1.0, 2.0 ];
39+
var y = [ 1.0, 2.0 ];
40+
var bool = isSameArrayLikeObject( x, y );
41+
// returns true
42+
43+
bool = isSameArrayLikeObject( x, [ -1.0, 2.0 ] );
44+
// returns false
45+
```
46+
47+
</section>
48+
49+
<!-- /.usage -->
50+
51+
<section class="notes">
52+
53+
## Notes
54+
55+
- In contrast to the strict equality operator `===`, the function distinguishes between `+0` and `-0` and treats `NaNs` as the [same value][@stdlib/assert/is-same-value].
56+
57+
</section>
58+
59+
<!-- /.notes -->
60+
61+
<section class="examples">
62+
63+
## Examples
64+
65+
<!-- eslint no-undef: "error" -->
66+
67+
```javascript
68+
var isSameArrayLikeObject = require( '@stdlib/assert/is-same-array-like-object' );
69+
70+
var x = [ 1.0, 2.0, 3.0 ];
71+
var y = [ 1.0, 2.0, 3.0 ];
72+
var out = isSameArrayLikeObject( x, y );
73+
// returns true
74+
75+
x = [ -0.0, 0.0, -0.0 ];
76+
y = [ 0.0, -0.0, 0.0 ];
77+
out = isSameArrayLikeObject( x, y );
78+
// returns false
79+
80+
x = [ NaN, NaN, NaN ];
81+
y = [ NaN, NaN, NaN ];
82+
out = isSameArrayLikeObject( x, y );
83+
// returns true
84+
```
85+
86+
</section>
87+
88+
<!-- /.examples -->
89+
90+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
91+
92+
<section class="related">
93+
94+
</section>
95+
96+
<!-- /.related -->
97+
98+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
99+
100+
<section class="links">
101+
102+
[@stdlib/assert/is-array-like-object]: https://github.com/stdlib-js/assert/tree/main/is-array-like-object
103+
104+
[@stdlib/assert/is-same-value]: https://github.com/stdlib-js/assert/tree/main/is-same-value
105+
106+
<!-- <related-links> -->
107+
108+
<!-- </related-links> -->
109+
110+
</section>
111+
112+
<!-- /.links -->
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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 bench = require( '@stdlib/bench' );
24+
var isBoolean = require( './../../is-boolean' ).isPrimitive;
25+
var pow = require( '@stdlib/math/base/special/pow' );
26+
var zeroTo = require( '@stdlib/array/base/zero-to' );
27+
var pkg = require( './../package.json' ).name;
28+
var isSameArrayLikeObject = 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 = zeroTo( len );
42+
var y = zeroTo( len );
43+
return benchmark;
44+
45+
/**
46+
* Benchmark function.
47+
*
48+
* @private
49+
* @param {Benchmark} b - benchmark instance
50+
*/
51+
function benchmark( b ) {
52+
var bool;
53+
var i;
54+
55+
b.tic();
56+
for ( i = 0; i < b.iterations; i++ ) {
57+
bool = isSameArrayLikeObject( x, y );
58+
if ( typeof bool !== 'boolean' ) {
59+
b.fail( 'should return a boolean' );
60+
}
61+
}
62+
b.toc();
63+
if ( !isBoolean( bool ) ) {
64+
b.fail( 'should return a boolean' );
65+
}
66+
b.pass( 'benchmark finished' );
67+
b.end();
68+
}
69+
}
70+
71+
72+
// MAIN //
73+
74+
/**
75+
* Main execution sequence.
76+
*
77+
* @private
78+
*/
79+
function main() {
80+
var len;
81+
var min;
82+
var max;
83+
var f;
84+
var i;
85+
86+
min = 1; // 10^min
87+
max = 6; // 10^max
88+
89+
for ( i = min; i <= max; i++ ) {
90+
len = pow( 10, i );
91+
f = createBenchmark( len );
92+
bench( pkg+':len='+len, f );
93+
}
94+
}
95+
96+
main();
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
{{alias}}( v1, v2 )
3+
Tests if two arguments are both array-like objects and have the same values.
4+
5+
The function differs from the `===` operator in that the function treats
6+
`-0` and `+0` as distinct and `NaNs` as the same.
7+
8+
Parameters
9+
----------
10+
v1: any
11+
First input value.
12+
13+
v2: any
14+
Second input value.
15+
16+
Returns
17+
-------
18+
bool: boolean
19+
Boolean indicating whether two arguments are the same.
20+
21+
Examples
22+
--------
23+
> var x = [ 1.0, 2.0, 3.0 ];
24+
> var y = [ 1.0, 2.0, 3.0 ];
25+
> var bool = {{alias}}( x, y )
26+
true
27+
28+
> x = [ NaN, NaN, NaN ];
29+
> y = [ NaN, NaN, NaN ];
30+
> bool = {{alias}}( x, y )
31+
true
32+
33+
See Also
34+
--------
35+
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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+
/**
22+
* Tests if two arguments are both array-like objects and have the same values.
23+
*
24+
* ## Notes
25+
*
26+
* - The function differs from the `===` operator in that the function treats `-0` and `+0` as distinct and `NaNs` as the same.
27+
*
28+
* @param v1 - first input value
29+
* @param v2 - second input value
30+
* @returns boolean indicating whether two arguments are the same
31+
*
32+
* @example
33+
* var x = [ 1.0, 2.0, 3.0 ];
34+
* var y = [ 1.0, 2.0, 3.0 ];
35+
*
36+
* var out = isSameArrayLikeObject( x, y );
37+
* // returns true
38+
*
39+
* @example
40+
* var x = [ 1.0, 2.0, 3.0 ];
41+
* var y = [ 1.0, 2.0, 4.0 ];
42+
*
43+
* var out = isSameArrayLikeObject( x, y );
44+
* // returns false
45+
*/
46+
declare function isSameArrayLikeObject( v1: any, v2: any ): boolean;
47+
48+
49+
// EXPORTS //
50+
51+
export = isSameArrayLikeObject;
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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 isSameArrayLikeObject = require( './index' );
20+
21+
22+
// TESTS //
23+
24+
// The function returns a boolean...
25+
{
26+
isSameArrayLikeObject( 3.14, 3.14 ); // $ExpectType boolean
27+
isSameArrayLikeObject( null, null ); // $ExpectType boolean
28+
isSameArrayLikeObject( 'beep', 'boop' ); // $ExpectType boolean
29+
}
30+
31+
// The compiler throws an error if the function is provided an unsupported number of arguments...
32+
{
33+
isSameArrayLikeObject(); // $ExpectError
34+
isSameArrayLikeObject( 3.14 ); // $ExpectError
35+
isSameArrayLikeObject( 'beep', 'beep', 3.14 ); // $ExpectError
36+
}

0 commit comments

Comments
 (0)