本文整理汇总了TypeScript中fs.unwatchFile函数的典型用法代码示例。如果您正苦于以下问题:TypeScript unwatchFile函数的具体用法?TypeScript unwatchFile怎么用?TypeScript unwatchFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了unwatchFile函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: setTimeout
const onSourceChanged = (curr: fs.Stats, prev :fs.Stats) => {
// console.log(process.pid, 'server changed')
for (let filename of selfSourceFiles) {
fs.unwatchFile(filename)
}
for (let filename of sourceFiles) {
fs.unwatchFile(filename)
}
if (process.env.IS_SUBPROCESS) {
process.exit(0)
return
}
if (isClosing) {
return
}
isClosing = true
if (httpServer) {
// console.log(process.pid, 'closing server', httpServer.listening)
httpServer.close(() => {
setTimeout(restartAsSubproc, 100)
})
httpServer.unref()
} else {
setTimeout(restartAsSubproc, 100)
}
}
示例2: watchFile
watchFile('testfile', {persistent: false, interval: 1000}, (curr, prev) => {
expect(curr.size).toBe(16);
expect(prev.size).toBe(12);
expect(zoneASpec.onScheduleTask).toHaveBeenCalled();
expect(Zone.current.name).toBe('A');
unwatchFile('testfile');
unlink('testfile', () => {
done();
});
});
示例3: unwatchFile
.then(() => {
unwatchFile(readyFile);
// We have to watch for errors until the tunnel has started
// successfully at which point we only want to watch for
// status messages to emit
readMessage = readStatus;
readRunningMessage('');
readMessage = undefined;
})
示例4: watchFile
watchFile(readyFile, { persistent: false, interval: 1007 }, function(
current,
previous
) {
if (Number(current.mtime) === Number(previous.mtime)) {
// readyFile hasn't been modified, so ignore the event
return;
}
unwatchFile(readyFile);
resolve();
});
示例5: close
watchFile: (fileName, callback) => {
// watchFile polls a file every 250ms, picking up file notifications.
_fs.watchFile(fileName, { persistent: true, interval: 250 }, fileChanged);
return {
close() { _fs.unwatchFile(fileName, fileChanged); }
};
function fileChanged(curr: any, prev: any) {
if (+curr.mtime <= +prev.mtime) {
return;
}
callback(fileName);
};
},
示例6:
close: () => _fs.unwatchFile(fileName, fileChanged)
示例7: unwatch
/** Clears callbacks added with onModify(). */
unwatch() {
fs.unwatchFile(this.path);
}