-
-
Notifications
You must be signed in to change notification settings - Fork 867
feat: add assert/is-same-date-object
#1348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add assert/is-same-date-object
#1348
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👋 Hi there! 👋
And thank you for opening your first pull request! We will review it shortly. 🏃 💨
assert/is-same-date-object
@adityacodes30 You mind ticking the box indicating that you've read the contributing guidelines? Thanks! |
done |
lib/node_modules/@stdlib/assert/is-same-date-object/docs/types/index.d.ts
Outdated
Show resolved
Hide resolved
Thanks for submitting this PR. We'll try to review within the next day or so. |
…s/types/index.d.ts
…s/types/index.d.ts
Tests if two arguments are both valid date objects and both resolve to the same timestamp. | ||
|
||
```javascript | ||
var d1 = new Date(2024, 11, 31, 23, 59, 59, 999); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adityacodes30 Would you mind updating here and elsewhere to adhere to common project conventions? Namely, with some exception, we prefer spaces within brackets. E.g.,
var d1 = new Date(2024, 11, 31, 23, 59, 59, 999); | |
var d1 = new Date( 2024, 11, 31, 23, 59, 59, 999 ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do that pronto
lib/node_modules/@stdlib/assert/is-same-date-object/docs/repl.txt
Outdated
Show resolved
Hide resolved
@kgryte ive made the changes , let me know if anything else needs to be done |
lib/node_modules/@stdlib/assert/is-same-date-object/benchmark/benchmark.length.js
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/assert/is-same-date-object/benchmark/benchmark.length.js
Outdated
Show resolved
Hide resolved
var i; | ||
b.tic(); | ||
for ( i = 0; i < b.iterations; i++ ) { | ||
date2.setMilliseconds( i ); // Change the date slightly each iteration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I appreciate the intent to ensure we compare different dates for each iteration in order to avoid certain compiler optimizations. I think we can do better by simply using a pre-allocated list of values
containing a list of date objects and then in the loop, just use cheap modulo arithmetic to pull out a new date2
for comparison. If you hunt enough, you should be able to find a similar approach elsewhere in the project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got that, i'll make the changes and pull the 'date2' from a values array.
that aside i'm curious about your usage of the word 'cheap' , is there a high cost operation here ? if yes then which one and how. Would highly appreciate your knowledge
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A method call which mutates an object is likely to be slower than an operator (e.g., %
) which is implemented in hardware. Here, we want to avoid doing operations which have perf costs similar to what we are attempting to test. Otherwise, perf results have conflating factors and it becomes harder to separate signal from noise when comparing across implementations and/or packages. Ideally, any boilerplate code around the operation of focus should be at least an order of magnitude faster, preferably more, such that any additional costs are negligible.
lib/node_modules/@stdlib/assert/is-same-date-object/docs/repl.txt
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/assert/is-same-date-object/benchmark/benchmark.js
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/assert/is-same-date-object/benchmark/benchmark.js
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/assert/is-same-date-object/benchmark/benchmark.js
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/assert/is-same-date-object/docs/repl.txt
Outdated
Show resolved
Hide resolved
Co-authored-by: Athan <[email protected]> Signed-off-by: Aditya Sapra <[email protected]>
…benchmark.js Co-authored-by: Athan <[email protected]> Signed-off-by: Aditya Sapra <[email protected]>
Co-authored-by: Athan <[email protected]> Signed-off-by: Aditya Sapra <[email protected]>
…0/stdlib into is-same-date-object
@kgryte ive made the changes , i see a lot of co-sign commits, let me know if you want me to squash them |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's get this in, thanks!
Suggested a few remaining changes, but will merge once CI has passed.
lib/node_modules/@stdlib/assert/is-same-date-object/docs/repl.txt
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/assert/is-same-date-object/docs/repl.txt
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/assert/is-same-date-object/examples/index.js
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/assert/is-same-date-object/examples/index.js
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/assert/is-same-date-object/examples/index.js
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/assert/is-same-date-object/examples/index.js
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/assert/is-same-date-object/examples/index.js
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/assert/is-same-date-object/package.json
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/assert/is-same-date-object/package.json
Outdated
Show resolved
Hide resolved
Signed-off-by: Philipp Burckhardt <[email protected]>
Signed-off-by: Philipp Burckhardt <[email protected]>
Signed-off-by: Philipp Burckhardt <[email protected]>
…ndex.js Signed-off-by: Philipp Burckhardt <[email protected]>
…ndex.js Signed-off-by: Philipp Burckhardt <[email protected]>
…ndex.js Signed-off-by: Philipp Burckhardt <[email protected]>
…ndex.js Signed-off-by: Philipp Burckhardt <[email protected]>
…ndex.js Signed-off-by: Philipp Burckhardt <[email protected]>
Signed-off-by: Philipp Burckhardt <[email protected]>
seems like there are some lint errors , let me take a look at em |
lib/node_modules/@stdlib/assert/is-same-date-object/examples/index.js
Outdated
Show resolved
Hide resolved
…ndex.js Signed-off-by: Philipp Burckhardt <[email protected]>
@adityacodes30 Was just a duplicate |
PR-URL: stdlib-js#1348 Closes: stdlib-js#1337 --------- Signed-off-by: Aditya Sapra <[email protected]> Signed-off-by: Philipp Burckhardt <[email protected]> Co-authored-by: Athan Reines <[email protected]> Co-authored-by: Philipp Burckhardt <[email protected]> Reviewed-by: Athan Reines <[email protected]> Reviewed-by: Philipp Burckhardt <[email protected]>
Resolves #1337
Description
This PR adds
@stdlib/assert/is-same-date-object
Related Issues
Yes it solves #1337
This pull request:
@stdlib/assert/is-same-date-object
#1337Questions
No.
Other
This implementation uses the getTime() function to compare upto the same timestamp that covers different ways of initialising the Date object
Checklist
@stdlib-js/reviewers