-
Notifications
You must be signed in to change notification settings - Fork 53
Array.from(moment(from).twix(to)).iterate("days")) == [] #104
Copy link
Copy link
Open
Labels
Description
Hey,
I now know about toArray() but I got caught out today when iterate() didn't return an iterable suitable for Array.from()
@home:~/src$ cat test.js
const moment = require("moment")
const twix = require("./lib/twix.min.js")
let start = new Date("2018-01-01");
let end = new Date("2018-06-01");
console.log(moment(start).twix(end).toArray("days").length);
console.log(Array.from(moment(start).twix(end).iterate("days")).length);
console.log(Array.from(moment(start).twix(end).iterate("days")));@home:~/src$ node test.js
152
0
[]
Array.from() should expand the iterable:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from
so I guess the object returned from iterate is not truly 'iterable' in the way required by the spec.
Nice library though.. saved me a bunch of time elsewhere so I'm still net positive on time-savings thanks to twix. :-)
Reactions are currently unavailable