本文整理匯總了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);
}