diff --git a/lib/node_modules/@stdlib/assert/is-same-date-object/README.md b/lib/node_modules/@stdlib/assert/is-same-date-object/README.md new file mode 100644 index 000000000000..b4bc4d707c56 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-same-date-object/README.md @@ -0,0 +1,91 @@ + + +# isSameDateObject + +> Test if two values are [Date](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) objects corresponding to the same date and time. + +
+ +## Usage + +```javascript +var isSameDateObject = require( '@stdlib/assert/is-same-date-object' ); +``` + +#### isSameDateObject( d1, d2 ) + +Tests if two values are both Date objects corresponding to the same date and time. + +```javascript +var d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); +var d2 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); +var bool = isSameDateObject( d1, d2 ); +// returns true + +bool = isSameDateObject( d1, new Date( 2023, 11, 31, 23, 59, 59, 78 ) ); +// returns false +``` + +
+ + + +
+ +## Examples + + + +```javascript +var isSameDateObject = require( '@stdlib/assert/is-same-date-object' ); + +var d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); +var d2 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); + +var bool = isSameDateObject( d1, d2 ); +// returns true + +d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); +d2 = new Date( 2024, 11, 31, 23, 59, 59, 78 ); + +bool = isSameDateObject( d1, d2 ); +// returns false + +d1 = new Date(); +d2 = new Date( '2024-12-31T23:59:59.999' ); + +bool = isSameDateObject( d1, d2 ); +// returns false + +var d3 = new Date( 2024, 11, 31 ); +var d4 = new Date( 'December 31, 2024 23:59:59:999' ); + +bool = isSameDateObject( d1, d3 ); +// returns false + +bool = isSameDateObject( d2, d4 ); +// returns true +``` + +
+ + + diff --git a/lib/node_modules/@stdlib/assert/is-same-date-object/benchmark/benchmark.js b/lib/node_modules/@stdlib/assert/is-same-date-object/benchmark/benchmark.js new file mode 100644 index 000000000000..3c000a5afc7c --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-same-date-object/benchmark/benchmark.js @@ -0,0 +1,62 @@ +/** +* @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. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pkg = require( './../package.json' ).name; +var isSameDateObject = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var values; + var date1; + var date2; + var bool; + var i; + values = [ + '5', + 'Date', + new Date( 'December 31, 2024 23:59:59:999' ), + new Date( '2024-12-31T23:59:59.999' ), + NaN, + true, + false, + null + ]; + date1 = new Date(); + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + date2 = values[ i%values.length ]; + bool = isSameDateObject( date1, date2 ); + 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(); +}); diff --git a/lib/node_modules/@stdlib/assert/is-same-date-object/docs/repl.txt b/lib/node_modules/@stdlib/assert/is-same-date-object/docs/repl.txt new file mode 100644 index 000000000000..e5078d774774 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-same-date-object/docs/repl.txt @@ -0,0 +1,32 @@ + +{{alias}}( d1, d2 ) + Tests if two values are both Date objects corresponding + to the same date and time. + + Parameters + ---------- + d1: any + First input value. + d2: any + Second input value. + + Returns + ------- + bool: boolean + Boolean indicating whether both values are Date objects + corresponding to the same date and time. + + Examples + -------- + > var d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); + > var d2 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); + > var bool = {{alias}}( d1, d2 ) + true + > var d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); + > var d2 = new Date( 2024, 11, 31, 23, 59, 59, 78 ); + > var bool = {{alias}}( d1, d2 ) + false + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/assert/is-same-date-object/docs/types/index.d.ts b/lib/node_modules/@stdlib/assert/is-same-date-object/docs/types/index.d.ts new file mode 100644 index 000000000000..557a16d2e67a --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-same-date-object/docs/types/index.d.ts @@ -0,0 +1,47 @@ +/* +* @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. +*/ + +// TypeScript Version: 4.1 + +/** +* Tests if two values are both Date objects corresponding to the same date and time. +* +* @param d1 - first input value +* @param d2 - second input value +* @returns boolean indicating whether both are Date objects corresponding to the same date and time. +* +* @example +* var d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); +* var d2 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); +* +* var bool = isSameDateObject( d1, d2 ); +* // returns true +* +* @example +* var d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); +* var d2 = new Date( 2024, 11, 31, 23, 59, 59, 78 ); +* +* var bool = isSameDateObject( d1, d2 ); +* // returns false +*/ +declare function isSameDateObject( d1: any, d2: any ): boolean; + + +// EXPORTS // + +export = isSameDateObject; diff --git a/lib/node_modules/@stdlib/assert/is-same-date-object/docs/types/test.ts b/lib/node_modules/@stdlib/assert/is-same-date-object/docs/types/test.ts new file mode 100644 index 000000000000..0bc2ed487ab6 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-same-date-object/docs/types/test.ts @@ -0,0 +1,36 @@ +/* +* @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. +*/ + +import isSameDateObject = require( './index' ); + + +// TESTS // + +// The function returns a boolean... +{ + isSameDateObject( new Date(), new Date() ); // $ExpectType boolean + isSameDateObject( null, null ); // $ExpectType boolean + isSameDateObject( 'beep', 'boop' ); // $ExpectType boolean +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + isSameDateObject(); // $ExpectError + isSameDateObject( new Date() ); // $ExpectError + isSameDateObject( 'beep', 'beep', new Date() ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/assert/is-same-date-object/examples/index.js b/lib/node_modules/@stdlib/assert/is-same-date-object/examples/index.js new file mode 100644 index 000000000000..000083c80701 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-same-date-object/examples/index.js @@ -0,0 +1,51 @@ +/** +* @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. +*/ + +'use strict'; + +var isSameDateObject = require( './../lib' ); + +var d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); +var d2 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); + +var bool = isSameDateObject( d1, d2 ); +console.log( bool ); +// => true + +d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); +d2 = new Date( 2024, 11, 31, 23, 59, 59, 78 ); + +bool = isSameDateObject( d1, d2 ); +console.log( bool ); +// => false + +d1 = new Date(); +d2 = new Date( '2024-12-31T23:59:59.999' ); +bool = isSameDateObject( d1, d2 ); +// returns false + +var d3 = new Date( 2024, 11, 31 ); +var d4 = new Date( 'December 31, 2024 23:59:59:999' ); + +bool = isSameDateObject( d1, d3 ); +console.log( bool ); +// => false + +bool = isSameDateObject( d2, d4 ); +console.log( bool ); +// => true diff --git a/lib/node_modules/@stdlib/assert/is-same-date-object/lib/index.js b/lib/node_modules/@stdlib/assert/is-same-date-object/lib/index.js new file mode 100644 index 000000000000..8344411ffca0 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-same-date-object/lib/index.js @@ -0,0 +1,52 @@ +/** +* @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. +*/ + +'use strict'; + +/** +* Test if two arguments are both Date objects corresponding to the same date and time. +* +* @module @stdlib/assert/is-same-date-object +* +* @example +* var isSameDateObject = require( '@stdlib/assert/is-same-date-object' ); +* +* var d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); +* var d2 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); +* +* var bool = isSameDateObject( d1, d2 ); +* // returns true +* +* @example +* var isSameDateObject = require( '@stdlib/assert/is-same-date-object' ); +* +* var d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); +* var d2 = new Date( 2024, 11, 31, 23, 59, 59, 78 ); +* +* var bool = isSameDateObject( d1, d2 ); +* // returns false +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/assert/is-same-date-object/lib/main.js b/lib/node_modules/@stdlib/assert/is-same-date-object/lib/main.js new file mode 100644 index 000000000000..d804d00bcd48 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-same-date-object/lib/main.js @@ -0,0 +1,57 @@ +/** +* @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. +*/ + +'use strict'; + +// MODULES // + +var isDateObject = require( '@stdlib/assert/is-date-object' ); + + +// MAIN // + +/** +* Tests if two arguments are both Date objects corresponding to the same date and time. +* +* @param {*} d1 - first value +* @param {*} d2 - second value +* @returns {boolean} boolean result +* +* @example +* var d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); +* var d2 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); +* var bool = isSameDateObject( d1, d2 ); +* // returns true +* +* @example +* var d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); +* var d2 = new Date( 2024, 11, 31, 23, 59, 59, 78 ); +* var bool = isSameDateObject( d1, d2 ); +* // returns false +*/ +function isSameDateObject( d1, d2 ) { + if ( isDateObject( d1 ) && isDateObject( d2 ) ) { + return d1.getTime() === d2.getTime(); + } + return false; +} + + +// EXPORTS // + +module.exports = isSameDateObject; diff --git a/lib/node_modules/@stdlib/assert/is-same-date-object/package.json b/lib/node_modules/@stdlib/assert/is-same-date-object/package.json new file mode 100644 index 000000000000..b7a1efe49d2b --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-same-date-object/package.json @@ -0,0 +1,78 @@ +{ + "name": "@stdlib/assert/is-same-date-object", + "version": "0.0.0", + "description": "Test if two values are both Date objects corresponding to the same date and time.", + "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": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdassert", + "assertion", + "assert", + "utilities", + "utility", + "utils", + "util", + "equal", + "same", + "strict", + "is", + "issame", + "issamevalue", + "isequal", + "isstrictequal", + "type", + "check", + "valid", + "validate", + "test", + "date", + "time", + "generic" + ] + } + \ No newline at end of file diff --git a/lib/node_modules/@stdlib/assert/is-same-date-object/test/test.js b/lib/node_modules/@stdlib/assert/is-same-date-object/test/test.js new file mode 100644 index 000000000000..1f85c75dca84 --- /dev/null +++ b/lib/node_modules/@stdlib/assert/is-same-date-object/test/test.js @@ -0,0 +1,90 @@ +/** +* @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. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isSameDateObject = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof isSameDateObject, 'function', 'main export is a function' ); + t.end(); +} ); + +tape( 'the function returns `true` if provided two Date objects corresponding to the same date and time', function test( t ) { + var d1; + var d2; + + d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); + t.strictEqual( isSameDateObject( d1, d1 ), true, 'returns expected value' ); + + d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); + d2 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); + t.strictEqual( isSameDateObject( d1, d2 ), true, 'returns expected value' ); + + d1 = new Date( 'December 31, 2024 23:59:59:999' ); + d2 = new Date( '2024-12-31T23:59:59.999' ); + t.strictEqual( isSameDateObject( d1, d2 ), true, 'returns expected value' ); + + t.end(); +} ); + +tape( 'the function returns `false` if not provided two Date objects corresponding to the same date and time', function test( t ) { + var d1; + var d2; + + d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); + d2 = new Date( 2024, 11, 31, 23, 59, 59, 78 ); + t.strictEqual( isSameDateObject( d1, d2 ), false, 'returns expected value' ); + + d1 = new Date(); + d2 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); + t.strictEqual( isSameDateObject( d1, d2 ), false, 'returns expected value' ); + + d1 = new Date( 2024, 11, 31 ); + d2 = new Date( 2024, 11, 30 ); + t.strictEqual( isSameDateObject( d1, d2 ), false, 'returns expected value' ); + + d1 = new Date( 2024, 11, 31 ); + d2 = 'string'; + t.strictEqual( isSameDateObject( d1, d2 ), false, 'returns expected value' ); + + d1 = new Date( 2024, 11, 31 ); + d2 = 1; + t.strictEqual( isSameDateObject( d1, d2 ), false, 'returns expected value' ); + + d1 = new Date( 2024, 11, 31 ); + d2 = undefined; + t.strictEqual( isSameDateObject( d1, d2 ), false, 'returns expected value' ); + + d1 = new Date( 2024, 11, 31 ); + d2 = {}; + t.strictEqual( isSameDateObject( d1, d2 ), false, 'returns expected value' ); + + d1 = new Date( 2024, 11, 31 ); + d2 = []; + t.strictEqual( isSameDateObject( d1, d2 ), false, 'returns expected value' ); + + t.end(); +} );