Comparing version 2.1.0 to 2.1.1
104
index.d.ts
declare module 'nsfw' { | ||
interface NsfwFunction { | ||
(watchPath: string, eventCallback: (events: Array<FileChangeEvent>) => void, options?: Partial<Options>): Promise<NSFW>; | ||
actions: typeof ActionType; | ||
} | ||
export = NsfwFunction; | ||
/** Returns a Promise that resolves to the created NSFW Object. | ||
@@ -12,56 +10,60 @@ * @param {watchPath} watchPath - the path that nsfw should watchPath | ||
*/ | ||
var func: NsfwFunction; | ||
export default func; | ||
function NsfwFunction(watchPath: string, eventCallback: (events: Array<NsfwFunction.FileChangeEvent>) => void, options?: Partial<NsfwFunction.Options>): Promise<NsfwFunction.NSFW>; | ||
namespace NsfwFunction { | ||
export interface NSFW { | ||
/** Returns a Promise that resolves after NSFW has paused listening to events. */ | ||
pause: () => Promise<void>; | ||
/** Returns a Promise that resolves after NSFW has resumed listening to events. */ | ||
resume: () => Promise<void>; | ||
/** Returns a Promise that resolves when the NSFW object has started watching the path. */ | ||
start: () => Promise<void>; | ||
/** Returns a Promise that resolves when NSFW object has halted. */ | ||
stop: () => Promise<void>; | ||
} | ||
export const actions: typeof ActionType; | ||
export const enum ActionType { | ||
CREATED = 0, | ||
DELETED = 1, | ||
MODIFIED = 2, | ||
RENAMED = 3 | ||
} | ||
export interface NSFW { | ||
/** Returns a Promise that resolves after NSFW has paused listening to events. */ | ||
pause: () => Promise<void>; | ||
/** Returns a Promise that resolves after NSFW has resumed listening to events. */ | ||
resume: () => Promise<void>; | ||
/** Returns a Promise that resolves when the NSFW object has started watching the path. */ | ||
start: () => Promise<void>; | ||
/** Returns a Promise that resolves when NSFW object has halted. */ | ||
stop: () => Promise<void>; | ||
} | ||
export type CreatedFileEvent = GenericFileEvent<ActionType.CREATED>; | ||
export type DeletedFileEvent = GenericFileEvent<ActionType.DELETED>; | ||
export type ModifiedFileEvent = GenericFileEvent<ActionType.MODIFIED>; | ||
export type FileChangeEvent = CreatedFileEvent | DeletedFileEvent | ModifiedFileEvent | RenamedFileEvent; | ||
export const enum ActionType { | ||
CREATED = 0, | ||
DELETED = 1, | ||
MODIFIED = 2, | ||
RENAMED = 3 | ||
} | ||
export interface RenamedFileEvent { | ||
/** the type of event that occurred */ | ||
action: ActionType.RENAMED; | ||
/** the directory before a rename */ | ||
directory: string; | ||
/** the name of the file before a rename*/ | ||
oldFile: string; | ||
/** the new location of the file(only useful on linux) */ | ||
newDirectory: string; | ||
/** the name of the file after a rename */ | ||
newFile: string; | ||
} | ||
export type CreatedFileEvent = GenericFileEvent<ActionType.CREATED>; | ||
export type DeletedFileEvent = GenericFileEvent<ActionType.DELETED>; | ||
export type ModifiedFileEvent = GenericFileEvent<ActionType.MODIFIED>; | ||
export type FileChangeEvent = CreatedFileEvent | DeletedFileEvent | ModifiedFileEvent | RenamedFileEvent; | ||
export interface GenericFileEvent<T extends ActionType> { | ||
/** the type of event that occurred */ | ||
action: T; | ||
/** the location the event took place */ | ||
directory: string; | ||
/** the name of the file that was changed(Not available for rename events) */ | ||
file: string; | ||
export interface RenamedFileEvent { | ||
/** the type of event that occurred */ | ||
action: ActionType.RENAMED; | ||
/** the directory before a rename */ | ||
directory: string; | ||
/** the name of the file before a rename*/ | ||
oldFile: string; | ||
/** the new location of the file(only useful on linux) */ | ||
newDirectory: string; | ||
/** the name of the file after a rename */ | ||
newFile: string; | ||
} | ||
export interface GenericFileEvent<T extends ActionType> { | ||
/** the type of event that occurred */ | ||
action: T; | ||
/** the location the event took place */ | ||
directory: string; | ||
/** the name of the file that was changed(Not available for rename events) */ | ||
file: string; | ||
} | ||
interface Options { | ||
/** time in milliseconds to debounce the event callback */ | ||
debounceMS?: number; | ||
/** callback to fire in the case of errors */ | ||
errorCallback: (err: any) => void | ||
} | ||
} | ||
interface Options { | ||
/** time in milliseconds to debounce the event callback */ | ||
debounceMS?: number; | ||
/** callback to fire in the case of errors */ | ||
errorCallback: (err: any) => void | ||
} | ||
} |
{ | ||
"name": "nsfw", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "A simple file watcher for Node", | ||
@@ -5,0 +5,0 @@ "main": "js/src/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
76256
147