Javascript Node Js basic to Advance
1.09K subscribers
4 photos
1 video
2 files
39 links
Javascript Node Js group

@LogicB_Support
@BCA_MCA_BTECH
Download Telegram
Javascript Node Js basic to Advance pinned «Notes 📝 : Telegram.me/BCA_Sem1_Notes Telegram.me/BCA_Sem2_Notes Telegram.me/BCA_Sem3_Notes Telegram.me/BCA_Sem4_Notes Telegram.me/BCA_Sem5_Notes Telegram.me/BCA_Sem6_Notes Code practice Channels: Telegram.me/C_Codes_pro Telegram.me/CPP_Codes_pro Telegram…»
// Fetch song lyrics
const input = require("input");
const axios = require("axios");

const readline = require('readline');

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout
});

rl.question("Enter song name in 2-3 words: ", async (lyrics) => {
    axios.get('https://song.panditsiddharth.repl.co/lyrics?song=' + lyrics)
      .then(response => {
        console.log(response.data);
      })
      .catch(error => {
        console.error("Error fetching lyrics:", error);
      });
 
rl.close();
});
इस बाॅट में कोड रन करना सीखें
Learn how to run code in this bot.

See bot with Full tutorial: https://t.me/logicBots/147

लाभ (Advantage):
आप किसी को भी रियल टाइम में कोड का आउटपुट दिखा सकते हो, जिससे अगर आपके कोड में कोई गलती है तो वह भी सरलता से एक दूसरे से डिस्कस करके साॅल्व कर सकते हो।

See features written in pic ☝️☝️

You can show the output of the code to anyone in real time, so that if there is any mistake in your code, they can easily solve it by discussing with each other.

Full tutorial: https://t.me/logicBots/147
👍1
// Use jsshort lib for input (simpler)
require("jsshort")

async function sum(){
let a = await input("Enter first number: ")
let b = await input("Enter 2nd number: ")

print("Sum of both numbers is:", end= " ")
print(int(a)+int(b))
}

sum()
// fetch song Lyrics
require("jsshort")

async function fLyrics (lyrics){

require("axios").get('https://song.panditsiddharth.repl.co/lyrics?song=' + lyrics)

.then(response => {
        console.log(response.data);
      })
  }

input("Enter song name in 2-3 words")
.then(song => fLyrics(song))
👍1
Learn in 55 seconds
How to run codes in telegram 👇
https://t.me/logicBots/163
// Pascal's triangle like pattern
require("jsshort");

let pre = "";
function triangle(num) {
  for(let i = 0; i < num; i++) {
    for(let j = 0; j < num - i; j++) {
      if(j < (num - i - 1))
        print(" ", end="");
       else{
         if(i == 0)
         pre = "0"
         else
         pre = i + pre + i;

         print(pre)
       }
    }
  }
}

input("Enter Number: ")
.then(num => {
  triangle(int(num));
});
//@JS_Codes_pro
// Fetch ip details
require('jsshort')

input("Please enter IP address:")
.then(ip => {
const url = `http://ip-api.com/json/${ip}`;

require("axios").get(url)
.then(response => {
const data = response.data;
if(!data.country)
return console.error("Please try with another ip " + ip + " not exists\nExample ip:  192.1.2.1");
console.log(`
Status : ${data.status}
Country : ${data.country}
Countrycode : ${data.countryCode}
Region : ${data.region}
City : ${data.city}
Zip Code : ${data.zip}
latitude : ${data.lat}
longitude : ${data.lon}
timezone : ${data.timezone}
ISP : ${data.isp} `);
})
.catch(error => {
console.error("Please try with another ip it's not exists\nExample: 192.1.2.1");
});
})
// Fetch pincode details
require("jsshort")
let a = require("axios")

async function fetchPin(){
let pin = await input("Enter pincode: ");
let url = "https://api.postalpincode.in/pincode/" + pin;
let pd = await a.get(url);
let posts = pd.data[0].PostOffice

if(!posts)
return console.log("Enter correct pincode: Try again", pd.data[0])
let arr = [];

for(let i=0; i < posts.length; i++){
arr.push({[i]: posts[i].Name})
}
console.log(arr)

const slct = await input("\n\n👇👇👇👇👇👇👇\nEnter Number for upper given PostOffices to see your PostOffice details: ");

console.log(pd.data[0].PostOffice[slct])
}

fetchPin()
Task:
Ek default asynchronous language se samajhaiye ki asynchronous language kis kis tarah se better hai


Explaination:
Default asynchronous language, jaise ki JavaScript, asynchronous programming mein kaafi accha hota hai kyunki yeh concurrently multiple tasks ko handle kar sakta hai bina kisi task ko rokne ke. 
Ismein ek task ke completion ke bina dusre tasks execute ho sakte hain, jisse efficiency badhti hai. Isse blocking nahi hota, jiska matlab hai ki ek task ke wait karne se dusre tasks ko block nahi kiya jaata, aur overall performance improve hoti hai.


