Skip to content

Change patroon helpers #3

@bas080

Description

@bas080

I'm not an native English speaker but to me the naming of the pattern helpers seem off.

Currently we have typed and ref. It seems a bit off. Either the naming should improve or the API should change so these helpers don't even exist.

An idea is to only have an all helper which will check if all patterns passed to it pass. It could look like this.

To manage the errors with a value one could do:

patroon(
  all(is(Error), {statusCode: _}), 'an error with statusCode'
)

In case of the ref one could do:

patroon(
  equals(fn), 'is the function'
)

This would make patroon a little more focused/bare-bones but still play nice with other fp libraries.

EDIT:

@CrossEye suggested using arrays for each pattern-value pair. In that case an all helper would not be necessary.

patroon(
  [Error, {statusCode: _}, 'is an error with a statusCode']
)

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