-
I'm developing an app which needs a list of the days of the week, but right now the
require("locale").dow()
function only accepts a Date object. So I've had to do this:let daysOfWeek = []; for (let i = 1; i <= 7; i++) { daysOfWeek.push(require('locale').dow(new Date(1970, 1, i, 0, 0, 0, 0)); // 1/1/1970 was a Sunday } // Result: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
It seems to me it would be more efficient if the dow() function could accept an integer as well (0 = Sunday, 6 = Saturday) because right now it's just calling
getDay()
on the argument. That way, the code would be simpler:let daysOfWeek = []; for (let i = 0; i < 7; i++) { daysOfWeek.push(require('locale').dow(i); }
Does this make sense?
-
-
-
-
-
-
Not sure if this has been suggested before, but I think it would be useful to have custom libraries. Say, two different apps need to draw graphs. We could give every app separate code to draw the graphs, but it would be more efficient to create a graphing library and then have both apps use that library. Then, it's described in each app's .info file that it requires that library (e.g.
requires: ["graphing"]
), so that when the app is downloaded it can also download the libraries it needs.
P.S: I'm not saying the function should no longer accept Date objects: that would break previous implementations. Instead, it would accept both Date and integer arguments.