Real world example:
Jaise ki JavaScript mein, agar ek website multiple resources ko load kar rahi hai jaise images, CSS files, aur data from a server, toh asynchronous nature allows simultaneous loading of these resources. 

Jab ek resource load ho raha hota hai, dusre resources simultaneously load ho sakte hain, isse website ke performance mein improvement hoti hai compared to synchronous loading jahan ek resource ke wait karte karte dusre resources ka loading process block ho jaata hai.


Code Example:
const axios = require('axios');

// Asynchronous GET request bhejna
axios.get('https://example.com')
.then(function (response) {
// Agar request successful hua
console.log(response.data);
})

// upar ka code execute hone se pahle ye excecute ho jayega kyuki JavaScript isko bhi uske sath simultaneously execute karega
console.log("Request bhej diya hai!");
Ab aap log apna khud ka Compiler bot bana sakte hain easily 🥳🥳🔥
Apne manpasand name aur username se

Create your own
By using @CloneCompiler_bot

See full details: Click Here
// Dimond pattern
require("jsshort")
input("Enter num: ")
.then((n)=>{
let str = '';

// top half
for (let i = 1; i <= n; i++) {
str = ' '.repeat(n - i);
str += '* '.repeat(i);
console.log(str);
}

// bottom half
for (let i = n - 1; i >= 1; i--) {
str = ' '.repeat(n - i);
str += '* '.repeat(i);
console.log(str);
}
})
// MorseCode encryption
class MorseCodeCipher {
  constructor() {
    // This is a JavaScript implementation of MorseCode Cipher
    this.morse_dict = {
      'A': '.-', 'B': '-...',
      'C': '-.-.', 'D': '-..', 'E': '.',
      'F': '..-.', 'G': '--.', 'H': '....',
      'I': '..', 'J': '.---', 'K': '-.-',
      'L': '.-..', 'M': '--', 'N': '-.',
      'O': '---', 'P': '.--.', 'Q': '--.-',
      'R': '.-.', 'S': '...', 'T': '-',
      'U': '..-', 'V': '...-', 'W': '.--',
      'X': '-..-', 'Y': '-.--', 'Z': '--..',
      '1': '.----', '2': '..---', '3': '...--',
      '4': '....-', '5': '.....', '6': '-....',
      '7': '--...', '8': '---..', '9': '----.',
      '0': '-----', ',': '--..--', '.': '.-.-.-',
      '?': '..--..', ' ': '/', '-': '-....-',
      '(': '-.--.', ')': '-.--.-'
    };

    this.reverse_morse = {};
    for (const [key, value] of Object.entries(this.morse_dict)) {
      this.reverse_morse[value] = key;
    }
  }

  encrypt(text) {
    let result = '';
    for (const ch of text.toUpperCase()) {
      result += this.morse_dict[ch] || ch;
      result += ' ';
    }
    return result.trim();
  }

  decrypt(text) {
    let result = '';
    for (const code of text.split(' ')) {
      result += this.reverse_morse[code] || code;
    }
    return result;
  }
}
(async ()=>{
const cipher = new MorseCodeCipher();
require("jsshort")
let work = await input("For decrypt 0 For encrypt enter any key: ")
if(work != '0'){
const plainText = await input("Enter text to encrypt: ")
const encryptedText = cipher.encrypt(plainText);
console.log('Encrypted Text:', encryptedText);
} else {
let enc = await input("Enter text to decrypt: ")
const decryptedText = cipher.decrypt(enc);
console.log('Decrypted Text:', decryptedText);
}
process.exit(0)
})()
// simplest function definition in js 😁

let e = e => +e
// Js Own event lib creation
class EventEmitter {
  funcs = [];
 
  constructor() {}
 
  on(mesType, callback) {
    this.funcs.push({ mesType, callback });
  }
 
  emit(mesType, obj) {
    this.funcs.forEach(funobj => {
      if (funobj.mesType == mesType) {
        funobj.callback(obj);
      }
    });
  }
}

/*
For use:
e = new EventEmitter();

e.on("mes", (mes)=> {
console.log("logic here")
})

e.emit("mes", {data: "mydata"})
*/
👍1
All video downloader js libraries:

Youtube video downloader
https://www.npmjs.com/package/ytdl-core

Insta video downloader
https://www.npmjs.com/package/snapsave-downloader-itj

Facebook video downloader
https://www.npmjs.com/package/fb-downloader-scrapper

Twitter video downloader
(If you have chrome then use update it in puppeteer-core)

https://github.com/JBLorincz/xvidrip
Or
Twitter video downloader
(Without puppeteer Old lib so needs some modification as twitter is now x.com)

https://www.npmjs.com/package/video-url-link?activeTab=code
👍1
// Js code to scrap phone numbers from string
str = "+911234567890 xyz abcd Xs bdtsk yts ki hrtsk 1212343409 djdb 23 yted l 1234567 Ynd yts"

console.log(str.match(/\+?\d{10,12}/g))