From 32852334cd1db6488fb57ef078c0c53f632f435b Mon Sep 17 00:00:00 2001 From: abhishekblue Date: Tue, 25 Feb 2025 23:50:10 +0530 Subject: [PATCH 1/8] feat(assert): Add @stdlib/assert/has-same-constructor --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- .../assert/has-same-constructor/README.md | 155 ++++++++++++++++++ .../benchmark/benchmark.js | 66 ++++++++ .../assert/has-same-constructor/docs/repl.txt | 28 ++++ .../docs/types/index.d.ts | 46 ++++++ .../has-same-constructor/docs/types/test.ts | 34 ++++ .../has-same-constructor/examples/index.js | 63 +++++++ .../assert/has-same-constructor/lib/index.js | 55 +++++++ .../assert/has-same-constructor/lib/main.js | 60 +++++++ .../assert/has-same-constructor/package.json | 65 ++++++++ .../assert/has-same-constructor/test/test.js | 136 +++++++++++++++ 10 files changed, 708 insertions(+) create mode 100644 lib/node_modules/@stdlib/assert/has-same-constructor/README.md create mode 100644 lib/node_modules/@stdlib/assert/has-same-constructor/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/assert/has-same-constructor/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/assert/has-same-constructor/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/assert/has-same-constructor/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/assert/has-same-constructor/examples/index.js create mode 100644 lib/node_modules/@stdlib/assert/has-same-constructor/lib/index.js create mode 100644 lib/node_modules/@stdlib/assert/has-same-constructor/lib/main.js create mode 100644 lib/node_modules/@stdlib/assert/has-same-constructor/package.json create mode 100644 lib/node_modules/@stdlib/assert/has-same-constructor/test/test.js diff --git a/lib/node_modules/@stdlib/assert/has-same-constructor/README.md b/lib/node_modules/@stdlib/assert/has-same-constructor/README.md new file mode 100644 index 000000000000..40b76661c59d --- /dev/null +++ b/lib/node_modules/@stdlib/assert/has-same-constructor/README.md @@ -0,0 +1,155 @@ + + +# hasSameConstructor + +> Tests if two values have the same constructor. + +
+ +## Usage + +```javascript +var hasSameConstructor = require( '@stdlib/assert/has-same-constructor' ) +``` + +#### hasSameConstructor( x, y ) + +Returns a `boolean` indicating whether two given values has same contructor function. + +```javascript +var x = new Number(5); +var y = new Number(10); +var bool = hasSameConstructor( x, y ); +// returns true + +var x = new Number(5); +var y = []; +var bool = hasSameConstructor( x, y ); +// returns false + +var x = []; +var y = []; +var bool = hasSameConstructor( x, y ); +// returns true +``` + +
+ + + +
+ +## Notes + +- The function does **not** throw when provided `null` or `undefined`. Instead, the function returns `false`. + + ```javascript + var bool = hasSameConstructor(null, 5); + // returns false + + var bool = hasSameConstructor(void 0, 5); + // returns false + ``` + +- Value arguments other than `null` or `undefined` are coerced to `objects`(e.g., “Primitives like `5` or `'hello'` are autoboxed to objects, such as `new Number(5)` or `new String('hello')`, for constructor checking”). + + ```javascript + var bool = hasSameConstructor( 'beep', 'length' ); + // returns true + ``` + +
+ + + +
+ +## Examples + + + + + +```javascript +var hasSameConstructor = require( '@stdlib/assert/has-same-constructor' ); + +var bool = hasSameConstructor( [1, 2, 3], ['a', 'b', 'c'] ); +// returns true + +bool = hasSameConstructor( [1, 2, 3], { key: 'value' } ); +// returns false + +bool = hasSameConstructor( { name: 'Alice' }, { age: 30 } ); +// returns true + +bool = hasSameConstructor( { name: 'Alice' }, new Date() ); +// returns false + +bool = hasSameConstructor( new Date(), new Date() ); +// returns true + +bool = hasSameConstructor( null, { name: 'Alice' } ); +// returns false + +bool = hasSameConstructor( undefined, [1, 2, 3] ); +// returns false + +bool = hasSameConstructor( 42, 3.14 ); +// returns true + +bool = hasSameConstructor( 42, 'Hello' ); +// returns false + +bool = hasSameConstructor( function() {}, () => {} ); +// returns true +``` + +
+ + + + + + + + + + + + + + \ No newline at end of file diff --git a/lib/node_modules/@stdlib/assert/has-same-constructor/benchmark/benchmark.js b/lib/node_modules/@stdlib/assert/has-same-constructor/benchmark/benchmark.js new file mode 100644 index 000000000000..213ac5cef831 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/has-same-constructor/benchmark/benchmark.js @@ -0,0 +1,66 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable no-empty-function */ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pkg = require( './../package.json' ).name; +var hasSameConstructor = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var values; + var bool; + var i; + + values = [ + '5', + 5, + NaN, + true, + false, + null, + void 0, + [], + {}, + new Date(), + function noop() {} + ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + bool = hasSameConstructor( values[ i % values.length ], values[ (i+1) % values.length ] ); + if ( typeof bool !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + + if ( !isBoolean( bool ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); \ No newline at end of file diff --git a/lib/node_modules/@stdlib/assert/has-same-constructor/docs/repl.txt b/lib/node_modules/@stdlib/assert/has-same-constructor/docs/repl.txt new file mode 100644 index 000000000000..a3cd8b5022f5 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/has-same-constructor/docs/repl.txt @@ -0,0 +1,28 @@ + +{{alias}}( x, y ) + Tests if two values have the same constructor. + + Parameters + ---------- + a: any + First input value. + + b: any + Second input value. + + Returns + ------- + bool: boolean + Boolean indicating whether two values have same constructor. + + Examples + -------- + > var bool = {{alias}}( new Date(), new Date() ); + true + > bool = {{alias}}( new Date(), 'Hello'); + false + > bool = {{alias}}(new String('Hello'), 'World'); + true + + See Also + -------- \ No newline at end of file diff --git a/lib/node_modules/@stdlib/assert/has-same-constructor/docs/types/index.d.ts b/lib/node_modules/@stdlib/assert/has-same-constructor/docs/types/index.d.ts new file mode 100644 index 000000000000..af159b58e203 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/has-same-constructor/docs/types/index.d.ts @@ -0,0 +1,46 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2019 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/** +* Test whether two provided values have the same constructor. +* +* @param x - first input value +* @param y - second input value +* @returns boolean indicating whether two arguments have the same constructor +* +* @example +* var bool = hasSameConstructor(new Date(), new Date()); +* // returns true +* +* @example +* var bool = hasSameConstructor("Hello", new Date()); +* // returns false +* +* @example +* var bool = hasSameConstructor(new String("Hello"), "World"); +* // returns true +*/ + +declare function hasSameConstructor(x: any, y: any): boolean; + + +// EXPORTS // + +export = hasSameConstructor; \ No newline at end of file diff --git a/lib/node_modules/@stdlib/assert/has-same-constructor/docs/types/test.ts b/lib/node_modules/@stdlib/assert/has-same-constructor/docs/types/test.ts new file mode 100644 index 000000000000..cb52531bdfcd --- /dev/null +++ b/lib/node_modules/@stdlib/assert/has-same-constructor/docs/types/test.ts @@ -0,0 +1,34 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2019 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import hasSameConstructor = require( './index' ); + + +// TESTS // + +// The function returns a boolean... +{ + hasSameConstructor( new Date(), new String('Hello' ) ); // $ExpectType boolean + hasSameConstructor( new String('Hello'), 'World' ); // $ExpectType boolean +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + hasSameConstructor(); // $ExpectError + hasSameConstructor( new Date(), new Date(), new Date() ); // $ExpectError +} \ No newline at end of file diff --git a/lib/node_modules/@stdlib/assert/has-same-constructor/examples/index.js b/lib/node_modules/@stdlib/assert/has-same-constructor/examples/index.js new file mode 100644 index 000000000000..08ebf8d025ae --- /dev/null +++ b/lib/node_modules/@stdlib/assert/has-same-constructor/examples/index.js @@ -0,0 +1,63 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable object-curly-newline, no-empty-function, no-restricted-syntax */ + +'use strict'; + +var hasSameConstructor = require( "../lib" ); + +var bool = hasSameConstructor( [1, 2, 3], ['a', 'b', 'c'] ); +console.log( bool ); +// => true + +bool = hasSameConstructor( [1, 2, 3], { key: 'value' } ); +console.log( bool ); +// => false + +bool = hasSameConstructor( { name: 'Alice' }, { age: 30 } ); +console.log( bool ); +// => true + +bool = hasSameConstructor( { name: 'Alice' }, new Date() ); +console.log( bool ); +// => false + +bool = hasSameConstructor( new Date(), new Date() ); +console.log( bool ); +// => true + +bool = hasSameConstructor( null, { name: 'Alice' } ); +console.log( bool ); +// => false + +bool = hasSameConstructor( undefined, [1, 2, 3] ); +console.log( bool ); +// => false + +bool = hasSameConstructor( 42, 3.14 ); +console.log( bool ); +// => true + +bool = hasSameConstructor( 42, 'Hello' ); +console.log( bool ); +// => false + +bool = hasSameConstructor( function() {}, () => {} ); +console.log( bool ); +// => true diff --git a/lib/node_modules/@stdlib/assert/has-same-constructor/lib/index.js b/lib/node_modules/@stdlib/assert/has-same-constructor/lib/index.js new file mode 100644 index 000000000000..c0dd76fda180 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/has-same-constructor/lib/index.js @@ -0,0 +1,55 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Test whether an object has a specified property, either own or inherited. +* +* @module @stdlib/assert/has-same-constructor +* +* @example +* var hasSameConstructor = require( '@stdlib/assert/has-same-constructor' ); +* +* @example +* var x = new Number(5); +* var y = new Number(10); +* var bool = hasSameConstructor( x, y ); +* // returns true +* +* @example +* var x = new Number(5); +* var y = []; +* var bool = hasSameConstructor( x, y ); +* // returns false +* +* @example +* var x = []; +* var y = []; +* var bool = hasSameConstructor( x, y ); +* // returns true +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/assert/has-same-constructor/lib/main.js b/lib/node_modules/@stdlib/assert/has-same-constructor/lib/main.js new file mode 100644 index 000000000000..85906d85c697 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/has-same-constructor/lib/main.js @@ -0,0 +1,60 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MAIN // + +/** +* Tests if two objects has same contructor function. +* +* @param {*} x - first input value +* @param {*} y - second input value +* @returns {boolean} boolean indicating whether two arguments have the same native class +* +* @example +* var x = new Number(5); +* var y = new Number(10); +* var bool = hasSameConstructor( x, y ); +* // returns true +* +* @example +* var x = new Number(5); +* var y = []; +* var bool = hasSameConstructor( x, y ); +* // returns false +* +* @example +* var x = []; +* var y = []; +* var bool = hasSameConstructor( x, y ); +* // returns true +* +*/ + +function hasSameConstructor( x, y ) { + if ( !x || !y ) { + return false; + } + return x.constructor === y.constructor; +} + + +// EXPORTS // + +module.exports = hasSameConstructor; \ No newline at end of file diff --git a/lib/node_modules/@stdlib/assert/has-same-constructor/package.json b/lib/node_modules/@stdlib/assert/has-same-constructor/package.json new file mode 100644 index 000000000000..7ebe5be0560a --- /dev/null +++ b/lib/node_modules/@stdlib/assert/has-same-constructor/package.json @@ -0,0 +1,65 @@ +{ + "name": "@stdlib/assert/has-same-constructor", + "version": "0.0.0", + "description": "Check if two values have the same constructor.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "https://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdassert", + "assertion", + "assert", + "utilities", + "utility", + "utils", + "util", + "object", + "obj", + "has", + "hasown", + "hasownproperty", + "property", + "prop", + "test", + "check", + "validate" + ] +} diff --git a/lib/node_modules/@stdlib/assert/has-same-constructor/test/test.js b/lib/node_modules/@stdlib/assert/has-same-constructor/test/test.js new file mode 100644 index 000000000000..598c9a528f32 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/has-same-constructor/test/test.js @@ -0,0 +1,136 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable object-curly-newline */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasSameConstructor = require( './../lib' ) + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof hasSameConstructor, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'compare two null values', function test( t ) { + var bool; + + bool = hasSameConstructor( null, null ) + t.strictEqual( bool, false, 'returns false for null and null' ) + + t.end() +}) + +tape( 'compare two Number objects', function test( t ) { + var bool; + + bool = hasSameConstructor( new Number(5), new Number(10) ); + t.strictEqual( bool, true, 'returns true for matching Number objects' ); + + t.end(); +}); + +tape( 'compare two Arrays', function test( t ) { + var bool; + + bool = hasSameConstructor( [], [] ); + t.strictEqual( bool, true, 'returns true for matching Arrays' ); + + t.end(); +}); + +tape( 'compare Number and Array', function test(t) { + var bool; + + bool = hasSameConstructor( new Number(5), [] ); + t.strictEqual( bool, false, 'returns false for different constructors' ); + + t.end(); +}); + +tape( 'compare two null values', function test( t ) { + var bool; + + bool = hasSameConstructor( null, null ); + t.strictEqual( bool, false, 'returns false for null and null' ); + + t.end(); +}); + +tape( 'compare two undefined values', function test( t ) { + var bool; + + bool = hasSameConstructor( undefined, undefined ); + t.strictEqual( bool, false, 'returns false for undefined and undefined' ); + + t.end(); +}); + +tape( 'compare null and Number object', function test( t ) { + var bool; + + bool = hasSameConstructor( null, new Number(5) ); + t.strictEqual( bool, false, 'returns false for null and Number object' ); + + t.end(); +}); + +tape( 'compare undefined and Array', function test( t ) { + var bool; + + bool = hasSameConstructor( undefined, [] ); + t.strictEqual( bool, false, 'returns false for undefined and Array' ); + + t.end(); +}); + +tape( 'compare two number primitives', function test( t ) { + var bool; + + bool = hasSameConstructor( 5, 5 ); + t.strictEqual( bool, true, 'returns true for matching number primitives' ); + + t.end(); +}); + +tape( 'compare number and string primitives', function test( t ) { + var bool; + + bool = hasSameConstructor( 5, 'hello' ); + t.strictEqual( bool, false, 'returns false for different primitive types' ); + + t.end(); +}); + +tape( 'compare number primitive and Number object', function test( t ) { + var bool; + + bool = hasSameConstructor( 5, new Number( 5 ) ); + t.strictEqual( bool, true, 'returns true for matching number primitive and object' ); + + t.end(); +}); + + From 62cb3da0a718db25181d3e0bd598f10ffecd9941 Mon Sep 17 00:00:00 2001 From: abhishekblue Date: Wed, 26 Feb 2025 00:27:21 +0530 Subject: [PATCH 2/8] fix(assert): update README formatting and examples for #815 --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: passed - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: failed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: passed - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: failed --- --- .../assert/has-same-constructor/README.md | 18 +++++++++--------- .../benchmark/benchmark.js | 2 +- .../has-same-constructor/docs/types/index.d.ts | 10 +++++----- .../has-same-constructor/docs/types/test.ts | 2 +- .../has-same-constructor/examples/index.js | 2 +- .../assert/has-same-constructor/lib/index.js | 2 +- .../assert/has-same-constructor/lib/main.js | 2 +- .../assert/has-same-constructor/test/test.js | 2 +- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/node_modules/@stdlib/assert/has-same-constructor/README.md b/lib/node_modules/@stdlib/assert/has-same-constructor/README.md index 40b76661c59d..5b6ec041d539 100644 --- a/lib/node_modules/@stdlib/assert/has-same-constructor/README.md +++ b/lib/node_modules/@stdlib/assert/has-same-constructor/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2018 The Stdlib Authors. +Copyright (c) 2025 The Stdlib Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ limitations under the License. ## Usage ```javascript -var hasSameConstructor = require( '@stdlib/assert/has-same-constructor' ) +var hasSameConstructor = require( '@stdlib/assert/has-same-constructor' ); ``` #### hasSameConstructor( x, y ) @@ -40,14 +40,14 @@ var y = new Number(10); var bool = hasSameConstructor( x, y ); // returns true -var x = new Number(5); -var y = []; -var bool = hasSameConstructor( x, y ); +x = new Number(5); +y = []; +bool = hasSameConstructor( x, y ); // returns false -var x = []; -var y = []; -var bool = hasSameConstructor( x, y ); +x = []; +y = []; +bool = hasSameConstructor( x, y ); // returns true ``` @@ -65,7 +65,7 @@ var bool = hasSameConstructor( x, y ); var bool = hasSameConstructor(null, 5); // returns false - var bool = hasSameConstructor(void 0, 5); + bool = hasSameConstructor(void 0, 5); // returns false ``` diff --git a/lib/node_modules/@stdlib/assert/has-same-constructor/benchmark/benchmark.js b/lib/node_modules/@stdlib/assert/has-same-constructor/benchmark/benchmark.js index 213ac5cef831..285f136748b5 100644 --- a/lib/node_modules/@stdlib/assert/has-same-constructor/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/assert/has-same-constructor/benchmark/benchmark.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/assert/has-same-constructor/docs/types/index.d.ts b/lib/node_modules/@stdlib/assert/has-same-constructor/docs/types/index.d.ts index af159b58e203..5f946a2e4ee4 100644 --- a/lib/node_modules/@stdlib/assert/has-same-constructor/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/assert/has-same-constructor/docs/types/index.d.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2019 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,11 +24,11 @@ * @param x - first input value * @param y - second input value * @returns boolean indicating whether two arguments have the same constructor -* +* * @example * var bool = hasSameConstructor(new Date(), new Date()); * // returns true -* +* * @example * var bool = hasSameConstructor("Hello", new Date()); * // returns false @@ -38,9 +38,9 @@ * // returns true */ -declare function hasSameConstructor(x: any, y: any): boolean; +declare function hasSameConstructor( x: any, y: any ): boolean; // EXPORTS // -export = hasSameConstructor; \ No newline at end of file +export = hasSameConstructor; diff --git a/lib/node_modules/@stdlib/assert/has-same-constructor/docs/types/test.ts b/lib/node_modules/@stdlib/assert/has-same-constructor/docs/types/test.ts index cb52531bdfcd..139f789aac09 100644 --- a/lib/node_modules/@stdlib/assert/has-same-constructor/docs/types/test.ts +++ b/lib/node_modules/@stdlib/assert/has-same-constructor/docs/types/test.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2019 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/assert/has-same-constructor/examples/index.js b/lib/node_modules/@stdlib/assert/has-same-constructor/examples/index.js index 08ebf8d025ae..c76712764bca 100644 --- a/lib/node_modules/@stdlib/assert/has-same-constructor/examples/index.js +++ b/lib/node_modules/@stdlib/assert/has-same-constructor/examples/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/assert/has-same-constructor/lib/index.js b/lib/node_modules/@stdlib/assert/has-same-constructor/lib/index.js index c0dd76fda180..ed3f27081c35 100644 --- a/lib/node_modules/@stdlib/assert/has-same-constructor/lib/index.js +++ b/lib/node_modules/@stdlib/assert/has-same-constructor/lib/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/assert/has-same-constructor/lib/main.js b/lib/node_modules/@stdlib/assert/has-same-constructor/lib/main.js index 85906d85c697..57546051f7fc 100644 --- a/lib/node_modules/@stdlib/assert/has-same-constructor/lib/main.js +++ b/lib/node_modules/@stdlib/assert/has-same-constructor/lib/main.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/assert/has-same-constructor/test/test.js b/lib/node_modules/@stdlib/assert/has-same-constructor/test/test.js index 598c9a528f32..0a4f274a97d8 100644 --- a/lib/node_modules/@stdlib/assert/has-same-constructor/test/test.js +++ b/lib/node_modules/@stdlib/assert/has-same-constructor/test/test.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 81737cd0b0b958150ab00117bdaf4e0ccf6c03df Mon Sep 17 00:00:00 2001 From: abhishekblue Date: Wed, 26 Feb 2025 00:57:28 +0530 Subject: [PATCH 3/8] style(assert): fix lint errors in has-same-constructor --- .../assert/has-same-constructor/README.md | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/lib/node_modules/@stdlib/assert/has-same-constructor/README.md b/lib/node_modules/@stdlib/assert/has-same-constructor/README.md index 5b6ec041d539..91f1ba5e298e 100644 --- a/lib/node_modules/@stdlib/assert/has-same-constructor/README.md +++ b/lib/node_modules/@stdlib/assert/has-same-constructor/README.md @@ -35,12 +35,12 @@ var hasSameConstructor = require( '@stdlib/assert/has-same-constructor' ); Returns a `boolean` indicating whether two given values has same contructor function. ```javascript -var x = new Number(5); -var y = new Number(10); +var x = 5 +var y = 10; var bool = hasSameConstructor( x, y ); // returns true -x = new Number(5); +x = 5; y = []; bool = hasSameConstructor( x, y ); // returns false @@ -69,7 +69,7 @@ bool = hasSameConstructor( x, y ); // returns false ``` -- Value arguments other than `null` or `undefined` are coerced to `objects`(e.g., “Primitives like `5` or `'hello'` are autoboxed to objects, such as `new Number(5)` or `new String('hello')`, for constructor checking”). +- Value arguments other than `null` or `undefined` are coerced to `objects`. ```javascript var bool = hasSameConstructor( 'beep', 'length' ); @@ -94,19 +94,19 @@ var hasSameConstructor = require( '@stdlib/assert/has-same-constructor' ); var bool = hasSameConstructor( [1, 2, 3], ['a', 'b', 'c'] ); // returns true -bool = hasSameConstructor( [1, 2, 3], { key: 'value' } ); +bool = hasSameConstructor( [1, 2, 3], { 'key': 'value' } ); // returns false -bool = hasSameConstructor( { name: 'Alice' }, { age: 30 } ); +bool = hasSameConstructor({ 'name': 'Alice' }, { 'age': 30 }); // returns true -bool = hasSameConstructor( { name: 'Alice' }, new Date() ); +bool = hasSameConstructor( { 'name': 'Alice' }, new Date() ); // returns false bool = hasSameConstructor( new Date(), new Date() ); // returns true -bool = hasSameConstructor( null, { name: 'Alice' } ); +bool = hasSameConstructor( null, { 'name': 'Alice' } ); // returns false bool = hasSameConstructor( undefined, [1, 2, 3] ); @@ -117,9 +117,6 @@ bool = hasSameConstructor( 42, 3.14 ); bool = hasSameConstructor( 42, 'Hello' ); // returns false - -bool = hasSameConstructor( function() {}, () => {} ); -// returns true ``` @@ -152,4 +149,4 @@ bool = hasSameConstructor( function() {}, () => {} ); - \ No newline at end of file + From 6cad99bc43ce8fe34a66545ee6ccf66a63225b43 Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Wed, 26 Feb 2025 19:08:14 +0000 Subject: [PATCH 4/8] fix: resolve lint errors --- .../assert/has-same-constructor/README.md | 8 -- .../benchmark/benchmark.js | 2 +- .../has-same-constructor/docs/types/test.ts | 2 +- .../has-same-constructor/examples/index.js | 12 +- .../assert/has-same-constructor/lib/main.js | 2 +- .../assert/has-same-constructor/test/test.js | 134 +++++++++--------- 6 files changed, 74 insertions(+), 86 deletions(-) diff --git a/lib/node_modules/@stdlib/assert/has-same-constructor/README.md b/lib/node_modules/@stdlib/assert/has-same-constructor/README.md index 91f1ba5e298e..ae15fe5b8f64 100644 --- a/lib/node_modules/@stdlib/assert/has-same-constructor/README.md +++ b/lib/node_modules/@stdlib/assert/has-same-constructor/README.md @@ -127,12 +127,6 @@ bool = hasSameConstructor( 42, 'Hello' ); @@ -143,8 +137,6 @@ bool = hasSameConstructor( 42, 'Hello' ); -[@stdlib/assert/has-same-constructor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/has-same-constructor - diff --git a/lib/node_modules/@stdlib/assert/has-same-constructor/benchmark/benchmark.js b/lib/node_modules/@stdlib/assert/has-same-constructor/benchmark/benchmark.js index 285f136748b5..60c0a7b4d374 100644 --- a/lib/node_modules/@stdlib/assert/has-same-constructor/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/assert/has-same-constructor/benchmark/benchmark.js @@ -63,4 +63,4 @@ bench( pkg, function benchmark( b ) { } b.pass( 'benchmark finished' ); b.end(); -}); \ No newline at end of file +}); diff --git a/lib/node_modules/@stdlib/assert/has-same-constructor/docs/types/test.ts b/lib/node_modules/@stdlib/assert/has-same-constructor/docs/types/test.ts index 139f789aac09..14bf7ed72c37 100644 --- a/lib/node_modules/@stdlib/assert/has-same-constructor/docs/types/test.ts +++ b/lib/node_modules/@stdlib/assert/has-same-constructor/docs/types/test.ts @@ -31,4 +31,4 @@ import hasSameConstructor = require( './index' ); { hasSameConstructor(); // $ExpectError hasSameConstructor( new Date(), new Date(), new Date() ); // $ExpectError -} \ No newline at end of file +} diff --git a/lib/node_modules/@stdlib/assert/has-same-constructor/examples/index.js b/lib/node_modules/@stdlib/assert/has-same-constructor/examples/index.js index c76712764bca..7aaf69a98b97 100644 --- a/lib/node_modules/@stdlib/assert/has-same-constructor/examples/index.js +++ b/lib/node_modules/@stdlib/assert/has-same-constructor/examples/index.js @@ -20,21 +20,21 @@ 'use strict'; -var hasSameConstructor = require( "../lib" ); +var hasSameConstructor = require( './' ); var bool = hasSameConstructor( [1, 2, 3], ['a', 'b', 'c'] ); console.log( bool ); // => true -bool = hasSameConstructor( [1, 2, 3], { key: 'value' } ); +bool = hasSameConstructor( [1, 2, 3], { key: 'value' }); console.log( bool ); // => false -bool = hasSameConstructor( { name: 'Alice' }, { age: 30 } ); +bool = hasSameConstructor({ name: 'Alice' }, { age: 30 }); console.log( bool ); // => true -bool = hasSameConstructor( { name: 'Alice' }, new Date() ); +bool = hasSameConstructor({ name: 'Alice' }, new Date() ); console.log( bool ); // => false @@ -42,7 +42,7 @@ bool = hasSameConstructor( new Date(), new Date() ); console.log( bool ); // => true -bool = hasSameConstructor( null, { name: 'Alice' } ); +bool = hasSameConstructor( null, { name: 'Alice' }); console.log( bool ); // => false @@ -58,6 +58,6 @@ bool = hasSameConstructor( 42, 'Hello' ); console.log( bool ); // => false -bool = hasSameConstructor( function() {}, () => {} ); +bool = hasSameConstructor( function () {}, () => {} ); console.log( bool ); // => true diff --git a/lib/node_modules/@stdlib/assert/has-same-constructor/lib/main.js b/lib/node_modules/@stdlib/assert/has-same-constructor/lib/main.js index 57546051f7fc..55c023ccfdec 100644 --- a/lib/node_modules/@stdlib/assert/has-same-constructor/lib/main.js +++ b/lib/node_modules/@stdlib/assert/has-same-constructor/lib/main.js @@ -57,4 +57,4 @@ function hasSameConstructor( x, y ) { // EXPORTS // -module.exports = hasSameConstructor; \ No newline at end of file +module.exports = hasSameConstructor; diff --git a/lib/node_modules/@stdlib/assert/has-same-constructor/test/test.js b/lib/node_modules/@stdlib/assert/has-same-constructor/test/test.js index 0a4f274a97d8..bd1752014335 100644 --- a/lib/node_modules/@stdlib/assert/has-same-constructor/test/test.js +++ b/lib/node_modules/@stdlib/assert/has-same-constructor/test/test.js @@ -16,14 +16,12 @@ * limitations under the License. */ -/* eslint-disable object-curly-newline */ - 'use strict'; // MODULES // var tape = require( 'tape' ); -var hasSameConstructor = require( './../lib' ) +var hasSameConstructor = require( './../lib' ); // TESTS // @@ -35,102 +33,100 @@ tape( 'main export is a function', function test( t ) { }); tape( 'compare two null values', function test( t ) { - var bool; + var bool; - bool = hasSameConstructor( null, null ) - t.strictEqual( bool, false, 'returns false for null and null' ) + bool = hasSameConstructor( null, null ); + t.strictEqual( bool, false, 'returns false for null and null' ); - t.end() -}) + t.end(); +}); tape( 'compare two Number objects', function test( t ) { - var bool; - - bool = hasSameConstructor( new Number(5), new Number(10) ); - t.strictEqual( bool, true, 'returns true for matching Number objects' ); - - t.end(); + var bool; + + bool = hasSameConstructor( new Number(5), new Number(10) ); + t.strictEqual( bool, true, 'returns true for matching Number objects' ); + + t.end(); }); tape( 'compare two Arrays', function test( t ) { - var bool; - - bool = hasSameConstructor( [], [] ); - t.strictEqual( bool, true, 'returns true for matching Arrays' ); - - t.end(); + var bool; + + bool = hasSameConstructor( [], [] ); + t.strictEqual( bool, true, 'returns true for matching Arrays' ); + + t.end(); }); tape( 'compare Number and Array', function test(t) { - var bool; - - bool = hasSameConstructor( new Number(5), [] ); - t.strictEqual( bool, false, 'returns false for different constructors' ); - - t.end(); + var bool; + + bool = hasSameConstructor( new Number(5), [] ); + t.strictEqual( bool, false, 'returns false for different constructors' ); + + t.end(); }); tape( 'compare two null values', function test( t ) { - var bool; - - bool = hasSameConstructor( null, null ); - t.strictEqual( bool, false, 'returns false for null and null' ); - - t.end(); + var bool; + + bool = hasSameConstructor( null, null ); + t.strictEqual( bool, false, 'returns false for null and null' ); + + t.end(); }); tape( 'compare two undefined values', function test( t ) { - var bool; - - bool = hasSameConstructor( undefined, undefined ); - t.strictEqual( bool, false, 'returns false for undefined and undefined' ); - - t.end(); + var bool; + + bool = hasSameConstructor( undefined, undefined ); + t.strictEqual( bool, false, 'returns false for undefined and undefined' ); + + t.end(); }); tape( 'compare null and Number object', function test( t ) { - var bool; - - bool = hasSameConstructor( null, new Number(5) ); - t.strictEqual( bool, false, 'returns false for null and Number object' ); - - t.end(); + var bool; + + bool = hasSameConstructor( null, new Number(5) ); + t.strictEqual( bool, false, 'returns false for null and Number object' ); + + t.end(); }); tape( 'compare undefined and Array', function test( t ) { - var bool; - - bool = hasSameConstructor( undefined, [] ); - t.strictEqual( bool, false, 'returns false for undefined and Array' ); - - t.end(); + var bool; + + bool = hasSameConstructor( undefined, [] ); + t.strictEqual( bool, false, 'returns false for undefined and Array' ); + + t.end(); }); tape( 'compare two number primitives', function test( t ) { - var bool; - - bool = hasSameConstructor( 5, 5 ); - t.strictEqual( bool, true, 'returns true for matching number primitives' ); - - t.end(); + var bool; + + bool = hasSameConstructor( 5, 5 ); + t.strictEqual( bool, true, 'returns true for matching number primitives' ); + + t.end(); }); tape( 'compare number and string primitives', function test( t ) { - var bool; - - bool = hasSameConstructor( 5, 'hello' ); - t.strictEqual( bool, false, 'returns false for different primitive types' ); - - t.end(); + var bool; + + bool = hasSameConstructor( 5, 'hello' ); + t.strictEqual( bool, false, 'returns false for different primitive types' ); + + t.end(); }); tape( 'compare number primitive and Number object', function test( t ) { - var bool; - - bool = hasSameConstructor( 5, new Number( 5 ) ); - t.strictEqual( bool, true, 'returns true for matching number primitive and object' ); - - t.end(); -}); + var bool; + bool = hasSameConstructor( 5, new Number( 5 ) ); + t.strictEqual( bool, true, 'returns true for matching number primitive and object' ); + t.end(); +}); From 234f29cc6ae27b6f63ec93f481f44572e6ca315f Mon Sep 17 00:00:00 2001 From: abhishekblue Date: Thu, 27 Feb 2025 03:01:32 +0530 Subject: [PATCH 5/8] made suggested changes in example.js and main.js --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: passed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: failed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: passed --- --- .../assert/has-same-constructor/lib/main.js | 9 +- .../assert/has-same-constructor/test/test.js | 130 +++++------------- lib/node_modules/@stdlib/assert/package.json | 6 +- 3 files changed, 48 insertions(+), 97 deletions(-) diff --git a/lib/node_modules/@stdlib/assert/has-same-constructor/lib/main.js b/lib/node_modules/@stdlib/assert/has-same-constructor/lib/main.js index 55c023ccfdec..5fdc8c8fa980 100644 --- a/lib/node_modules/@stdlib/assert/has-same-constructor/lib/main.js +++ b/lib/node_modules/@stdlib/assert/has-same-constructor/lib/main.js @@ -44,11 +44,16 @@ * var y = []; * var bool = hasSameConstructor( x, y ); * // returns true -* */ +// function hasSameConstructor( x, y ) { +// if ( !x || !y ) { +// return false; +// } +// return x.constructor === y.constructor; +// } function hasSameConstructor( x, y ) { - if ( !x || !y ) { + if (x == null || y == null) { // Check for null or undefined only return false; } return x.constructor === y.constructor; diff --git a/lib/node_modules/@stdlib/assert/has-same-constructor/test/test.js b/lib/node_modules/@stdlib/assert/has-same-constructor/test/test.js index bd1752014335..cc8d3f2a4c77 100644 --- a/lib/node_modules/@stdlib/assert/has-same-constructor/test/test.js +++ b/lib/node_modules/@stdlib/assert/has-same-constructor/test/test.js @@ -32,101 +32,45 @@ tape( 'main export is a function', function test( t ) { t.end(); }); -tape( 'compare two null values', function test( t ) { - var bool; - - bool = hasSameConstructor( null, null ); - t.strictEqual( bool, false, 'returns false for null and null' ); - - t.end(); -}); - -tape( 'compare two Number objects', function test( t ) { - var bool; - - bool = hasSameConstructor( new Number(5), new Number(10) ); - t.strictEqual( bool, true, 'returns true for matching Number objects' ); - - t.end(); -}); - -tape( 'compare two Arrays', function test( t ) { - var bool; - - bool = hasSameConstructor( [], [] ); - t.strictEqual( bool, true, 'returns true for matching Arrays' ); - - t.end(); -}); - -tape( 'compare Number and Array', function test(t) { - var bool; - - bool = hasSameConstructor( new Number(5), [] ); - t.strictEqual( bool, false, 'returns false for different constructors' ); - - t.end(); -}); - -tape( 'compare two null values', function test( t ) { - var bool; - - bool = hasSameConstructor( null, null ); - t.strictEqual( bool, false, 'returns false for null and null' ); - - t.end(); -}); - -tape( 'compare two undefined values', function test( t ) { - var bool; - - bool = hasSameConstructor( undefined, undefined ); - t.strictEqual( bool, false, 'returns false for undefined and undefined' ); - - t.end(); -}); - -tape( 'compare null and Number object', function test( t ) { - var bool; - - bool = hasSameConstructor( null, new Number(5) ); - t.strictEqual( bool, false, 'returns false for null and Number object' ); - - t.end(); -}); - -tape( 'compare undefined and Array', function test( t ) { - var bool; - - bool = hasSameConstructor( undefined, [] ); - t.strictEqual( bool, false, 'returns false for undefined and Array' ); - - t.end(); -}); - -tape( 'compare two number primitives', function test( t ) { - var bool; - - bool = hasSameConstructor( 5, 5 ); - t.strictEqual( bool, true, 'returns true for matching number primitives' ); - - t.end(); +tape( 'the function returns `true` if provided two arguments which have the same constructor', function test ( t ) { + var values; + var bool; + var i; + + values =[ + [ true, false ], + [ 1.0, 3.1 ], + [ new Number( 1.0 ), 3.1 ], + [ new Number( 0.0 ), new Number( 0.0 ) ], + [ new String( 'abc' ), 'abc' ], + [ JSON, Math ], + [ NaN, NaN ], + [ function() {}, () => {} ] + + ]; + + for ( i = 0; i < values.length; i++ ) { + bool = hasSameConstructor( values[ i ][ 0 ], values[ i ][ 1 ] ); + t.strictEqual( bool, true, 'returns true' ); + } + t.end(); }); -tape( 'compare number and string primitives', function test( t ) { +tape( 'the function returns `false` if not provided two arguments having the same constructor', function test( t ) { + var values; var bool; - - bool = hasSameConstructor( 5, 'hello' ); - t.strictEqual( bool, false, 'returns false for different primitive types' ); - - t.end(); -}); - -tape( 'compare number primitive and Number object', function test( t ) { - var bool; - - bool = hasSameConstructor( 5, new Number( 5 ) ); - t.strictEqual( bool, true, 'returns true for matching number primitive and object' ); - + var i; + + values = [ + [ 1.0, '1.0' ], + [ null, null ], + [ [], {} ], + [ null, void 0 ], + ]; + + for ( i = 0; i < values.length; i++ ) { + bool = hasSameConstructor( values[ i ][ 0 ], values[ i ][ 1 ] ); + t.strictEqual( bool, false, 'returns false' ); + } t.end(); }); diff --git a/lib/node_modules/@stdlib/assert/package.json b/lib/node_modules/@stdlib/assert/package.json index 6315d06dcd31..745d14cd6c9d 100644 --- a/lib/node_modules/@stdlib/assert/package.json +++ b/lib/node_modules/@stdlib/assert/package.json @@ -30,8 +30,10 @@ "bugs": { "url": "https://github.com/stdlib-js/stdlib/issues" }, - "dependencies": {}, - "devDependencies": {}, + "dependencies": { + "doctest": "^0.21.0", + "tape": "^5.9.0" + }, "engines": { "node": ">=0.10.0", "npm": ">2.7.0" From b0b581b47d28f9b617be1fe7d2eaa1472720793e Mon Sep 17 00:00:00 2001 From: abhishekblue Date: Thu, 27 Feb 2025 14:01:37 +0530 Subject: [PATCH 6/8] adjust formatting --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: passed - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: failed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: passed - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: failed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: passed - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: failed --- --- lib/node_modules/@stdlib/assert/has-same-constructor/README.md | 2 +- .../@stdlib/assert/has-same-constructor/examples/index.js | 2 +- .../@stdlib/assert/has-same-constructor/lib/index.js | 2 +- .../@stdlib/assert/has-same-constructor/lib/main.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/assert/has-same-constructor/README.md b/lib/node_modules/@stdlib/assert/has-same-constructor/README.md index ae15fe5b8f64..4cf89fb84f83 100644 --- a/lib/node_modules/@stdlib/assert/has-same-constructor/README.md +++ b/lib/node_modules/@stdlib/assert/has-same-constructor/README.md @@ -20,7 +20,7 @@ limitations under the License. # hasSameConstructor -> Tests if two values have the same constructor. +> Test whether two provided values have the same constructor.
diff --git a/lib/node_modules/@stdlib/assert/has-same-constructor/examples/index.js b/lib/node_modules/@stdlib/assert/has-same-constructor/examples/index.js index 7aaf69a98b97..4be55040a4d6 100644 --- a/lib/node_modules/@stdlib/assert/has-same-constructor/examples/index.js +++ b/lib/node_modules/@stdlib/assert/has-same-constructor/examples/index.js @@ -20,7 +20,7 @@ 'use strict'; -var hasSameConstructor = require( './' ); +var hasSameConstructor = require( './../lib' ); var bool = hasSameConstructor( [1, 2, 3], ['a', 'b', 'c'] ); console.log( bool ); diff --git a/lib/node_modules/@stdlib/assert/has-same-constructor/lib/index.js b/lib/node_modules/@stdlib/assert/has-same-constructor/lib/index.js index ed3f27081c35..76f92c3bd94f 100644 --- a/lib/node_modules/@stdlib/assert/has-same-constructor/lib/index.js +++ b/lib/node_modules/@stdlib/assert/has-same-constructor/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* Test whether an object has a specified property, either own or inherited. +* Test whether two provided values have the same constructor. * * @module @stdlib/assert/has-same-constructor * diff --git a/lib/node_modules/@stdlib/assert/has-same-constructor/lib/main.js b/lib/node_modules/@stdlib/assert/has-same-constructor/lib/main.js index 5fdc8c8fa980..3c086e6680b1 100644 --- a/lib/node_modules/@stdlib/assert/has-same-constructor/lib/main.js +++ b/lib/node_modules/@stdlib/assert/has-same-constructor/lib/main.js @@ -21,7 +21,7 @@ // MAIN // /** -* Tests if two objects has same contructor function. +* Test whether two provided values have the same constructor * * @param {*} x - first input value * @param {*} y - second input value From 04bcb746dc048547bfc76d9bf1f886afbf8a3aac Mon Sep 17 00:00:00 2001 From: abhishekblue Date: Fri, 28 Feb 2025 13:52:40 +0530 Subject: [PATCH 7/8] fix(assert): resolve README lint errors and improve formatting --- .../assert/has-same-constructor/README.md | 24 +++++++------------ .../benchmark/benchmark.js | 7 ++++-- .../assert/has-same-constructor/docs/repl.txt | 6 ++--- .../docs/types/index.d.ts | 1 - .../has-same-constructor/examples/index.js | 12 +++++----- .../assert/has-same-constructor/lib/index.js | 15 +++--------- .../assert/has-same-constructor/lib/main.js | 21 ++++------------ 7 files changed, 30 insertions(+), 56 deletions(-) diff --git a/lib/node_modules/@stdlib/assert/has-same-constructor/README.md b/lib/node_modules/@stdlib/assert/has-same-constructor/README.md index 4cf89fb84f83..80210213e841 100644 --- a/lib/node_modules/@stdlib/assert/has-same-constructor/README.md +++ b/lib/node_modules/@stdlib/assert/has-same-constructor/README.md @@ -20,7 +20,7 @@ limitations under the License. # hasSameConstructor -> Test whether two provided values have the same constructor. +> Test whether two provided arguments have the same constructor.
@@ -32,22 +32,16 @@ var hasSameConstructor = require( '@stdlib/assert/has-same-constructor' ); #### hasSameConstructor( x, y ) -Returns a `boolean` indicating whether two given values has same contructor function. +Tests if two arguments `x` and `y` have the same constructor. ```javascript -var x = 5 -var y = 10; -var bool = hasSameConstructor( x, y ); +var bool = hasSameConstructor( 5, 10 ); // returns true -x = 5; -y = []; -bool = hasSameConstructor( x, y ); +bool = hasSameConstructor( 5, [] ); // returns false -x = []; -y = []; -bool = hasSameConstructor( x, y ); +bool = hasSameConstructor( [], [] ); // returns true ``` @@ -91,16 +85,16 @@ bool = hasSameConstructor( x, y ); ```javascript var hasSameConstructor = require( '@stdlib/assert/has-same-constructor' ); -var bool = hasSameConstructor( [1, 2, 3], ['a', 'b', 'c'] ); +var bool = hasSameConstructor([1, 2, 3], ['a', 'b', 'c']); // returns true -bool = hasSameConstructor( [1, 2, 3], { 'key': 'value' } ); +bool = hasSameConstructor([1, 2, 3], { 'key': 'value' }); // returns false bool = hasSameConstructor({ 'name': 'Alice' }, { 'age': 30 }); // returns true -bool = hasSameConstructor( { 'name': 'Alice' }, new Date() ); +bool = hasSameConstructor({'name': 'Alice' }, new Date()); // returns false bool = hasSameConstructor( new Date(), new Date() ); @@ -109,7 +103,7 @@ bool = hasSameConstructor( new Date(), new Date() ); bool = hasSameConstructor( null, { 'name': 'Alice' } ); // returns false -bool = hasSameConstructor( undefined, [1, 2, 3] ); +bool = hasSameConstructor( void 0, [1, 2, 3] ); // returns false bool = hasSameConstructor( 42, 3.14 ); diff --git a/lib/node_modules/@stdlib/assert/has-same-constructor/benchmark/benchmark.js b/lib/node_modules/@stdlib/assert/has-same-constructor/benchmark/benchmark.js index 60c0a7b4d374..a1973456fed9 100644 --- a/lib/node_modules/@stdlib/assert/has-same-constructor/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/assert/has-same-constructor/benchmark/benchmark.js @@ -33,6 +33,8 @@ var hasSameConstructor = require( './../lib' ); bench( pkg, function benchmark( b ) { var values; var bool; + var x; + var y; var i; values = [ @@ -51,13 +53,14 @@ bench( pkg, function benchmark( b ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - bool = hasSameConstructor( values[ i % values.length ], values[ (i+1) % values.length ] ); + x = values[ i%values.length ]; + y = values[ (i+1)%values.length ]; + bool = hasSameConstructor( x, y ); if ( typeof bool !== 'boolean' ) { b.fail( 'should return a boolean' ); } } b.toc(); - if ( !isBoolean( bool ) ) { b.fail( 'should return a boolean' ); } diff --git a/lib/node_modules/@stdlib/assert/has-same-constructor/docs/repl.txt b/lib/node_modules/@stdlib/assert/has-same-constructor/docs/repl.txt index a3cd8b5022f5..48e52abbb099 100644 --- a/lib/node_modules/@stdlib/assert/has-same-constructor/docs/repl.txt +++ b/lib/node_modules/@stdlib/assert/has-same-constructor/docs/repl.txt @@ -4,16 +4,16 @@ Parameters ---------- - a: any + x: any First input value. - b: any + y: any Second input value. Returns ------- bool: boolean - Boolean indicating whether two values have same constructor. + Boolean indicating whether two arguments have the same constructor. Examples -------- diff --git a/lib/node_modules/@stdlib/assert/has-same-constructor/docs/types/index.d.ts b/lib/node_modules/@stdlib/assert/has-same-constructor/docs/types/index.d.ts index 5f946a2e4ee4..18a9ec11b708 100644 --- a/lib/node_modules/@stdlib/assert/has-same-constructor/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/assert/has-same-constructor/docs/types/index.d.ts @@ -37,7 +37,6 @@ * var bool = hasSameConstructor(new String("Hello"), "World"); * // returns true */ - declare function hasSameConstructor( x: any, y: any ): boolean; diff --git a/lib/node_modules/@stdlib/assert/has-same-constructor/examples/index.js b/lib/node_modules/@stdlib/assert/has-same-constructor/examples/index.js index 4be55040a4d6..0c2964f5b36e 100644 --- a/lib/node_modules/@stdlib/assert/has-same-constructor/examples/index.js +++ b/lib/node_modules/@stdlib/assert/has-same-constructor/examples/index.js @@ -22,11 +22,11 @@ var hasSameConstructor = require( './../lib' ); -var bool = hasSameConstructor( [1, 2, 3], ['a', 'b', 'c'] ); +var bool = hasSameConstructor([1, 2, 3], ['a', 'b', 'c']); console.log( bool ); // => true -bool = hasSameConstructor( [1, 2, 3], { key: 'value' }); +bool = hasSameConstructor([1, 2, 3], { key: 'value' }); console.log( bool ); // => false @@ -34,7 +34,7 @@ bool = hasSameConstructor({ name: 'Alice' }, { age: 30 }); console.log( bool ); // => true -bool = hasSameConstructor({ name: 'Alice' }, new Date() ); +bool = hasSameConstructor({ name: 'Alice' }, new Date()); console.log( bool ); // => false @@ -42,11 +42,11 @@ bool = hasSameConstructor( new Date(), new Date() ); console.log( bool ); // => true -bool = hasSameConstructor( null, { name: 'Alice' }); +bool = hasSameConstructor(null, { name: 'Alice' }); console.log( bool ); // => false -bool = hasSameConstructor( undefined, [1, 2, 3] ); +bool = hasSameConstructor(undefined, [1, 2, 3]); console.log( bool ); // => false @@ -58,6 +58,6 @@ bool = hasSameConstructor( 42, 'Hello' ); console.log( bool ); // => false -bool = hasSameConstructor( function () {}, () => {} ); +bool = hasSameConstructor(function () {}, () => {}); console.log( bool ); // => true diff --git a/lib/node_modules/@stdlib/assert/has-same-constructor/lib/index.js b/lib/node_modules/@stdlib/assert/has-same-constructor/lib/index.js index 76f92c3bd94f..ee1ce1c5dbe8 100644 --- a/lib/node_modules/@stdlib/assert/has-same-constructor/lib/index.js +++ b/lib/node_modules/@stdlib/assert/has-same-constructor/lib/index.js @@ -26,22 +26,13 @@ * @example * var hasSameConstructor = require( '@stdlib/assert/has-same-constructor' ); * -* @example -* var x = new Number(5); -* var y = new Number(10); -* var bool = hasSameConstructor( x, y ); +* var bool = hasSameConstructor( new Number(5), new Number(10) ); * // returns true * -* @example -* var x = new Number(5); -* var y = []; -* var bool = hasSameConstructor( x, y ); +* bool = hasSameConstructor( new Number(5), [] ); * // returns false * -* @example -* var x = []; -* var y = []; -* var bool = hasSameConstructor( x, y ); +* bool = hasSameConstructor( [], [] ); * // returns true */ diff --git a/lib/node_modules/@stdlib/assert/has-same-constructor/lib/main.js b/lib/node_modules/@stdlib/assert/has-same-constructor/lib/main.js index 3c086e6680b1..fbc5a7d09066 100644 --- a/lib/node_modules/@stdlib/assert/has-same-constructor/lib/main.js +++ b/lib/node_modules/@stdlib/assert/has-same-constructor/lib/main.js @@ -28,32 +28,19 @@ * @returns {boolean} boolean indicating whether two arguments have the same native class * * @example -* var x = new Number(5); -* var y = new Number(10); -* var bool = hasSameConstructor( x, y ); +* var bool = hasSameConstructor( new Number(5), new Number(10) ); * // returns true * * @example -* var x = new Number(5); -* var y = []; -* var bool = hasSameConstructor( x, y ); +* var bool = hasSameConstructor( new Number(5), [] ); * // returns false * * @example -* var x = []; -* var y = []; -* var bool = hasSameConstructor( x, y ); +* var bool = hasSameConstructor( [], [] ); * // returns true */ -// function hasSameConstructor( x, y ) { -// if ( !x || !y ) { -// return false; -// } -// return x.constructor === y.constructor; -// } - function hasSameConstructor( x, y ) { - if (x == null || y == null) { // Check for null or undefined only + if (x == null || y == null) { return false; } return x.constructor === y.constructor; From f3f92184f0a7e46f38f3c1ebea72c39d7b9f427c Mon Sep 17 00:00:00 2001 From: abhishekblue Date: Fri, 28 Feb 2025 14:21:07 +0530 Subject: [PATCH 8/8] adjust main.js --- .../@stdlib/assert/has-same-constructor/lib/main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/assert/has-same-constructor/lib/main.js b/lib/node_modules/@stdlib/assert/has-same-constructor/lib/main.js index fbc5a7d09066..9f267a024525 100644 --- a/lib/node_modules/@stdlib/assert/has-same-constructor/lib/main.js +++ b/lib/node_modules/@stdlib/assert/has-same-constructor/lib/main.js @@ -21,7 +21,7 @@ // MAIN // /** -* Test whether two provided values have the same constructor +* Test whether two provided values have the same constructor. * * @param {*} x - first input value * @param {*} y - second input value @@ -40,7 +40,7 @@ * // returns true */ function hasSameConstructor( x, y ) { - if (x == null || y == null) { + if ( x === null || y === null ) { return false; } return x.constructor === y.constructor;