Skip to content

Instantly share code, notes, and snippets.

@Kelerchian
Kelerchian / gist-stackoverflow-stop-signal-example.js
Created March 10, 2020 18:24
Example Code for: Is there any programmatic way to break infinite loop in NodeJS?
// Question: https://stackoverflow.com/questions/60623418/is-there-any-programmatic-way-to-break-infinite-loop-in-nodejs
const example = () => {
const infiniteLoopWithSignal = async controller => {
let iteration = 0;
while (true) {
if(controller.isStopped) break;
console.log("Iteration: ", iteration++);
await new Promise(resolve => setTimeout(resolve, 1000));
}
@Kelerchian
Kelerchian / usage.ts
Created October 12, 2020 11:02
Lipsurf: PluginBase.util.fuzzyHighScore index/score difference on normal usage vs mapped usage
// Scroll down for code example and result
//////////////////////
// Code - Normal usage
const [index, score] = await PluginBase.util.fuzzyHighScore(
sub.query,
filteredVideos.map(video => video.title),
0,
true