{"id":24261899,"url":"https://github.com/grady-lad/composition-logger","last_synced_at":"2025-10-16T18:18:55.564Z","repository":{"id":57204953,"uuid":"80309211","full_name":"grady-lad/composition-logger","owner":"grady-lad","description":"The most optimal way to visualize/debug functional compositions :mag:","archived":false,"fork":false,"pushed_at":"2018-03-19T12:13:22.000Z","size":762,"stargazers_count":15,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-16T23:54:02.043Z","etag":null,"topics":["compose","composition-logger","functional-compositons","functional-programming","javascript","log","pipe"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/grady-lad.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-28T20:37:51.000Z","updated_at":"2019-07-08T22:00:08.000Z","dependencies_parsed_at":"2022-09-18T00:50:39.215Z","dependency_job_id":null,"html_url":"https://github.com/grady-lad/composition-logger","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grady-lad%2Fcomposition-logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grady-lad%2Fcomposition-logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grady-lad%2Fcomposition-logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grady-lad%2Fcomposition-logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grady-lad","download_url":"https://codeload.github.com/grady-lad/composition-logger/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234001693,"owners_count":18764310,"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":["compose","composition-logger","functional-compositons","functional-programming","javascript","log","pipe"],"created_at":"2025-01-15T06:49:34.403Z","updated_at":"2025-10-16T18:18:55.472Z","avatar_url":"https://github.com/grady-lad.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Composition Logger\n\n## [![composition-logger](media/logo.png)](https://github.com/grady-lad/composition-logger)\n\n### Installation\n\nTo install ( _recommended to save as a dev dependency_ )\n\n`npm install composition-logger --save -dev`\n\n### What is this?\n\nFrom all the resources that I have seen, the recommended way to debug functional compositions in JavaScript is to provide a function that produces a side effect such as logging to the console and continue to pass the data through the composition, such as [ramdas tap function](http://ramdajs.com/docs/#tap).\n\nThis is all well and good but it poses a few limitations such as:\n\n* Not beginner friendly. Beginners need to understand how functional composition works in order to debug or gain insight in how the data flows through a composition.\n\n* Debugging methods such as `tap` can be tedious to work with. Let's say your composition contains a bug, in order to view the data between each step of the compositon, you would be required to manually add the `tap` function between each step of the composition.\n\nSo how can we do better? By utilising [console.group](https://developer.mozilla.org/en-US/docs/Web/API/Console/group) and this is exactly what composition-logger does.\n\ncomposition-logger logs each step of your composition in an organised manner without interuptting the data flow of your composition, making it effortless to debug and giving you continuous insight into your functional compositions.\n\n### Usage\n\ncomposition-logger exposes two functions:\n\n* `pipeWithLogs`: Compose from left to right [see pipe](http://ramdajs.com/docs/#pipe)\n\n* `composeWithLogs`: Compose from right to left [see compose](http://ramdajs.com/docs/#compose)\n\n#### Pipe\n\n```javascript\nimport { pipeWithLogs } from \"composition-logger\";\n\nconst divideByTwo = data =\u003e data / 2;\n\nconst sum = data =\u003e data.reduce((a, b) =\u003e a + b);\n\nconst addOne = data =\u003e data.map(item =\u003e item + 1);\n\nconst performCalculation = pipeWithLogs(addOne, sum, divideByTwo);\n\nperformCalculation([1, 4, 5, 6, 7]);\n```\n\nThe above example will log the following to the browser:\n\n\u003cdiv align=\"left\"\u003e\n  \u003cimg src=\"media/compositionOutput.png\" width=\"700\" /\u003e\n\u003c/div\u003e\n\n#### Compose\n\n```javascript\nimport { composeWithLogs } from \"composition-logger\";\n\nconst divideByTwo = data =\u003e data / 2;\n\nconst sum = data =\u003e data.reduce((a, b) =\u003e a + b);\n\nconst addOne = data =\u003e data.map(item =\u003e item + 1);\n\nconst performCalculation = composeWithLogs(divideByTwo, sum, addOne);\n\nperformCalculation([1, 4, 5, 6, 7]);\n```\n\nThe above example will log the following to the browser:\n\n\u003cdiv align=\"left\"\u003e\n  \u003cimg src=\"media/compositionOutput.png\" width=\"700\" /\u003e\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrady-lad%2Fcomposition-logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrady-lad%2Fcomposition-logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrady-lad%2Fcomposition-logger/lists"}