{"id":18887827,"url":"https://github.com/masterfermin02/slash","last_synced_at":"2025-04-14T22:34:16.741Z","repository":{"id":62524866,"uuid":"258696767","full_name":"masterfermin02/slash","owner":"masterfermin02","description":"PHP library for functional programming","archived":false,"fork":false,"pushed_at":"2023-01-29T23:45:52.000Z","size":830,"stargazers_count":12,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-28T11:04:46.348Z","etag":null,"topics":["functional","functional-programming","lodash","php","ramda","underscore"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/masterfermin02.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-25T05:42:16.000Z","updated_at":"2023-12-05T06:26:34.000Z","dependencies_parsed_at":"2023-02-16T02:00:58.076Z","dependency_job_id":null,"html_url":"https://github.com/masterfermin02/slash","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masterfermin02%2Fslash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masterfermin02%2Fslash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masterfermin02%2Fslash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masterfermin02%2Fslash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/masterfermin02","download_url":"https://codeload.github.com/masterfermin02/slash/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248973456,"owners_count":21191974,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["functional","functional-programming","lodash","php","ramda","underscore"],"created_at":"2024-11-08T07:39:47.812Z","updated_at":"2025-04-14T22:34:11.723Z","avatar_url":"https://github.com/masterfermin02.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Slash\n\n[![Build Status](https://www.travis-ci.com/masterfermin02/slash.svg?branch=master)](https://travis-ci.org/masterfermin02/slash)\n[![Latest Stable Version](http://img.shields.io/packagist/v/masterfermin02/slash.svg?style=flat)](https://packagist.org/packages/masterfermin02/slash)\n[![Total Downloads](http://img.shields.io/packagist/dt/masterfermin02/slash.svg?style=flat)](https://packagist.org/packages/masterfermin02/slash)\n[![codecov](https://codecov.io/gh/masterfermin02/slash/branch/master/graph/badge.svg)](https://codecov.io/gh/masterfermin02/slash)\n\nA functional library for PHP programmers, similar to Ramdajs.\n\n## Functionality\nA small usage example for the groupBy function:\n```php\n\u003c?php\n\nuse function Slash\\groupBy;\n\n$records = [\n     ['id' =\u003e 1, 'value1' =\u003e 5, 'value2' =\u003e 10],\n     ['id' =\u003e 2, 'value1' =\u003e 50, 'value2' =\u003e 100],\n     ['id' =\u003e 1, 'value1' =\u003e 2, 'value2' =\u003e 2],\n     ['id' =\u003e 2, 'value1' =\u003e 15, 'value2' =\u003e 20],\n     ['id' =\u003e 3, 'value1' =\u003e 15, 'value2' =\u003e 20],\n];\n\n$groupById = groupBy('id');\n\n$grouped = $groupById($records);\n\n/*\n * resultado :    [\n * 1 =\u003e [ [ \"id\" =\u003e 1, \"value1\" =\u003e 5, \"value2\" =\u003e 10 ], [ \"id\" =\u003e 1, \"value1\" =\u003e 1, \"value2\" =\u003e 2 ] ], \n * 2 =\u003e [ [ \"id\" =\u003e 2, \"value1\" =\u003e 50, \"value2\" =\u003e 100 ], [ \"id\" =\u003e 2, \"value1\" =\u003e 15, \"value2\" =\u003e 20 ] ], \n * 3 =\u003e [ [ \"id\" =\u003e 3, \"value1\" =\u003e 15, \"value2\" =\u003e 20 ] ]   \n *   ];\n*/\n\n```\n\nMap usage :\n\n```php\n\u003c?php \n\nuse Slash\\Slash;\n\nSlash\\map([1, 2, 3], fn ($n) =\u003e $n * 2);  // === [2, 4, 6]\n```\n\nExample with slash object:\n```php\n\u003c?php\nuse Slash\\Slash;\n\nSlash::max([1, 2, 3]) // =\u003e 3\n\nSlash::flatten([1, [2, [3]]]) // =\u003e [1, 2, 3]\n\nSlash::last([1, 2, 3], 2) // =\u003e [2, 3]\n\n```\n## Why Slash?\n\nThere are already several excellent libraries with a functional flavor. Typically, they are meant to be general-purpose toolkits, suitable \nfor working in multiple paradigms. Slash has a more focused goal. We wanted a library designed specifically for a functional programming style, \none that makes it easy to create functional pipelines, one that never mutates user data.\n\n## What's Different?\nThe primary distinguishing features of slash are:\n\nSlash emphasizes a purer functional style. Immutability and side-effect free functions are at the heart of its design philosophy. This can help you get the job done with simple, elegant code.\n\nSlash functions are automatically curried. This allows you to easily build up new functions from old ones simply by not supplying the final parameters.\n\nThe parameters to Slash functions are arranged to make it convenient for currying. The data to be operated on is generally supplied last.\n\nThe last two points together make it very easy to build functions as sequences of simpler functions, each of which transforms the data and passes it along to the next. Slash is designed to support this style of coding.\n\n## Install\nRequires PHP 8+\n```bash\ncomposer require masterfermin02/slash\n```\n\nFor php 7 use version 1.4.0\n\n## Usage\nSlash operations are pure functions that can be used alone.\n\n# What It Offers\n- 60+ useful functions that you can use in your projects.\n- Slash is fully tested.\n- The source code is clean and documented.\n\nHere is what is available to you:\n\n- boolean isDate(mixed $value)\n- boolean isNumber(mixed $value)\n- boolean isString(mixed $value)\n- boolean isFunction(mixed $value)\n- boolean isEmpty(mixed $value)\n- boolean isEqual(mixed $left, mixed $right)\n- boolean isBoolean(mixed $value)\n- boolean isObject(mixed $value)\n- boolean isArray(mixed $value)\n- boolean isTraversable(mixed $value)\n- boolean isNull(mixed $value)\n- boolean has(mixed $object, string $key)\n- array keys(mixed $object)\n- array values(mixed $object)\n- array methods(mixed $object)\n- mixed copy(mixed $value)\n- mixed extend(mixed $source, mixed $destination)\n- mixed apply(mixed $object, Closure $closure)\n- mixed defaults(mixed $object, array|mixed $defaults)\n- string escape(string $string)\n- string id(string $prefix = '')\n- mixed with(mixed $value)\n- void times(integer $number, Closure $closure)\n- mixed cache(Closure $closure)\n- mixed wrap(Closure $closure, Closure $wrapper)\n- mixed compose(array $closures, array $arguments = array())\n- void once(Closure $closure)\n- mixed after(integer $number, Closure $closure)\n- mixed|array first(array $elements, integer $amount = 1)\n- array initial(array $elements, integer $amount = 1)\n- array rest(array $elements, integer $index = 1)\n- mixed|array last(array $elements, integer $amount = 1)\n- array pack(array $elements)\n- array flatten(array $elements)\n- array range(integer $to, integer $from = 0, integer $step = 1)\n- array difference(array $one, array $another)\n- array unique(array $elements, Closure $iterator = null)\n- array without(array $elements, array $ignore)\n- array zip(array $one, array $another)\n- integer indexOf(array $elements, mixed $element)\n- array intersection(array $one, array $another)\n- array union(array $one, array $another)\n- void each(array $collection, Closure $iterator)\n- array map(array $collection, Closure $iterator)\n- array toArray(mixed $value)\n- integer|null size(array|Countable $value)\n- array shuffle(array $collection)\n- boolean any(array $collection, Closure $iterator)\n- boolean all(array $collection, Closure $iterator)\n- array reject(array $collection, Closure $iterator)\n- array pluck(array $collection, string $key)\n- boolean contains(array $collection, mixed $value)\n- array invoke(array $collection, string $function)\n- mixed reduce(array $collection, Closure $iterator, mixed $initial = 0)\n- array sortBy(array $collection, Closure $iterator)\n- array groupBy(array $collection, Closure $iterator)\n- mixed max(array $collection)\n- mixed min(array $collection)\n\n## Docs\n[Read the docs](https://github.com/masterfermin02/slash/blob/master/docs/Operations.md)\n\n## Feedback\nFound a bug or have a suggestion? Please [create a new GitHub issue](https://github.com/masterfermin02/slash/issues/new). We want your feedback!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmasterfermin02%2Fslash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmasterfermin02%2Fslash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmasterfermin02%2Fslash/lists"}