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

Accept iterables. #153

Merged
merged 18 commits into from
Aug 19, 2020
Next Next commit
Allow stack.{keys,order} to be iterable.
  • Loading branch information
mbostock committed Nov 19, 2019
commit 9d7c3c2adbf9eccb9e4bab4cd375186de90a1c11
5 changes: 2 additions & 3 deletions src/stack.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {slice} from "./array.js";
import constant from "./constant.js";
import offsetNone from "./offset/none.js";
import orderNone from "./order/none.js";
Expand Down Expand Up @@ -38,15 +37,15 @@ export default function() {
}

stack.keys = function(_) {
return arguments.length ? (keys = typeof _ === "function" ? _ : constant(slice.call(_)), stack) : keys;
return arguments.length ? (keys = typeof _ === "function" ? _ : constant(Array.from(_)), stack) : keys;
};

stack.value = function(_) {
return arguments.length ? (value = typeof _ === "function" ? _ : constant(+_), stack) : value;
};

stack.order = function(_) {
return arguments.length ? (order = _ == null ? orderNone : typeof _ === "function" ? _ : constant(slice.call(_)), stack) : order;
return arguments.length ? (order = _ == null ? orderNone : typeof _ === "function" ? _ : constant(Array.from(_)), stack) : order;
};

stack.offset = function(_) {
Expand Down