changed-http
raw JSON → 0.0.3 verified Sat Apr 25 auth: no javascript abandoned
Polls HTTP/HTTPS resources and fires events when the response body changes. Version 0.0.3 is the latest (and only) release as of early 2013, with no updates since. Minimalist library using Node.js http/https modules, gzip decoding, and a custom compare function. Unlike general-purpose polling libraries, it is specifically scoped to monitoring HTTP content changes. No longer maintained; consider using newer alternatives or the built-in fetch with manual polling.
Common errors
error Error: Cannot find module 'changed-http' ↓
cause Package not installed correctly; old package name or npm install used wrong syntax.
fix
npm install robinjmurphy/changed
error TypeError: changed.Resource is not a constructor ↓
cause Import as default using import statement; no default export.
fix
Use const changed = require('changed-http'); then new changed.Resource(...)
error TypeError: resource.on is not a function ↓
cause Missing new keyword when constructing Resource.
fix
Use new changed.Resource(url, options)
error AssertionError: false == true (in compare function) ↓
cause Custom compare function returns a falsy value when change is detected, or truthy when no change.
fix
Return true when content differs, false otherwise.
Warnings
gotcha Package is unmaintained; no updates since 2013. May have unresolved HTTP parsing issues or vulnerabilities. ↓
fix Consider using modern alternatives like node-fetch with manual polling or chokidar for file changes.
gotcha No TypeScript types. No d.ts files; using with TS requires manual type declarations. ↓
fix Create a custom .d.ts file or use as any.
gotcha The compare function overrides the default string comparison. If it returns false in a truthy check, no 'changed' event fires. ↓
fix Ensure compare returns a boolean: true if changed, false otherwise.
gotcha startPolling() only accepts one argument (interval). It does not check for valid number; passing undefined or null uses default 10000ms. ↓
fix Always pass a positive number.
Install
npm install changed-http yarn add changed-http pnpm add changed-http Imports
- changed wrong
import changed from 'changed-http';correctconst changed = require('changed-http'); - Resource wrong
const { Resource } = require('changed-http').Resource;correctconst { Resource } = require('changed-http'); - logger wrong
changed.logger = 'custom logger';correctchanged.logger = winston;
Quickstart
const changed = require('changed-http');
const resource = new changed.Resource('http://example.com', {
compare: function(current, previous) {
return current !== previous;
}
});
resource.on('changed', function(current, previous) {
console.log('Resource changed!');
});
resource.startPolling(5000);