{"id":20806319,"url":"https://github.com/nodesource/ah-prune","last_synced_at":"2025-09-13T16:35:03.150Z","repository":{"id":57174688,"uuid":"79591359","full_name":"nodesource/ah-prune","owner":"nodesource","description":"Prune specific types of async hook resources from a collected map.","archived":false,"fork":false,"pushed_at":"2017-03-09T11:20:13.000Z","size":1182,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-25T04:01:26.339Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://nodesource.github.io/ah-prune","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/nodesource.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-20T19:38:02.000Z","updated_at":"2021-12-26T19:11:37.000Z","dependencies_parsed_at":"2022-09-03T08:51:49.189Z","dependency_job_id":null,"html_url":"https://github.com/nodesource/ah-prune","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodesource%2Fah-prune","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodesource%2Fah-prune/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodesource%2Fah-prune/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nodesource%2Fah-prune/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nodesource","download_url":"https://codeload.github.com/nodesource/ah-prune/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243152876,"owners_count":20244657,"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":[],"created_at":"2024-11-17T19:19:17.061Z","updated_at":"2025-03-12T03:41:31.482Z","avatar_url":"https://github.com/nodesource.png","language":"JavaScript","readme":"# ah-prune [![build status](https://secure.travis-ci.org/nodesource/ah-prune.png)](http://travis-ci.org/nodesource/ah-prune)\n\nPrune specific types of async hook resources from a collected map.\n\n```js\nconst prune = require('ah-prune')\n\n// Removing all TickObject\nconst noticks = prune({ activities, prune: new Set([ 'TickObject' ]) })\n\n// Removing everything but TCPWRAP\nconst onlytcpwrap = prune({ activities, keep: new Set([ 'TCPWRAP' ]) })\n\n// Removing everything but a specific id via a custom keep function\nconst onlytcp1 = prune({\n    activities\n  , keepFn(type, activity) { return activity.id === 'tcp:1' }\n})\n```\n\n## Installation\n\n    npm install ah-prune\n\n## [API](https://nodesource.github.io/ah-prune/)\n\n\u003c!-- Generated by documentation.js. Update this documentation by updating the source code. --\u003e\n\n### prune\n\nPrunes the supplied async hook activities according to `prune` or\n`keep` option.\nIt repoints the triggerIds in the process so that the graph is\npreserved.\n\nOnly either `prune` or `keep` maybe supplied at once.\n\nThe `activities` passed are not modified, instead a clone is made before\nthe pruning step, unless `copy` is set to `false`\n\n**Parameters**\n\n-   `$0` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** options to configure the pruning step\n    -   `$0.activities` **[Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)\u0026lt;[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)\u003e** the activities to be pruned\n    -   `$0.prune` **[Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)\u0026lt;[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)\u003e** if supplied all activities of types supplied\n        in the Set are removed\n    -   `$0.keep` **[Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set)\u0026lt;[String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)\u003e** if supplied all activities of types NOT\n        supplied in the Set are removed\n    -   `$0.keepFn` **[function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** `function (type, activity)` if supplied will be\n        used as the predicate function to determine if an activity is removed.\n        Return `true` to keep the activity, `false` to remove it\n    -   `$0.copy` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** if set, the activities are cloned before\n        modification, otherwise they are modified in place, default: `true`\n\nReturns **[Map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map)\u0026lt;[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)\u003e** the pruned activities\n\n## License\n\nMIT\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnodesource%2Fah-prune","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnodesource%2Fah-prune","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnodesource%2Fah-prune/lists"}