Skip to content

Commit

Permalink
watcher-nodejs: expose the effect time
Browse files Browse the repository at this point in the history
  • Loading branch information
Will committed Oct 18, 2024
1 parent 20ba1de commit bf4e5f5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion watcher-nodejs/lib/watcher-napi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ static napi_value event_to_js_obj(napi_env env, wtr_watcher_event* event)
napi_value effect_type = NULL;
napi_value path_type = NULL;
napi_create_object(env, &event_obj);
napi_create_bigint_int64(env, event->effect_time, &effect_time);
napi_create_int64(env, event->effect_time, &effect_time);
napi_create_string_utf8(env, event->path_name, NAPI_AUTO_LENGTH, &path_name);
if (event->associated_path_name) {
napi_create_string_utf8(env, event->associated_path_name, NAPI_AUTO_LENGTH, &associated_path_name);
Expand Down
3 changes: 3 additions & 0 deletions watcher-nodejs/lib/watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ export enum EffectType {
}

export interface Event {
effectTime: number;
pathName: string;
effectType: EffectType;
pathType: PathType;
associatedPathName: string | null;
}

interface CEvent {
effectTime: number;
pathName: string;
associatedPathName: string | null;
effectType: number;
Expand All @@ -36,6 +38,7 @@ interface CEvent {
export const watch = (path: string, cb: (event: Event) => void): { close: () => boolean } => {
let typedCb: null | ((_: CEvent) => void) = (cEvent) => {
let event: Event = {
effectTime: cEvent.effectTime,
pathName: cEvent.pathName,
associatedPathName: cEvent.associatedPathName,
effectType: Object.keys(EffectType)[cEvent.effectType] as EffectType,
Expand Down

0 comments on commit bf4e5f5

Please sign in to comment.