{"id":23789953,"url":"https://github.com/blackglory/extra-watcher","last_synced_at":"2026-02-26T08:40:40.615Z","repository":{"id":65523099,"uuid":"473943727","full_name":"BlackGlory/extra-watcher","owner":"BlackGlory","description":"🌿","archived":false,"fork":false,"pushed_at":"2025-04-13T13:47:49.000Z","size":443,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-26T02:24:28.119Z","etag":null,"topics":["library","nodejs","npm-package","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/extra-watcher","language":"TypeScript","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/BlackGlory.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-25T09:21:11.000Z","updated_at":"2025-04-13T13:47:52.000Z","dependencies_parsed_at":"2025-02-21T12:43:09.982Z","dependency_job_id":"03ebe834-b128-434f-bd6b-b14ffbbf0bce","html_url":"https://github.com/BlackGlory/extra-watcher","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/BlackGlory/extra-watcher","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlackGlory%2Fextra-watcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlackGlory%2Fextra-watcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlackGlory%2Fextra-watcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlackGlory%2Fextra-watcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BlackGlory","download_url":"https://codeload.github.com/BlackGlory/extra-watcher/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlackGlory%2Fextra-watcher/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272324338,"owners_count":24914398,"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-08-27T02:00:09.397Z","response_time":76,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","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":["library","nodejs","npm-package","typescript"],"created_at":"2025-01-01T17:17:47.793Z","updated_at":"2026-02-26T08:40:40.581Z","avatar_url":"https://github.com/BlackGlory.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# extra-watcher\n## Install\n```sh\nnpm install --save extra-watcher\n# or\nyarn add extra-watcher\n```\n\n## API\n### DirectoryWatcher\n```ts\ntype Event =\n| ICreatedEvent\n| IModifiedEvent\n| IDeletedEvent\n\ninterface ICreatedEvent {\n  type: 'created'\n  target: Target\n  pathname: string\n}\n\ninterface IModifiedEvent {\n  type: 'modified'\n  target: Target.File\n  pathname: string\n}\n\ninterface IDeletedEvent {\n  type: 'deleted'\n  target: Target\n  pathname: string\n}\n\nenum Target {\n  File = 'file'\n, Directory = 'directory'\n}\n\nclass DirectoryWatcher {\n  events: readonly Event[]\n\n  constructor(dirname: string)\n\n  observe(): Observable\u003cEvent\u003e\n  start(): Promise\u003cvoid\u003e\n  stop(): void\n  reset(): void\n\n  isChanged(): boolean\n  isFileCreated(filename: string): boolean\n  isDirectoryCreated(dirname: string): boolean\n  isFileModified(filename: string): boolean\n  isDirectoryModified(dirname: string): boolean\n  isFileDeleted(filename: string): boolean\n  isDirectoryDeleted(dirname: string): boolean\n}\n```\n\nDirectoryWatcher based on event sourcing, `reset` can clear events.\nA watcher can only be started and stopped once.\n\nThe following method checks \"whether this condition is eventually true\",\nnot \"whether this event has occurred\":\n- `isFileCreated`\n- `isDirectoryCreated`\n- `isFileModified`\n- `isDirectoryModified`\n- `isFileDeleted`\n- `isDirectoryDeleted`\n\n### FileWatcher\n```ts\ntype Event =\n| ICreatedEvent\n| IModifiedEvent\n| IDeletedEvent\n\ninterface ICreatedEvent {\n  type: 'created'\n}\n\ninterface IModifiedEvent {\n  type: 'modified'\n}\n\ninterface IDeletedEvent {\n  type: 'deleted'\n}\n\nclass FileWatcher {\n  events: readonly Event[]\n\n  constructor(filename: string)\n\n  observe(): Observable\u003cEvent\u003e\n  start(): Promise\u003cvoid\u003e\n  stop(): void\n  reset(): void\n\n  isChanged(): boolean\n  isCreated(): boolean\n  isModified(): boolean\n  isDeleted(): boolean\n}\n```\n\nFileWatcher based on event sourcing, `reset` can clear events.\nA watcher can only be started and stopped once.\n\nThe following method checks \"whether this condition is eventually true\",\nnot \"whether this event has occurred\":\n- `isCreated`\n- `isModified`\n- `isDeleted`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblackglory%2Fextra-watcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblackglory%2Fextra-watcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblackglory%2Fextra-watcher/lists"}