Skip to content

Switch any/every/some to arrays instead of varargs #70

@domenic

Description

@domenic

Back in #16, we ended up talking ourselves into using varargs. After seeing varargs in practice, I am now back in the array camp. Here's the essential reason:

// Promise.any with varargs (as it is now specced):

// - No []s in the arguments to Promise.any, but you need them in the onFulfilled handler.
Promise.any(a, b, c).then(([a, b, c]) => { });

// - Need ... in the arguments to Promise.any, but no adornments in the onFulfilled handler.
Promise.any(...array).then(array => { });

Instead I propose:

// Promise.any if it used arrays in both cases:

// - []s match
Promise.any([a, b, c]).then(([a, b, c]) => { });

// - no ...s on either side
Promise.any(array).then(array => { });

There's also the fact that the array methods that every and some take their name from are, well, array methods, and inextricably associated with arrays in my mind.


This is not a big deal in the end, as people can cope with some awkward asymmetry. But I think the parallel between what you pass in to the function vs. what onFulfilled gets called with is a good one to preserve, and breaking it makes things unnecessarily awkward. Thus I thought it'd be worth floating a fix to see how people feel.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions