{"id":19138019,"url":"https://github.com/lemonpi/call-capture","last_synced_at":"2025-07-23T06:33:29.500Z","repository":{"id":57192996,"uuid":"86640348","full_name":"LemonPi/call-capture","owner":"LemonPi","description":"Wrap an object to capture all calls made to it for future analysis or calling","archived":false,"fork":false,"pushed_at":"2018-12-26T03:40:18.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-22T18:39:35.603Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/LemonPi.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":"2017-03-30T00:05:06.000Z","updated_at":"2018-12-26T03:40:20.000Z","dependencies_parsed_at":"2022-08-24T06:00:31.469Z","dependency_job_id":null,"html_url":"https://github.com/LemonPi/call-capture","commit_stats":null,"previous_names":["lemonpi/deferred"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/LemonPi/call-capture","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LemonPi%2Fcall-capture","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LemonPi%2Fcall-capture/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LemonPi%2Fcall-capture/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LemonPi%2Fcall-capture/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LemonPi","download_url":"https://codeload.github.com/LemonPi/call-capture/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LemonPi%2Fcall-capture/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266631474,"owners_count":23959419,"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","status":"online","status_checked_at":"2025-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-09T06:41:28.051Z","updated_at":"2025-07-23T06:33:29.474Z","avatar_url":"https://github.com/LemonPi.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## capture\nWrap around an object and capture sets on its properties and calls on its methods.\n\n## usage\n\n### node\n```javascript\nconst capture = require(\"call-capture\");\n```\n\n### browser\n```html\n\u003chtml\u003e\n\u003chead\u003e\n    \u003cmeta charset=\"UTF-8\"\u003e\n    \u003cscript src=\"src/capture.js\"\u003e\u003c/script\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n\u003cscript\u003e\n// capture is in the global scope\n\u003c/script\u003e\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n### deferring\n```javascript\n// assume we have a canvas on a webpage\nvar ctx = capture(canvas.getContext(\"2d\"));\n\n// call and set on the capture object, will not execute immediately\nctx.beginPath();\nctx.lineWidth = 5;\nctx.moveTo(5, 10);\nctx.lineTo(70, 60);\nctx.stroke();\n\n// examine queued commands\nconsole.log(ctx.queue[1]);\n\n// modify queued command arguments\nctx.queue[1].args[1] += 10;\t// now becomes ctx.moveTo(5, 20)\n\n// execute all queued commands\nctx.executeAll();\n\n// execute a specific one in the queue\nctx.queue[3].execute();\n\n// clear queued commands (won't clear automatically after executing)\nctx.clearQueue();\n```\n\n### indirect wrapping\nIf you don't have access to object creation (for example if it's done in a library),\nthen you can patch its creation function.\n\n```javascript\n// wrap around with canvas drawing\nvar oldGetContext = HTMLCanvasElement.prototype.getContext;\nHTMLCanvasElement.prototype.getContext = function () {\n    return capture(oldGetContext.apply(this, arguments));\n};\n```\n\nIt's not recommended to try wrapping the CanvasRenderingContext2D's prototype\ndirectly because it contains native calls.\n\n### immediate execution\nIf you don't actually to defer anything, but instead capture them, then that is available\nvia the immediatelyExecute option:\n\n```javascript\nvar ctx = capture(canvas.getContext(\"2d\"), {immediatelyExecute: true});\n```\n\nThis and other options can be configured by directly modifying the captured object:\n\n```javascript\nctx.opts.executeImmediately = false;\n```\n\n### pause/start capturing\nYou can suspend capture and execute commands immediately by calling\n\n```javascript\nctx.pauseCapture();\n// immediately executed commands on ctx...\nctx.resumeCapture();\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flemonpi%2Fcall-capture","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flemonpi%2Fcall-capture","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flemonpi%2Fcall-capture/lists"}