{"id":16758637,"url":"https://github.com/simsieg/megasniff","last_synced_at":"2025-06-22T14:05:37.683Z","repository":{"id":57294226,"uuid":"153474338","full_name":"simsieg/megasniff","owner":"simsieg","description":"Better debugging for chained functions","archived":false,"fork":false,"pushed_at":"2018-10-18T13:11:00.000Z","size":7,"stargazers_count":9,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-02T04:58:35.622Z","etag":null,"topics":["chain","debug","log","logger","megasniff","npm","npm-module","npm-package","promise","stream"],"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/simsieg.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":"2018-10-17T14:48:56.000Z","updated_at":"2019-01-10T15:21:51.000Z","dependencies_parsed_at":"2022-08-29T08:02:11.871Z","dependency_job_id":null,"html_url":"https://github.com/simsieg/megasniff","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simsieg%2Fmegasniff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simsieg%2Fmegasniff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simsieg%2Fmegasniff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simsieg%2Fmegasniff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simsieg","download_url":"https://codeload.github.com/simsieg/megasniff/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248261913,"owners_count":21074225,"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":["chain","debug","log","logger","megasniff","npm","npm-module","npm-package","promise","stream"],"created_at":"2024-10-13T04:05:51.469Z","updated_at":"2025-04-10T17:13:59.969Z","avatar_url":"https://github.com/simsieg.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Megasniff\n\nBetter debugging for chained functions (promises, streams, etc.).\nInspired by [supersniff](https://github.com/mpj/supersniff), but with these improvements in mind:\n\n- [x] Support for custom loggers (like [bunyan](https://github.com/trentm/node-bunyan), [winston](https://github.com/winstonjs/winston), or other services)\n- [x] Pre- and suffix support\n- [x] No forced `tag`\n- [x] Using error levels for errors\n\nThings to do:\n\n- [ ] Custom configureable log levels\n- [ ] Decorator functions (e.g. ```error =\u003e error.message```)\n\n\n## Motivation\n\nCan be found [here](https://github.com/mpj/supersniff#why-this-is-useful).\nIt shall be a readable replacement for:\n\n```javascript\ngetData()\n  .then(data =\u003e {\n    console.info(data)\n    return data\n  })\n  .then(transformData)\n```\n\n## Installation\n\n```shell\nnpm install megasniff\n```\n\n## Examples\n\n```javascript\nconst megasniff = require('megasniff')\n\nconst reveersedList = new Promise(resolve =\u003e resolve([3, 1, 2]))\n  .then(megasniff)\n  .then(list =\u003e list.sort())\n  .then(megasniff)\n  .then(list =\u003e list.reverse())\n  .then(megasniff)\n```\n\nThis yields in the console:\n\n```javascript\n[ 3, 1, 2 ]\n[ 1, 2, 3 ]\n[ 3, 2, 1 ]\n```\n\n```javascript\nconst megasniff = require('megasniff')\n\nnew Promise(resolve =\u003e resolve('Good'))\n  .then(megasniff.config({ suffix: `Value at ${new Date()}:` }))\n```\nThis yields on stdout:\n```shell\nGood Value at Wed Oct 17 2018 15:47:26 GMT+0200 (Central European Summer Time)\n```\n\n```javascript\nconst megasniff = require('megasniff')\nconst logger = console\n\nnew Promise((resolve, reject) =\u003e reject(new Error('Bad')))\n  .catch(megasniff.config({ suffix: '.. We are doomed' }))\n  .catch(error =\u003e error)\n```\n\nThis yields on stderr:\n```shell\nError: Bad ... We are doomed\n```\n\n## API\n\n### Default Usage:\n\n```javascript\nconst megasniff = require('megasniff')\n\nconst sortedList = new Promise(resolve =\u003e resolve([3, 1, 2]))\n  .then(megasniff)\n  .then(list =\u003e list.sort())\n  .then(megasniff)\n```\n\n`megasniff` is a function that logs and returns the passed value.\nThe value is logged either to stdout or sterr depending on the passed value.\n\n### Configuration:\n\n```javascript\nconst megasniff = require('megasniff')\nconst logger = console\nnew Promise(resolve =\u003e resolve('Good Software'))\n  .then(megasniff.config({ prefix: `[megasniff]`, logger }))\n\n```\n`megasniff.config` takes an object as argument.\nMegasniff can be configured with these optional parameters:\n\n| key    | value                             |\n|--------|-----------------------------------|\n| log    | External logger                   |\n| logger | Other key for external logger     |\n| prefix | Will be prefixed the logged value |\n| suffix | Will be suffixed the logged value |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimsieg%2Fmegasniff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimsieg%2Fmegasniff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimsieg%2Fmegasniff/lists"}