Skip to content

Commit d727f87

Browse files
committed
Auto-generated commit
1 parent c5bde22 commit d727f87

File tree

14 files changed

+643
-1
lines changed

14 files changed

+643
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
55
<section class="release" id="unreleased">
66

7-
## Unreleased (2025-06-17)
7+
## Unreleased (2025-06-23)
88

99
<section class="features">
1010

1111
### Features
1212

13+
- [`0ba0d91`](https://github.com/stdlib-js/stdlib/commit/0ba0d912c0608c3fa8daff70874c9fa8de672a3a) - add `isStructConstructorLike` to namespace
14+
- [`67b59c6`](https://github.com/stdlib-js/stdlib/commit/67b59c6d61abd31bc0fa7fadc673a0dbfb02d387) - add `assert/is-struct-constructor-like`
1315
- [`f58120f`](https://github.com/stdlib-js/stdlib/commit/f58120f6a16840c817e26f439224a67e1680e21c) - add header for asserting is a Node-API value is a DataView
1416
- [`393b4e1`](https://github.com/stdlib-js/stdlib/commit/393b4e118d8152c99490be25c1953f48afc64087) - add `assert/napi/is-dataview`
1517
- [`25231ce`](https://github.com/stdlib-js/stdlib/commit/25231ce28c32227f3514a468dd6b9b2ca494e53b) - add `isEqualUint8ClampedArray` to namespace
@@ -105,6 +107,8 @@ A total of 6 issues were closed in this release:
105107

106108
<details>
107109

110+
- [`0ba0d91`](https://github.com/stdlib-js/stdlib/commit/0ba0d912c0608c3fa8daff70874c9fa8de672a3a) - **feat:** add `isStructConstructorLike` to namespace _(by Athan Reines)_
111+
- [`67b59c6`](https://github.com/stdlib-js/stdlib/commit/67b59c6d61abd31bc0fa7fadc673a0dbfb02d387) - **feat:** add `assert/is-struct-constructor-like` _(by Athan Reines)_
108112
- [`f58120f`](https://github.com/stdlib-js/stdlib/commit/f58120f6a16840c817e26f439224a67e1680e21c) - **feat:** add header for asserting is a Node-API value is a DataView _(by Athan Reines)_
109113
- [`393b4e1`](https://github.com/stdlib-js/stdlib/commit/393b4e118d8152c99490be25c1953f48afc64087) - **feat:** add `assert/napi/is-dataview` _(by Athan Reines)_
110114
- [`d40eeed`](https://github.com/stdlib-js/stdlib/commit/d40eeedd3e34280593e10be51238e0d80cf2a7cf) - **chore:** fix EditorConfig lint errors [(#7205)](https://github.com/stdlib-js/stdlib/pull/7205) _(by Deepak Singh)_

CONTRIBUTORS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Bryan Elee <rxbryn@gmail.com>
3737
Chinmay Joshi <86140365+JawHawk@users.noreply.github.com>
3838
Christopher Dambamuromo <chridam@gmail.com>
3939
Dan Rose <danoftheroses@gmail.com>
40+
Daniel Hernandez Gomez <156333015+dhernandeez13@users.noreply.github.com>
4041
Daniel Killenberger <daniel.killenberger@gmail.com>
4142
Daniel Yu <40680511+Daniel777y@users.noreply.github.com>
4243
Debashis Maharana <debashismaharana7854@gmail.com>
@@ -63,6 +64,7 @@ Girish Garg <garggirish2020@gmail.com>
6364
Golden Kumar <103646877+AuenKr@users.noreply.github.com>
6465
Gunj Joshi <gunjjoshi8372@gmail.com>
6566
Gururaj Gurram <gururajgurram1512@gmail.com>
67+
Harishchandra Reddy <harish.7000@gmail.com>
6668
Haroon Rasheed <51189276+haroon26@users.noreply.github.com>
6769
Harsh <harshyadav6078@gmail.com>
6870
HarshaNP <96897754+GittyHarsha@users.noreply.github.com>
@@ -201,6 +203,7 @@ ditsu <170345142+ditsus@users.noreply.github.com>
201203
ekambains <bainsinbusiness@gmail.com>
202204
fadiothman22 <48636283+fadiothman22@users.noreply.github.com>
203205
iraandrushko <71790513+iraandrushko@users.noreply.github.com>
206+
jsai28 <54253219+jsai28@users.noreply.github.com>
204207
lohithganni <116790357+lohithganni@users.noreply.github.com>
205208
olenkabilonizhka <62379231+olenkabilonizhka@users.noreply.github.com>
206209
pranav-1720 <123018993+pranav-1720@users.noreply.github.com>
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
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+
# isStructConstructorLike
22+
23+
> Test if a value is [struct constructor][@stdlib/dstructs/struct]-like.
24+
25+
<section class="usage">
26+
27+
## Usage
28+
29+
```javascript
30+
var isStructConstructorLike = require( '@stdlib/assert/is-struct-constructor-like' );
31+
```
32+
33+
#### isStructConstructorLike( value )
34+
35+
Tests if a value is [struct constructor][@stdlib/dstructs/struct]-like.
36+
37+
```javascript
38+
var structFactory = require( '@stdlib/dstructs/struct' );
39+
40+
var schema = [
41+
{
42+
'name': 'value',
43+
'type': 'float64'
44+
}
45+
];
46+
var Struct = structFactory( schema );
47+
48+
var bool = isStructConstructorLike( Struct );
49+
// returns true
50+
```
51+
52+
</section>
53+
54+
<!-- /.usage -->
55+
56+
<section class="examples">
57+
58+
## Examples
59+
60+
<!-- eslint no-undef: "error" -->
61+
62+
```javascript
63+
var structFactory = require( '@stdlib/dstructs/struct' );
64+
var isStructConstructorLike = require( '@stdlib/assert/is-struct-constructor-like' );
65+
66+
var schema = [
67+
{
68+
'name': 'value',
69+
'type': 'float64'
70+
}
71+
];
72+
73+
var bool = isStructConstructorLike( structFactory( schema ) );
74+
// returns true
75+
76+
bool = isStructConstructorLike( [ 1, 2, 3, 4 ] );
77+
// returns false
78+
79+
bool = isStructConstructorLike( {} );
80+
// returns false
81+
82+
bool = isStructConstructorLike( null );
83+
// returns false
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/dstructs/struct]: https://github.com/stdlib-js/dstructs-struct
103+
104+
</section>
105+
106+
<!-- /.links -->
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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 isBoolean = require( './../../is-boolean' ).isPrimitive;
25+
var Float64Results = require( '@stdlib/stats/base/ztest/one-sample/results/float64' );
26+
var pkg = require( './../package.json' ).name;
27+
var isStructConstructorLike = require( './../lib' );
28+
29+
30+
// MAIN //
31+
32+
bench( pkg+'::true', function benchmark( b ) {
33+
var values;
34+
var bool;
35+
var i;
36+
37+
values = [
38+
Float64Results,
39+
Float64Results
40+
];
41+
42+
b.tic();
43+
for ( i = 0; i < b.iterations; i++ ) {
44+
bool = isStructConstructorLike( values[ i%values.length ] );
45+
if ( typeof bool !== 'boolean' ) {
46+
b.fail( 'should return a boolean' );
47+
}
48+
}
49+
b.toc();
50+
if ( !isBoolean( bool ) ) {
51+
b.fail( 'should return a boolean' );
52+
}
53+
b.pass( 'benchmark finished' );
54+
b.end();
55+
});
56+
57+
bench( pkg+'::false', function benchmark( b ) {
58+
var values;
59+
var bool;
60+
var i;
61+
62+
values = [
63+
[ 1, 2, 3 ],
64+
{},
65+
null,
66+
5,
67+
'beep'
68+
];
69+
70+
b.tic();
71+
for ( i = 0; i < b.iterations; i++ ) {
72+
bool = isStructConstructorLike( values[ i%values.length ] );
73+
if ( typeof bool !== 'boolean' ) {
74+
b.fail( 'should return a boolean' );
75+
}
76+
}
77+
b.toc();
78+
if ( !isBoolean( bool ) ) {
79+
b.fail( 'should return a boolean' );
80+
}
81+
b.pass( 'benchmark finished' );
82+
b.end();
83+
});
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
{{alias}}( value )
3+
Tests if a value is struct constructor-like.
4+
5+
Parameters
6+
----------
7+
value: any
8+
Value to test.
9+
10+
Returns
11+
-------
12+
bool: boolean
13+
Boolean indicating whether a value is struct constructor-like.
14+
15+
Examples
16+
--------
17+
> var schema = [ { 'name': 'foo', 'type': 'float64' } ];
18+
> var S = {{alias:@stdlib/dstructs/struct}}( schema );
19+
> var bool = {{alias}}( S )
20+
true
21+
> bool = {{alias}}( [ 1, 2, 3, 4 ] )
22+
false
23+
> bool = {{alias}}( 3.14 )
24+
false
25+
> bool = {{alias}}( {} )
26+
false
27+
28+
See Also
29+
--------
30+
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
/**
22+
* Tests if a value is struct constructor-like.
23+
*
24+
* @param v - value to test
25+
* @returns boolean indicating if a value is struct constructor-like
26+
*
27+
* @example
28+
* var structFactory = require( '@stdlib/dstructs/struct' );
29+
*
30+
* var schema = [
31+
* {
32+
* 'name': 'foo',
33+
* 'type': 'float64'
34+
* }
35+
* ];
36+
* var Struct = structFactory( schema );
37+
*
38+
* var bool = isStructConstructorLike( Struct );
39+
* // returns true
40+
*
41+
* bool = isStructConstructorLike( [] );
42+
* // returns false
43+
*/
44+
declare function isStructConstructorLike( v: any ): boolean;
45+
46+
47+
// EXPORTS //
48+
49+
export = isStructConstructorLike;
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
import isStructConstructorLike = require( './index' );
20+
21+
22+
// TESTS //
23+
24+
// The function returns a boolean...
25+
{
26+
isStructConstructorLike( {} ); // $ExpectType boolean
27+
isStructConstructorLike( [] ); // $ExpectType boolean
28+
}
29+
30+
// The compiler throws an error if the function is provided an unsupported number of arguments...
31+
{
32+
isStructConstructorLike(); // $ExpectError
33+
isStructConstructorLike( {}, 123 ); // $ExpectError
34+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
var structFactory = require( '@stdlib/dstructs/struct' );
22+
var isStructConstructorLike = require( './../lib' );
23+
24+
var schema = [
25+
{
26+
'name': 'value',
27+
'type': 'float64'
28+
}
29+
];
30+
31+
console.log( isStructConstructorLike( structFactory( schema ) ) );
32+
// => true
33+
34+
console.log( isStructConstructorLike( [ 1, 2, 3, 4 ] ) );
35+
// => false
36+
37+
console.log( isStructConstructorLike( {} ) );
38+
// => false
39+
40+
console.log( isStructConstructorLike( null ) );
41+
// => false

0 commit comments

Comments
 (0)