Skip to content

Why $::util:toSet() equals to toSet($) but not toSet.cal($) in README "Example of using constructors or namespace object as extensions"? #9

Description

@LongTengDao
// util.js
export const toSet = iterable => new Set(iterable)
import * as util from './util.js'
[]::util:toSet();// why here equals to `util.toSet([])`, but not `util.toSet.call([])`?

If so, why not use |> syntax instead?

In my opinion, value|>step1|>step2|>step3 syntax suits util that designed to use without other args,
while value::step1(true)::step2()::step3('yes', 1) syntax suits util that designed to use with other args.
The both proposals are mainly to avoid writting backward logic like step3(step2(step1(value))),
but do chain thing like $(value).step1().step2().step3() more easily, free, and fast.

If :: want to cover the use cases that |> does, and |> want to cover the multiple arguments use cases which should leave to ::, the situation would be a mess...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions