{"id":13392748,"url":"https://github.com/Axosoft/nsfw","last_synced_at":"2025-03-13T18:31:56.074Z","repository":{"id":35861262,"uuid":"40146305","full_name":"Axosoft/nsfw","owner":"Axosoft","description":"A super fast and scaleable file watcher that provides a consistent interface on Linux, OSX and Windows","archived":false,"fork":false,"pushed_at":"2023-05-18T18:16:46.000Z","size":806,"stargazers_count":899,"open_issues_count":63,"forks_count":112,"subscribers_count":28,"default_branch":"master","last_synced_at":"2024-05-21T14:24:29.751Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","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/Axosoft.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-08-03T20:27:14.000Z","updated_at":"2024-06-18T12:24:57.045Z","dependencies_parsed_at":"2024-06-18T12:37:18.942Z","dependency_job_id":null,"html_url":"https://github.com/Axosoft/nsfw","commit_stats":{"total_commits":233,"total_committers":33,"mean_commits":"7.0606060606060606","dds":0.592274678111588,"last_synced_commit":"13a84d97c0d778535bbc3baebcc6dc1216a26325"},"previous_names":["axosoft/node-simple-file-watcher"],"tags_count":36,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Axosoft%2Fnsfw","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Axosoft%2Fnsfw/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Axosoft%2Fnsfw/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Axosoft%2Fnsfw/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Axosoft","download_url":"https://codeload.github.com/Axosoft/nsfw/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240400324,"owners_count":19795331,"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-07-30T17:00:36.514Z","updated_at":"2025-03-13T18:31:55.808Z","avatar_url":"https://github.com/Axosoft.png","language":"C++","funding_links":[],"categories":["C++","Uncategorized"],"sub_categories":["Uncategorized"],"readme":"# node-sentinel-file-watcher\n\u003ctable\u003e\n  \u003cthead\u003e\n    \u003ctr\u003e\n      \u003cth\u003eLinux\u003c/th\u003e\n      \u003cth\u003eOS X\u003c/th\u003e\n      \u003cth\u003eWindows\u003c/th\u003e\n    \u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd colspan=\"2\" align=\"center\"\u003e\n      \u003ca href=\"https://travis-ci.org/Axosoft/nsfw\"\u003e\u003cimg src=\"https://travis-ci.org/Axosoft/nsfw.svg?branch=master\"\u003e\u003c/a\u003e\n      \u003c/td\u003e\n      \u003ctd align=\"center\"\u003e\n        \u003ca href=\"https://ci.appveyor.com/project/implausible/node-simple-file-watcher\"\u003e\u003cimg src=\"https://ci.appveyor.com/api/projects/status/79ejlq7e60kjmbl6?svg=true\"\u003e\u003c/a\u003e\n      \u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\nA simple file watcher library for node.\n\n## Why NSFW?\nNSFW is a native abstraction for Linux, Windows, and OSX file watching services which tries to keep a consistent interface and feature set across operating systems. NSFW offers recursive file watching into deep file systems all at no additional cost to the Javascript layer. In Linux, NSFW recursively builds an inotify watch tree natively, which collects events concurrently to the javascript thread. In OSX, NSFW utilizes the FSEventsService, which recursively watches for file system changes in a specified directory. In Windows, NSFW implements a server around the ReadDirectoryChangesW method.\n\nWhen NSFW has events and is not being throttled, it will group those events in the order that they occurred and report them to the Javascript layer in a single callback. This is an improvement over services that utilize Node FS.watch, which uses a callback for every file event that is triggered. Every callback FS.watch makes to the event queue is a big bonus to NSFW's performance when watching large file system operations, because NSFW will only make 1 callback with many events within a specified throttle period.\n\nSo why NSFW? Because it has a consistent and minimal footprint in the Javascript layer, manages recursive watching for you, and is super easy to use.\n\n## Usage\n\n```js\nvar nsfw = require('nsfw');\n\nvar watcher1;\nreturn nsfw(\n  'dir1',\n  function(events) {\n    // handle events\n  })\n  .then(function(watcher) {\n    watcher1 = watcher;\n    return watcher.start();\n  })\n  .then(function() {\n    // we are now watching dir1 for events!\n\n    // To stop watching\n    watcher1.stop()\n  });\n\n// With options\nvar watcher2;\nreturn nsfw(\n  'dir2',\n  function(events) {\n  // handles other events\n  },\n  {\n    debounceMS: 250,\n    errorCallback(errors) {\n      //handle errors\n    },\n    excludedPaths: ['dir2/node_modules']\n  })\n  .then(function(watcher) {\n    watcher2 = watcher;\n    return watcher.start();\n  })\n  .then(function() {\n    // we are now watching dir2 for events!\n\n    // we can update excludedPaths array\n    return watcher2.updateExcludedPaths(['dir2/node_modules', '.git']);\n  })\n  .then(function() {\n    // To stop watching\n    watcher2.stop();\n  })\n```\n\n## Options\n\n- debounceMS: delays notifications emitted by the library. Default 500 ms.\n- errorCallback(errors): the library will call this callback when an error happens.\nAt the moment when an error happens the service does not stop, this may change in the near future.\n- excludedPaths: array with the absolute paths we want to exclude watching.\nYou can update the excludedPaths array without restarting the service using the `updateExcludedPaths` function\n\n## Callback Argument\n\nAn array of events as they have happened in a directory, it's children, or to a file.\n```js\n[\n  {\n    \"action\": 2, // nsfw.actions.MODIFIED\n    \"directory\": \"/home/nsfw/watchDir\",\n    \"file\": \"file1.ext\"\n  },\n  {\n    \"action\": 0, // nsfw.actions.CREATED\n    \"directory\": \"/home/nsfw/watchDir\",\n    \"file\": \"folder\"\n  },\n  {\n    \"action\": 1, // nsfw.actions.DELETED\n    \"directory\": \"home/nsfw/watchDir/testFolder\",\n    \"file\": \"test.ext\"\n  },\n  {\n    \"action\": 3, // nsfw.actions.RENAMED\n    \"directory\": \"home/nsfw/watchDir\",\n    \"oldFile\": \"oldname.ext\",\n    \"newDirectory\": \"home/nsfw/watchDir/otherDirectory\"\n    \"newFile\": \"newname.ext\"\n  }\n]\n```\n\nEvent are enumerated by the nsfw.actions enumeration\n```js\nnsfw.actions = {\n  CREATED: 0,\n  DELETED: 1,\n  MODIFIED: 2,\n  RENAMED: 3\n};\n```\n\n## Installation\nNSFW is a native node module and requires Node-Gyp to be functional before you can install it.\nMake sure you have completed installing all of the dependencies listed for [Node-Gyp](https://github.com/nodejs/node-gyp) on your operating system.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAxosoft%2Fnsfw","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAxosoft%2Fnsfw","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAxosoft%2Fnsfw/lists"}