breejs/later

incompatible with "clj-fuzzy"

nitramreffehcs opened this issue · 0 comments

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