Skip to content
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

incompatible with "clj-fuzzy" #8

Open
nitramreffehcs opened this issue Dec 17, 2020 · 0 comments
Open

incompatible with "clj-fuzzy" #8

nitramreffehcs opened this issue Dec 17, 2020 · 0 comments

Comments

@nitramreffehcs
Copy link

nitramreffehcs commented Dec 17, 2020

hi, apparently this module doesn't work after "clj-fuzzy" is loaded, i have no idea why, as that module is minified

this is my test code:

const later = require('@breejs/later')

const parsedSchedule = later.parse.text('at 0:00')
const scheduleObject = later.schedule(parsedSchedule)
let next

next = scheduleObject.next(2)

if (next[0].getTime() === next[1].getTime()) {
console.log('NOT OK')
} else {
console.log('OK')
}

require('clj-fuzzy')

next = scheduleObject.next(2)

if (next[0].getTime() === next[1].getTime()) {
console.log('NOT OK')
} else {
console.log('OK')
}

in the second test both dates returned by "next" are identical, the current time

FOUND IT !!

that module does this (yes that is totaly wrong)
Date.prototype.s = function (a, b) { return b instanceof Date && this.valueOf() === b.valueOf()
and later does

val: function val(d) {
return d.s || (d.s = later.date.getSec.call(d));
},

(line 363)
but, d is a standard javascript date at that time, i understand that this is some kind of optimization ? (are seconds cached this way ?

of course attaching methods to global classes is the problem here, but attaching properties isn't very safe either
sadly that other module isn't being maintained

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant