This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// main | |
function main(){ | |
try{ | |
if(conditon){ | |
throw new Error('We have error here, bye bye , see you in catch block'); | |
} | |
// this part of code it won't reach | |
}catch(e){ | |
console.log('Error is :', e); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try{ | |
// some code to run | |
}catch(e){ | |
if(e instanceof EvalError ){ | |
//do something | |
}else{ | |
//do something else | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function setWindowSize(size){ | |
let startWindow = 10; | |
let endWindow = 30; | |
if(size > endWindow){ | |
throw new RangeError(` Size ${size} is out of range`); | |
} | |
//do some more coding | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# set -x verbose #echo on | |
# Find files with trailing whitespace | |
for file in `git diff --check --cached | grep '^[^+-]' | grep -o '^.*[0-9]\+:'` ; do | |
file_name=`echo ${file} | grep -o '^[^:]\+'` | |
line_number=`echo ${file} | grep -oP '(?<=:)[0-9]+(?=:)'` | |
sed -i '' "${line_number}s/[[:space:]]*$//" ${file_name} | |
git add ${file_name} | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const net = require("net"); | |
const port = process.env.PORT ?? 3000; | |
const server = net.createServer((socket) => { | |
console.log("Client connected"); | |
socket.on("data", (data) => { | |
console.log(`Server Received msg: ${data}`); | |
socket.write(`Server has received your message: ${data}`); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const net = require("net"); | |
const readline = require("readline"); | |
const rl = readline.createInterface({ | |
input: process.stdin, | |
output: process.stdout, | |
}); | |
const port = process.env.PORT ?? 3000; | |
const host = process.env.HOST ?? "127.0.0.1"; |