var code = `
for (;;) {
console.log(1)
}`
code = infiniteLoopDetector.wrap(code)
// Can only wrap plain code string, no function or other things, or it will throw
// There is also an `unwrap` method to restore the code to the previous shape
try {
eval(code)
} catch(e) {
if (e.type === 'InfiniteLoopError') {
console.log('infinite loop detected')
}
}
-
Notifications
You must be signed in to change notification settings - Fork 3
xieranmaya/infinite-loop-detector
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
A mini library to detect infinite loop in Javascript
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published