Socket
Socket
Sign inDemoInstall

fsevents

Package Overview
Dependencies
0
Maintainers
2
Versions
67
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.3 to 2.2.0

85

fsevents.d.ts

@@ -1,55 +0,46 @@

declare type Event =
| 'created'
| 'cloned'
| 'modified'
| 'deleted'
| 'moved'
| 'root-changed'
| 'unknown';
declare type Type = 'file' | 'directory' | 'symlink';
declare type Event = "created" | "cloned" | "modified" | "deleted" | "moved" | "root-changed" | "unknown";
declare type Type = "file" | "directory" | "symlink";
declare type FileChanges = {
inode: boolean;
finder: boolean;
access: boolean;
xattrs: boolean;
inode: boolean;
finder: boolean;
access: boolean;
xattrs: boolean;
};
declare type Info = {
event: Event;
path: string;
type: Type;
changes: FileChanges;
flags: number;
event: Event;
path: string;
type: Type;
changes: FileChanges;
flags: number;
};
declare type WatchHandler = (path: string, flags: number, id: string) => void;
export declare function watch(
path: string,
handler: WatchHandler,
): () => Promise<void>;
export declare function watch(path: string, handler: WatchHandler): () => Promise<void>;
export declare function watch(path: string, since: number, handler: WatchHandler);
export declare function getInfo(path: string, flags: number): Info;
export declare const constants: {
None: 0x00000000;
MustScanSubDirs: 0x00000001;
UserDropped: 0x00000002;
KernelDropped: 0x00000004;
EventIdsWrapped: 0x00000008;
HistoryDone: 0x00000010;
RootChanged: 0x00000020;
Mount: 0x00000040;
Unmount: 0x00000080;
ItemCreated: 0x00000100;
ItemRemoved: 0x00000200;
ItemInodeMetaMod: 0x00000400;
ItemRenamed: 0x00000800;
ItemModified: 0x00001000;
ItemFinderInfoMod: 0x00002000;
ItemChangeOwner: 0x00004000;
ItemXattrMod: 0x00008000;
ItemIsFile: 0x00010000;
ItemIsDir: 0x00020000;
ItemIsSymlink: 0x00040000;
ItemIsHardlink: 0x00100000;
ItemIsLastHardlink: 0x00200000;
OwnEvent: 0x00080000;
ItemCloned: 0x00400000;
None: 0x00000000;
MustScanSubDirs: 0x00000001;
UserDropped: 0x00000002;
KernelDropped: 0x00000004;
EventIdsWrapped: 0x00000008;
HistoryDone: 0x00000010;
RootChanged: 0x00000020;
Mount: 0x00000040;
Unmount: 0x00000080;
ItemCreated: 0x00000100;
ItemRemoved: 0x00000200;
ItemInodeMetaMod: 0x00000400;
ItemRenamed: 0x00000800;
ItemModified: 0x00001000;
ItemFinderInfoMod: 0x00002000;
ItemChangeOwner: 0x00004000;
ItemXattrMod: 0x00008000;
ItemIsFile: 0x00010000;
ItemIsDir: 0x00020000;
ItemIsSymlink: 0x00040000;
ItemIsHardlink: 0x00100000;
ItemIsLastHardlink: 0x00200000;
OwnEvent: 0x00080000;
ItemCloned: 0x00400000;
};
export {}
export {};

@@ -7,25 +7,30 @@ /*

/* jshint node:true */
'use strict';
"use strict";
if (process.platform !== 'darwin') {
if (process.platform !== "darwin") {
throw new Error(`Module 'fsevents' is not compatible with platform '${process.platform}'`);
}
const Native = require('./fsevents.node');
const Native = require("./fsevents.node");
const events = Native.constants;
function watch(path, handler) {
if (typeof path !== 'string') {
function watch(path, since, handler) {
if (typeof path !== "string") {
throw new TypeError(`fsevents argument 1 must be a string and not a ${typeof path}`);
}
if (typeof handler !== 'function') {
throw new TypeError(`fsevents argument 2 must be a function and not a ${typeof handler}`);
if ("function" === typeof since && "undefined" === typeof handler) {
handler = since;
since = Native.flags.SinceNow;
}
if (typeof since !== "number") {
throw new TypeError(`fsevents argument 2 must be a number and not a ${typeof since}`);
}
if (typeof handler !== "function") {
throw new TypeError(`fsevents argument 3 must be a function and not a ${typeof handler}`);
}
let instance = Native.start(path, handler);
let instance = Native.start(Native.global, path, since, handler);
if (!instance) throw new Error(`could not watch: ${path}`);
return () => {
const result = instance
? Promise.resolve(instance).then(Native.stop)
: Promise.resolve(undefined);
const result = instance ? Promise.resolve(instance).then(Native.stop) : Promise.resolve(undefined);
instance = undefined;

@@ -42,3 +47,3 @@ return result;

type: getFileType(flags),
changes: getFileChanges(flags)
changes: getFileChanges(flags),
};

@@ -48,5 +53,5 @@ }

function getFileType(flags) {
if (events.ItemIsFile & flags) return 'file';
if (events.ItemIsDir & flags) return 'directory';
if (events.ItemIsSymlink & flags) return 'symlink';
if (events.ItemIsFile & flags) return "file";
if (events.ItemIsDir & flags) return "directory";
if (events.ItemIsSymlink & flags) return "symlink";
}

@@ -60,10 +65,10 @@ function anyIsTrue(obj) {

function getEventType(flags) {
if (events.ItemRemoved & flags) return 'deleted';
if (events.ItemRenamed & flags) return 'moved';
if (events.ItemCreated & flags) return 'created';
if (events.ItemModified & flags) return 'modified';
if (events.RootChanged & flags) return 'root-changed';
if (events.ItemCloned & flags) return 'cloned';
if (anyIsTrue(flags)) return 'modified';
return 'unknown';
if (events.ItemRemoved & flags) return "deleted";
if (events.ItemRenamed & flags) return "moved";
if (events.ItemCreated & flags) return "created";
if (events.ItemModified & flags) return "modified";
if (events.RootChanged & flags) return "root-changed";
if (events.ItemCloned & flags) return "cloned";
if (anyIsTrue(flags)) return "modified";
return "unknown";
}

@@ -75,3 +80,3 @@ function getFileChanges(flags) {

access: !!(events.ItemChangeOwner & flags),
xattrs: !!(events.ItemXattrMod & flags)
xattrs: !!(events.ItemXattrMod & flags),
};

@@ -78,0 +83,0 @@ }

{
"name": "fsevents",
"version": "2.1.3",
"version": "2.2.0",
"description": "Native Access to MacOS FSEvents",

@@ -5,0 +5,0 @@ "main": "fsevents.js",

@@ -73,2 +73,7 @@ # fsevents [![NPM](https://nodei.co/npm/fsevents.png)](https://nodei.co/npm/fsevents/)

## Troubleshooting
- I'm getting `EBADPLATFORM` `Unsupported platform for fsevents` error.
- It's fine, nothing is broken. fsevents is macos-only. Other platforms are skipped. If you want to hide this warning, report a bug to NPM bugtracker asking them to hide ebadplatform warnings by default.
## License

@@ -75,0 +80,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc