bind method for binding argument to callable

Installs: 13

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/ta-tikoma/bind

1.0.0 2025-10-24 08:03 UTC

This package is auto-updated.

Last update: 2025-10-24 08:05:16 UTC


README

There is only two functions in this package: bind and flip

Install

Examples

Example 1

Before

array_map(static fn (string $s) => substr($s, 2), ['a_bar', 'a_foo', 'a_boo'])

After

array_map(bind(substr(...), 2), ['a_bar', 'a_foo', 'a_boo'])

Example 2

Before

$result = 'Hello World'
    |> static fn (string $s) => explode(' ', $s)
    |> static fn (array $a) => array_filter($a, static fn (string $s) => str_starts_with($s, 'H'))

After

$result = 'Hello World'
    |> bind(flip(explode(...)), ' ')
    |> bind(array_filter(...), bind(str_starts_with(...), 'H'))