{"id":20957521,"url":"https://github.com/brandontruggles/diffhook","last_synced_at":"2025-03-13T06:13:59.047Z","repository":{"id":57212170,"uuid":"107977176","full_name":"brandontruggles/diffhook","owner":"brandontruggles","description":"Asynchronous webhooks for monitoring changes in external webpages.","archived":false,"fork":false,"pushed_at":"2017-10-27T03:22:07.000Z","size":38,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-09T22:35:35.509Z","etag":null,"topics":["ajax","async","diff","javascript","monitoring","webhook","webhooks","website"],"latest_commit_sha":null,"homepage":null,"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/brandontruggles.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-23T12:11:36.000Z","updated_at":"2022-08-09T17:05:08.000Z","dependencies_parsed_at":"2022-09-06T08:21:51.686Z","dependency_job_id":null,"html_url":"https://github.com/brandontruggles/diffhook","commit_stats":null,"previous_names":["brandonrninefive/diffhook"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brandontruggles%2Fdiffhook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brandontruggles%2Fdiffhook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brandontruggles%2Fdiffhook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brandontruggles%2Fdiffhook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brandontruggles","download_url":"https://codeload.github.com/brandontruggles/diffhook/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243352034,"owners_count":20276916,"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":["ajax","async","diff","javascript","monitoring","webhook","webhooks","website"],"created_at":"2024-11-19T01:34:14.160Z","updated_at":"2025-03-13T06:13:59.028Z","avatar_url":"https://github.com/brandontruggles.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"diffhook [![license](https://img.shields.io/github/license/brandonrninefive/diffhook.svg)](https://github.com/brandonrninefive/diffhook/blob/master/LICENSE.md) [![npm version](https://img.shields.io/npm/v/diffhook.svg)](https://www.npmjs.com/package/diffhook) [![Build Status](https://travis-ci.org/brandonrninefive/diffhook.svg?branch=master)](https://travis-ci.org/brandonrninefive/diffhook) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/brandonrninefive/diffhook/issues)  \n===\n\nAsynchronous webhooks for monitoring changes in external webpages. \n\nGetting Started\n==\n\nUsing diffhook is as simple as the following (using ES6 syntax):\n\n`npm i diffhook` or `yarn add diffhook`\n\n```javascript\nimport diffhook from 'diffhook';\n\nvar hook = null;\n\nfunction testFunc(oldResponse, newResponse) {\n\tconsole.log(\"Old Response:\");\n\tconsole.log(oldResponse);\n\tconsole.log(\"New Response:\");\n\tconsole.log(newResponse);\n\tclearInterval(hook);\n}\n\nvar hook = diffhook(\"https://brandonrninefive.github.io\", 10000, testFunc, \"Tick\");\n```\n\nThe above setup will make an AJAX call to `https://brandonrninefive.github.io` and log the string `\"Tick\"` every 10 seconds. However, if a response has not been fully returned from the last AJAX call, or a connection error occurs, the next `\"Tick\"` will be logged, but a new AJAX call will not be sent out. Any connection errors will also be logged. `testFunc` will only be called if the AJAX request is successful, and the contents of the response differs between calls.\n\n`diffhook` returns a call to `setInterval()`, meaning the hook can be stopped with `clearInterval()`, such as in the example above.\n\nParameters\n==\n\n`url` - (String) The URL of the webpage to monitor.\n\n`interval` - (Number) The interval between AJAX calls (in milliseconds).\n\n`callback` - (Function) The function to execute when a diff occurs between AJAX calls. This function is passed two parameters, `oldResponse`, and `newResponse`, representing the last and current contents of the AJAX response, respectfully.\n\n`pollingStr` - (String) A string to log to the console each time an AJAX call is made. Passing `null` will prevent any logging.\n\nInterval Courtesy\n==\n\nSince making frequent requests to URLs can throttle the response times of servers, setting `interval` to be too low could be perceived as a network attack. For this reason, it is highly recommended that you set `interval` to be a minimum of multiple seconds, or even minutes, in length. If you want to use a smaller `interval` value, do so at your own risk.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrandontruggles%2Fdiffhook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrandontruggles%2Fdiffhook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrandontruggles%2Fdiffhook/lists"}