├── thursday ├── .gitignore ├── class5-online │ ├── .gitignore │ ├── node_modules │ │ ├── @types │ │ │ └── node │ │ │ │ ├── globals.global.d.ts │ │ │ │ ├── ts4.8 │ │ │ │ ├── globals.global.d.ts │ │ │ │ ├── assert │ │ │ │ │ └── strict.d.ts │ │ │ │ ├── constants.d.ts │ │ │ │ ├── stream │ │ │ │ │ ├── consumers.d.ts │ │ │ │ │ └── promises.d.ts │ │ │ │ ├── string_decoder.d.ts │ │ │ │ ├── timers │ │ │ │ │ └── promises.d.ts │ │ │ │ ├── index.d.ts │ │ │ │ ├── module.d.ts │ │ │ │ ├── punycode.d.ts │ │ │ │ └── dom-events.d.ts │ │ │ │ ├── assert │ │ │ │ └── strict.d.ts │ │ │ │ ├── constants.d.ts │ │ │ │ ├── stream │ │ │ │ ├── consumers.d.ts │ │ │ │ └── promises.d.ts │ │ │ │ ├── LICENSE │ │ │ │ ├── README.md │ │ │ │ ├── string_decoder.d.ts │ │ │ │ ├── timers │ │ │ │ └── promises.d.ts │ │ │ │ ├── module.d.ts │ │ │ │ ├── punycode.d.ts │ │ │ │ ├── dom-events.d.ts │ │ │ │ └── readline │ │ │ │ └── promises.d.ts │ │ └── .package-lock.json │ ├── calculator.ts │ ├── users.json │ ├── calculator.js │ ├── package.json │ ├── package-lock.json │ ├── main.ts │ └── main.js ├── class5 │ ├── operations │ │ ├── add.js │ │ └── add.ts │ ├── student1.json │ ├── package.json │ ├── main.js │ └── main.ts ├── class6 │ ├── main.js │ ├── main2.js │ ├── main.ts │ └── main2.ts ├── class7 │ ├── main.js │ └── main.ts ├── class4 │ ├── main.js │ └── main.ts ├── class9 │ ├── main.ts │ └── main.js └── class10 │ ├── main.js │ └── main.ts └── wednesday ├── .gitignore ├── class5-online ├── .gitignore ├── node_modules │ ├── @types │ │ └── node │ │ │ ├── globals.global.d.ts │ │ │ ├── ts4.8 │ │ │ ├── globals.global.d.ts │ │ │ ├── assert │ │ │ │ └── strict.d.ts │ │ │ ├── constants.d.ts │ │ │ ├── stream │ │ │ │ ├── consumers.d.ts │ │ │ │ └── promises.d.ts │ │ │ ├── string_decoder.d.ts │ │ │ ├── timers │ │ │ │ └── promises.d.ts │ │ │ ├── index.d.ts │ │ │ ├── module.d.ts │ │ │ ├── punycode.d.ts │ │ │ └── dom-events.d.ts │ │ │ ├── assert │ │ │ └── strict.d.ts │ │ │ ├── constants.d.ts │ │ │ ├── stream │ │ │ ├── consumers.d.ts │ │ │ └── promises.d.ts │ │ │ ├── LICENSE │ │ │ ├── README.md │ │ │ ├── string_decoder.d.ts │ │ │ ├── timers │ │ │ └── promises.d.ts │ │ │ ├── module.d.ts │ │ │ ├── punycode.d.ts │ │ │ └── dom-events.d.ts │ └── .package-lock.json ├── calculator.ts ├── users.json ├── calculator.js ├── package.json ├── package-lock.json ├── main.ts └── main.js ├── class5 ├── abc │ ├── abc.ts │ └── abc.js ├── add.js ├── add.ts ├── student1.json ├── package.json ├── main.js ├── calculate.js ├── calculate.ts └── main.ts ├── class10 ├── package.json ├── main.js └── main.ts ├── class6 ├── main.js ├── main2.js ├── main.ts └── main2.ts ├── class7 ├── main.js └── main.ts ├── class4 ├── main.js └── main.ts ├── class9 ├── main.ts └── main.js └── class11 ├── main.js └── main.ts /thursday/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /wednesday/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /thursday/class5-online/.gitignore: -------------------------------------------------------------------------------- 1 | ./node_modules -------------------------------------------------------------------------------- /wednesday/class5-online/.gitignore: -------------------------------------------------------------------------------- 1 | ./node_modules -------------------------------------------------------------------------------- /wednesday/class5/abc/abc.ts: -------------------------------------------------------------------------------- 1 | export let a = 10 -------------------------------------------------------------------------------- /wednesday/class5/abc/abc.js: -------------------------------------------------------------------------------- 1 | export let a = 10; 2 | -------------------------------------------------------------------------------- /thursday/class5-online/node_modules/@types/node/globals.global.d.ts: -------------------------------------------------------------------------------- 1 | declare var global: typeof globalThis; 2 | -------------------------------------------------------------------------------- /wednesday/class5-online/node_modules/@types/node/globals.global.d.ts: -------------------------------------------------------------------------------- 1 | declare var global: typeof globalThis; 2 | -------------------------------------------------------------------------------- /thursday/class5-online/node_modules/@types/node/ts4.8/globals.global.d.ts: -------------------------------------------------------------------------------- 1 | declare var global: typeof globalThis; 2 | -------------------------------------------------------------------------------- /wednesday/class5-online/node_modules/@types/node/ts4.8/globals.global.d.ts: -------------------------------------------------------------------------------- 1 | declare var global: typeof globalThis; 2 | -------------------------------------------------------------------------------- /thursday/class5-online/calculator.ts: -------------------------------------------------------------------------------- 1 | export let num1 = 10; 2 | 3 | export function greet() { 4 | console.log("Hello World"); 5 | } 6 | -------------------------------------------------------------------------------- /wednesday/class5-online/calculator.ts: -------------------------------------------------------------------------------- 1 | export let num1 = 10; 2 | 3 | export function greet() { 4 | console.log("Hello World"); 5 | } 6 | -------------------------------------------------------------------------------- /wednesday/class5/add.js: -------------------------------------------------------------------------------- 1 | function Sum(num1, num2) { 2 | let sum = num1 + num2; 3 | return sum; 4 | } 5 | let a = 20; 6 | export { Sum }; 7 | -------------------------------------------------------------------------------- /thursday/class5-online/users.json: -------------------------------------------------------------------------------- 1 | { 2 | "dateOfBirth": "1999-01-01", 3 | "fatherName": "Ali", 4 | "name": "hamzah", 5 | "address": "lahore" 6 | } 7 | -------------------------------------------------------------------------------- /wednesday/class5-online/users.json: -------------------------------------------------------------------------------- 1 | { 2 | "dateOfBirth": "1999-01-01", 3 | "fatherName": "Ali", 4 | "name": "hamzah", 5 | "address": "lahore" 6 | } 7 | -------------------------------------------------------------------------------- /wednesday/class5/add.ts: -------------------------------------------------------------------------------- 1 | function Sum(num1: number, num2: number) { 2 | let sum = num1 + num2 3 | return sum 4 | } 5 | 6 | let a = 20 7 | 8 | export { Sum } -------------------------------------------------------------------------------- /thursday/class5/operations/add.js: -------------------------------------------------------------------------------- 1 | export function sum(num1, num2) { 2 | return num1 + num2; 3 | } 4 | // function sum2(num1: number, num2: number) { 5 | // return num1 + num2 6 | // } 7 | // export {sum, sum2} 8 | -------------------------------------------------------------------------------- /wednesday/class5/student1.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "stdName": "Hamzah", 4 | "age": 22 5 | }, 6 | 7 | 8 | { 9 | "stdName": "Hamzah", 10 | "age": 22 11 | } 12 | 13 | ] -------------------------------------------------------------------------------- /thursday/class5-online/calculator.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.greet = exports.num1 = void 0; 4 | exports.num1 = 10; 5 | function greet() { 6 | console.log("Hello World"); 7 | } 8 | exports.greet = greet; 9 | -------------------------------------------------------------------------------- /wednesday/class5-online/calculator.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.greet = exports.num1 = void 0; 4 | exports.num1 = 10; 5 | function greet() { 6 | console.log("Hello World"); 7 | } 8 | exports.greet = greet; 9 | -------------------------------------------------------------------------------- /thursday/class5/operations/add.ts: -------------------------------------------------------------------------------- 1 | export function sum(num1: number, num2: number) { 2 | return num1 + num2 3 | } 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | // function sum2(num1: number, num2: number) { 12 | // return num1 + num2 13 | // } 14 | 15 | // export {sum, sum2} -------------------------------------------------------------------------------- /thursday/class5-online/node_modules/@types/node/assert/strict.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'assert/strict' { 2 | import { strict } from 'node:assert'; 3 | export = strict; 4 | } 5 | declare module 'node:assert/strict' { 6 | import { strict } from 'node:assert'; 7 | export = strict; 8 | } 9 | -------------------------------------------------------------------------------- /wednesday/class5-online/node_modules/@types/node/assert/strict.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'assert/strict' { 2 | import { strict } from 'node:assert'; 3 | export = strict; 4 | } 5 | declare module 'node:assert/strict' { 6 | import { strict } from 'node:assert'; 7 | export = strict; 8 | } 9 | -------------------------------------------------------------------------------- /thursday/class5-online/node_modules/@types/node/ts4.8/assert/strict.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'assert/strict' { 2 | import { strict } from 'node:assert'; 3 | export = strict; 4 | } 5 | declare module 'node:assert/strict' { 6 | import { strict } from 'node:assert'; 7 | export = strict; 8 | } 9 | -------------------------------------------------------------------------------- /wednesday/class5-online/node_modules/@types/node/ts4.8/assert/strict.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'assert/strict' { 2 | import { strict } from 'node:assert'; 3 | export = strict; 4 | } 5 | declare module 'node:assert/strict' { 6 | import { strict } from 'node:assert'; 7 | export = strict; 8 | } 9 | -------------------------------------------------------------------------------- /thursday/class5/student1.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "studentName": "Hamzah", 4 | "studentAge": 22 5 | }, 6 | { 7 | "studentName": "Hamzah", 8 | "studentAge": 22 9 | }, 10 | { 11 | "studentName": "Hamzah", 12 | "studentAge": 22 13 | } 14 | ] -------------------------------------------------------------------------------- /wednesday/class10/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "class10", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "main.js", 6 | "type":"module", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "keywords": [], 11 | "author": "", 12 | "license": "ISC" 13 | } 14 | -------------------------------------------------------------------------------- /thursday/class6/main.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // let fan: boolean | number = 1; 3 | let hamzahOrder = { 4 | food: "Biryani" 5 | }; 6 | let shezadOrder = { 7 | food: "Biryani", 8 | drink: "Pepsi" 9 | }; 10 | hamzahOrder.food; 11 | hamzahOrder = shezadOrder; 12 | console.log(hamzahOrder); 13 | // shezadOrder = hamzahOrder 14 | -------------------------------------------------------------------------------- /wednesday/class6/main.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // let fan: boolean | number = 1; 3 | let hamzahOrder = { 4 | food: "Biryani" 5 | }; 6 | let shezadOrder = { 7 | food: "Biryani", 8 | drink: "Pepsi" 9 | }; 10 | hamzahOrder.food; 11 | hamzahOrder = shezadOrder; 12 | console.log(hamzahOrder); 13 | // shezadOrder = hamzahOrder 14 | -------------------------------------------------------------------------------- /thursday/class5-online/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "class5-online", 3 | "version": "1.0.0", 4 | "description": "caculator", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "devDependencies": { 13 | "@types/node": "^20.5.0" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /wednesday/class5-online/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "class5-online", 3 | "version": "1.0.0", 4 | "description": "caculator", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "devDependencies": { 13 | "@types/node": "^20.5.0" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /wednesday/class5/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "class5", 3 | "version": "1.0.0", 4 | "main": "main.js", 5 | "scripts": { 6 | "test": "echo \"Error: no test specified\" && exit 1" 7 | }, 8 | "author": "", 9 | "license": "ISC", 10 | "keywords": [], 11 | "description": "", 12 | "type": "module", 13 | "devDependencies": { 14 | "@types/inquirer": "^9.0.3", 15 | "@types/node": "^20.5.3" 16 | }, 17 | "dependencies": { 18 | "inquirer": "^9.2.10" 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /thursday/class5-online/node_modules/.package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "class5-online", 3 | "version": "1.0.0", 4 | "lockfileVersion": 3, 5 | "requires": true, 6 | "packages": { 7 | "node_modules/@types/node": { 8 | "version": "20.5.0", 9 | "resolved": "https://registry.npmjs.org/@types/node/-/node-20.5.0.tgz", 10 | "integrity": "sha512-Mgq7eCtoTjT89FqNoTzzXg2XvCi5VMhRV6+I2aYanc6kQCBImeNaAYRs/DyoVqk1YEUJK5gN9VO7HRIdz4Wo3Q==", 11 | "dev": true 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /wednesday/class5-online/node_modules/.package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "class5-online", 3 | "version": "1.0.0", 4 | "lockfileVersion": 3, 5 | "requires": true, 6 | "packages": { 7 | "node_modules/@types/node": { 8 | "version": "20.5.0", 9 | "resolved": "https://registry.npmjs.org/@types/node/-/node-20.5.0.tgz", 10 | "integrity": "sha512-Mgq7eCtoTjT89FqNoTzzXg2XvCi5VMhRV6+I2aYanc6kQCBImeNaAYRs/DyoVqk1YEUJK5gN9VO7HRIdz4Wo3Q==", 11 | "dev": true 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /thursday/class5/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@hamzahsyed/calculator2", 3 | "version": "3.0.0", 4 | "main": "index.js", 5 | "type": "module", 6 | "bin": "main.js", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "author": "", 11 | "license": "ISC", 12 | "keywords": [], 13 | "description": "", 14 | "devDependencies": { 15 | "@types/inquirer": "^9.0.3", 16 | "@types/node": "^20.5.4" 17 | }, 18 | "dependencies": { 19 | "inquirer": "^9.2.10" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /thursday/class5-online/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "class5-online", 3 | "version": "1.0.0", 4 | "lockfileVersion": 3, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "class5-online", 9 | "version": "1.0.0", 10 | "license": "ISC", 11 | "devDependencies": { 12 | "@types/node": "^20.5.0" 13 | } 14 | }, 15 | "node_modules/@types/node": { 16 | "version": "20.5.0", 17 | "resolved": "https://registry.npmjs.org/@types/node/-/node-20.5.0.tgz", 18 | "integrity": "sha512-Mgq7eCtoTjT89FqNoTzzXg2XvCi5VMhRV6+I2aYanc6kQCBImeNaAYRs/DyoVqk1YEUJK5gN9VO7HRIdz4Wo3Q==", 19 | "dev": true 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /wednesday/class5-online/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "class5-online", 3 | "version": "1.0.0", 4 | "lockfileVersion": 3, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "class5-online", 9 | "version": "1.0.0", 10 | "license": "ISC", 11 | "devDependencies": { 12 | "@types/node": "^20.5.0" 13 | } 14 | }, 15 | "node_modules/@types/node": { 16 | "version": "20.5.0", 17 | "resolved": "https://registry.npmjs.org/@types/node/-/node-20.5.0.tgz", 18 | "integrity": "sha512-Mgq7eCtoTjT89FqNoTzzXg2XvCi5VMhRV6+I2aYanc6kQCBImeNaAYRs/DyoVqk1YEUJK5gN9VO7HRIdz4Wo3Q==", 19 | "dev": true 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /wednesday/class5/main.js: -------------------------------------------------------------------------------- 1 | // console.log("hello world") 2 | export {}; 3 | // let student1 = { 4 | // name: "hamzah", 5 | // age: 22, 6 | // rollNumber: 11111, 7 | // isTeacher: true, 8 | // study: function () { 9 | // console.log("iS STUDING") 10 | // } 11 | // } 12 | // let object = { 13 | // key1: "value1", 14 | // key2: "value2", 15 | // key3: "value3" 16 | // }; 17 | // console.log(student1.isTeacher) 18 | // let a = 'hamzah'; 19 | // a = undefined 20 | // let username = "ali"; 21 | // username = "hamzah" 22 | // const user = { 23 | // name: "Hamzah" 24 | // } 25 | // user.name = "ali" 26 | // const user = "hamzah" 27 | // user = "ali" 28 | // let firstName = 29 | // 30 | // 31 | -------------------------------------------------------------------------------- /thursday/class5-online/main.ts: -------------------------------------------------------------------------------- 1 | // let username = "hamzah"; 2 | // let age = 20; 3 | // let isMarried = true; 4 | 5 | // let nic = { 6 | // dateOfBirth: "1999-01-01", 7 | // fatherName: "Ali", 8 | // name: "hamzah", 9 | // address: "lahore", 10 | // }; 11 | 12 | // let car1 = { 13 | // name: "BMW", // properties 14 | // color: "red", // properties 15 | // model: 2020, // properties 16 | // start: function () { 17 | // // method 18 | // console.log("Engine started"); 19 | // }, 20 | // }; 21 | 22 | // car1.start(); 23 | 24 | // // Convert into TS Object 25 | 26 | // const a = 5; 27 | // const b: number = 33; 28 | 29 | // const c = "hamzah"; 30 | 31 | import { num1, greet } from "./calculator"; 32 | 33 | greet(); 34 | -------------------------------------------------------------------------------- /thursday/class5-online/node_modules/@types/node/constants.d.ts: -------------------------------------------------------------------------------- 1 | /** @deprecated since v6.3.0 - use constants property exposed by the relevant module instead. */ 2 | declare module 'constants' { 3 | import { constants as osConstants, SignalConstants } from 'node:os'; 4 | import { constants as cryptoConstants } from 'node:crypto'; 5 | import { constants as fsConstants } from 'node:fs'; 6 | 7 | const exp: typeof osConstants.errno & 8 | typeof osConstants.priority & 9 | SignalConstants & 10 | typeof cryptoConstants & 11 | typeof fsConstants; 12 | export = exp; 13 | } 14 | 15 | declare module 'node:constants' { 16 | import constants = require('constants'); 17 | export = constants; 18 | } 19 | -------------------------------------------------------------------------------- /wednesday/class5-online/main.ts: -------------------------------------------------------------------------------- 1 | // let username = "hamzah"; 2 | // let age = 20; 3 | // let isMarried = true; 4 | 5 | // let nic = { 6 | // dateOfBirth: "1999-01-01", 7 | // fatherName: "Ali", 8 | // name: "hamzah", 9 | // address: "lahore", 10 | // }; 11 | 12 | // let car1 = { 13 | // name: "BMW", // properties 14 | // color: "red", // properties 15 | // model: 2020, // properties 16 | // start: function () { 17 | // // method 18 | // console.log("Engine started"); 19 | // }, 20 | // }; 21 | 22 | // car1.start(); 23 | 24 | // // Convert into TS Object 25 | 26 | // const a = 5; 27 | // const b: number = 33; 28 | 29 | // const c = "hamzah"; 30 | 31 | import { num1, greet } from "./calculator"; 32 | 33 | greet(); 34 | -------------------------------------------------------------------------------- /wednesday/class5-online/node_modules/@types/node/constants.d.ts: -------------------------------------------------------------------------------- 1 | /** @deprecated since v6.3.0 - use constants property exposed by the relevant module instead. */ 2 | declare module 'constants' { 3 | import { constants as osConstants, SignalConstants } from 'node:os'; 4 | import { constants as cryptoConstants } from 'node:crypto'; 5 | import { constants as fsConstants } from 'node:fs'; 6 | 7 | const exp: typeof osConstants.errno & 8 | typeof osConstants.priority & 9 | SignalConstants & 10 | typeof cryptoConstants & 11 | typeof fsConstants; 12 | export = exp; 13 | } 14 | 15 | declare module 'node:constants' { 16 | import constants = require('constants'); 17 | export = constants; 18 | } 19 | -------------------------------------------------------------------------------- /thursday/class5-online/node_modules/@types/node/ts4.8/constants.d.ts: -------------------------------------------------------------------------------- 1 | /** @deprecated since v6.3.0 - use constants property exposed by the relevant module instead. */ 2 | declare module 'constants' { 3 | import { constants as osConstants, SignalConstants } from 'node:os'; 4 | import { constants as cryptoConstants } from 'node:crypto'; 5 | import { constants as fsConstants } from 'node:fs'; 6 | 7 | const exp: typeof osConstants.errno & 8 | typeof osConstants.priority & 9 | SignalConstants & 10 | typeof cryptoConstants & 11 | typeof fsConstants; 12 | export = exp; 13 | } 14 | 15 | declare module 'node:constants' { 16 | import constants = require('constants'); 17 | export = constants; 18 | } 19 | -------------------------------------------------------------------------------- /wednesday/class5-online/node_modules/@types/node/ts4.8/constants.d.ts: -------------------------------------------------------------------------------- 1 | /** @deprecated since v6.3.0 - use constants property exposed by the relevant module instead. */ 2 | declare module 'constants' { 3 | import { constants as osConstants, SignalConstants } from 'node:os'; 4 | import { constants as cryptoConstants } from 'node:crypto'; 5 | import { constants as fsConstants } from 'node:fs'; 6 | 7 | const exp: typeof osConstants.errno & 8 | typeof osConstants.priority & 9 | SignalConstants & 10 | typeof cryptoConstants & 11 | typeof fsConstants; 12 | export = exp; 13 | } 14 | 15 | declare module 'node:constants' { 16 | import constants = require('constants'); 17 | export = constants; 18 | } 19 | -------------------------------------------------------------------------------- /wednesday/class5/calculate.js: -------------------------------------------------------------------------------- 1 | import { Sum } from './add.js'; 2 | // import { subtract } from './subtract' 3 | import inquirer from "inquirer"; 4 | const num1 = await inquirer.prompt({ 5 | message: "Enter your first number", 6 | type: "number", 7 | name: "firstNum" 8 | }); 9 | const num2 = await inquirer.prompt([ 10 | { 11 | message: "Enter your second number", 12 | type: "number", 13 | name: "secondNum" 14 | }, 15 | { 16 | message: "Enter your second number", 17 | type: "list", 18 | choices: ["*", "+"], 19 | name: "operation" 20 | }, 21 | ]); 22 | // console.log(num1.firstNum) 23 | // console.log(num2.secondNum) 24 | let result = Sum(num1.firstNum, num2.secondNum); 25 | console.log(result); 26 | -------------------------------------------------------------------------------- /thursday/class5-online/main.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // let username = "hamzah"; 3 | // let age = 20; 4 | // let isMarried = true; 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | // let nic = { 7 | // dateOfBirth: "1999-01-01", 8 | // fatherName: "Ali", 9 | // name: "hamzah", 10 | // address: "lahore", 11 | // }; 12 | // let car1 = { 13 | // name: "BMW", // properties 14 | // color: "red", // properties 15 | // model: 2020, // properties 16 | // start: function () { 17 | // // method 18 | // console.log("Engine started"); 19 | // }, 20 | // }; 21 | // car1.start(); 22 | // // Convert into TS Object 23 | // const a = 5; 24 | // const b: number = 33; 25 | // const c = "hamzah"; 26 | const calculator_1 = require("./calculator"); 27 | (0, calculator_1.greet)(); 28 | -------------------------------------------------------------------------------- /wednesday/class5-online/main.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // let username = "hamzah"; 3 | // let age = 20; 4 | // let isMarried = true; 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | // let nic = { 7 | // dateOfBirth: "1999-01-01", 8 | // fatherName: "Ali", 9 | // name: "hamzah", 10 | // address: "lahore", 11 | // }; 12 | // let car1 = { 13 | // name: "BMW", // properties 14 | // color: "red", // properties 15 | // model: 2020, // properties 16 | // start: function () { 17 | // // method 18 | // console.log("Engine started"); 19 | // }, 20 | // }; 21 | // car1.start(); 22 | // // Convert into TS Object 23 | // const a = 5; 24 | // const b: number = 33; 25 | // const c = "hamzah"; 26 | const calculator_1 = require("./calculator"); 27 | (0, calculator_1.greet)(); 28 | -------------------------------------------------------------------------------- /wednesday/class5/calculate.ts: -------------------------------------------------------------------------------- 1 | import { Sum } from './add.js' 2 | // import { subtract } from './subtract' 3 | 4 | 5 | import inquirer from "inquirer" 6 | 7 | 8 | const num1 = await inquirer.prompt({ 9 | message: "Enter your first number", 10 | type:"number", 11 | name: "firstNum" 12 | }) 13 | 14 | const num2 = await inquirer.prompt([ 15 | { 16 | message: "Enter your second number", 17 | type:"number", 18 | name: "secondNum" 19 | }, 20 | { 21 | message: "Enter your second number", 22 | type:"list", 23 | choices: ["*","+"], 24 | name: "operation" 25 | }, 26 | ]) 27 | 28 | 29 | // console.log(num1.firstNum) 30 | // console.log(num2.secondNum) 31 | 32 | 33 | 34 | let result = Sum(num1.firstNum, num2.secondNum) 35 | console.log(result) -------------------------------------------------------------------------------- /wednesday/class5/main.ts: -------------------------------------------------------------------------------- 1 | // console.log("hello world") 2 | 3 | // let student1 = { 4 | // name: "hamzah", 5 | // age: 22, 6 | // rollNumber: 11111, 7 | // isTeacher: true, 8 | // study: function () { 9 | // console.log("iS STUDING") 10 | // } 11 | // } 12 | 13 | // let object = { 14 | // key1: "value1", 15 | // key2: "value2", 16 | // key3: "value3" 17 | // }; 18 | 19 | // console.log(student1.isTeacher) 20 | 21 | // let a = 'hamzah'; 22 | 23 | // a = undefined 24 | 25 | 26 | // let username = "ali"; 27 | 28 | // username = "hamzah" 29 | 30 | 31 | // const user = { 32 | // name: "Hamzah" 33 | // } 34 | 35 | // user.name = "ali" 36 | 37 | // const user = "hamzah" 38 | 39 | // user = "ali" 40 | 41 | 42 | // let firstName = 43 | 44 | 45 | // 46 | 47 | // 48 | 49 | -------------------------------------------------------------------------------- /thursday/class5-online/node_modules/@types/node/stream/consumers.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'stream/consumers' { 2 | import { Blob as NodeBlob } from 'node:buffer'; 3 | import { Readable } from 'node:stream'; 4 | function buffer(stream: NodeJS.ReadableStream | Readable | AsyncIterator): Promise; 5 | function text(stream: NodeJS.ReadableStream | Readable | AsyncIterator): Promise; 6 | function arrayBuffer(stream: NodeJS.ReadableStream | Readable | AsyncIterator): Promise; 7 | function blob(stream: NodeJS.ReadableStream | Readable | AsyncIterator): Promise; 8 | function json(stream: NodeJS.ReadableStream | Readable | AsyncIterator): Promise; 9 | } 10 | declare module 'node:stream/consumers' { 11 | export * from 'stream/consumers'; 12 | } 13 | -------------------------------------------------------------------------------- /wednesday/class5-online/node_modules/@types/node/stream/consumers.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'stream/consumers' { 2 | import { Blob as NodeBlob } from 'node:buffer'; 3 | import { Readable } from 'node:stream'; 4 | function buffer(stream: NodeJS.ReadableStream | Readable | AsyncIterator): Promise; 5 | function text(stream: NodeJS.ReadableStream | Readable | AsyncIterator): Promise; 6 | function arrayBuffer(stream: NodeJS.ReadableStream | Readable | AsyncIterator): Promise; 7 | function blob(stream: NodeJS.ReadableStream | Readable | AsyncIterator): Promise; 8 | function json(stream: NodeJS.ReadableStream | Readable | AsyncIterator): Promise; 9 | } 10 | declare module 'node:stream/consumers' { 11 | export * from 'stream/consumers'; 12 | } 13 | -------------------------------------------------------------------------------- /thursday/class5-online/node_modules/@types/node/ts4.8/stream/consumers.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'stream/consumers' { 2 | import { Blob as NodeBlob } from 'node:buffer'; 3 | import { Readable } from 'node:stream'; 4 | function buffer(stream: NodeJS.ReadableStream | Readable | AsyncIterator): Promise; 5 | function text(stream: NodeJS.ReadableStream | Readable | AsyncIterator): Promise; 6 | function arrayBuffer(stream: NodeJS.ReadableStream | Readable | AsyncIterator): Promise; 7 | function blob(stream: NodeJS.ReadableStream | Readable | AsyncIterator): Promise; 8 | function json(stream: NodeJS.ReadableStream | Readable | AsyncIterator): Promise; 9 | } 10 | declare module 'node:stream/consumers' { 11 | export * from 'stream/consumers'; 12 | } 13 | -------------------------------------------------------------------------------- /wednesday/class5-online/node_modules/@types/node/ts4.8/stream/consumers.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'stream/consumers' { 2 | import { Blob as NodeBlob } from 'node:buffer'; 3 | import { Readable } from 'node:stream'; 4 | function buffer(stream: NodeJS.ReadableStream | Readable | AsyncIterator): Promise; 5 | function text(stream: NodeJS.ReadableStream | Readable | AsyncIterator): Promise; 6 | function arrayBuffer(stream: NodeJS.ReadableStream | Readable | AsyncIterator): Promise; 7 | function blob(stream: NodeJS.ReadableStream | Readable | AsyncIterator): Promise; 8 | function json(stream: NodeJS.ReadableStream | Readable | AsyncIterator): Promise; 9 | } 10 | declare module 'node:stream/consumers' { 11 | export * from 'stream/consumers'; 12 | } 13 | -------------------------------------------------------------------------------- /wednesday/class7/main.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | let hamzahOrderTray = { 3 | food: "biryani", 4 | }; 5 | let okashaOrderTray = { 6 | food: "biryani", 7 | drink: "pepsi", 8 | }; 9 | // let hamzah: Deal1 = hamzahOrderTray; // No Error 10 | // Stale Object 11 | let hamzah1 = okashaOrderTray; // No Error 12 | let ball = { diameter: 10 }; 13 | let sphere = { diameter: 20 }; 14 | sphere = ball; 15 | ball = sphere; 16 | let tube = { 17 | diameter: 22, 18 | length: 10 19 | }; 20 | ball = tube; 21 | function assignTask(day) { 22 | if (day === 1 /* Days.MONDAY */) { 23 | console.log("Admin word"); 24 | } 25 | else if (day === 2 /* Days.TUESDAY */) { 26 | console.log("Admin word"); 27 | } 28 | else if (day === 21 /* Days.THURSDAY */) { 29 | console.log("Admin word"); 30 | } 31 | else { 32 | console.log("else"); 33 | } 34 | } 35 | assignTask(1 /* Days.MONDAY */); 36 | // console.log(Days[1]); 37 | console.log(22 /* Days.FRIDAY */); 38 | -------------------------------------------------------------------------------- /thursday/class7/main.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // let user1 = { 3 | // name: "hamzah", 4 | // age: 18 5 | // } 6 | let hamzahTray = { 7 | food: "Biryani", 8 | }; 9 | let okashaTray = { 10 | food: "Biryani", 11 | drink: "Pepsi", 12 | }; 13 | // let ball: Ball = { 14 | // diameter: 50, 15 | // } 16 | // let sphere: Sphere = { 17 | // diameter: 10 18 | // } 19 | // ball = sphere; 20 | // sphere = ball; 21 | let ball = { 22 | diameter: 50, 23 | }; 24 | let tube = { 25 | length: 20, 26 | diameter: 50 27 | }; 28 | // ball = tube 29 | // tube = ball 30 | // let user1 = { name: "Zia", id: 1 }; 31 | // user1 = {id: 2, name:"Hamzah"}; 32 | // user1 = {id: 3, firstName: "Hamzah"} 33 | // user1 = {id:4, name:"Hamzah", age:22} 34 | let user1 = { name: "Zia", id: 1 }; 35 | let user2 = { name: "Hamzah", id: 2, age: 22 }; 36 | let user3 = { firstName: "Hamzah", id: 3 }; 37 | 38 | 39 | 40 | let redColor = 0 /* TrafficLights.RED */; 41 | let greenColor = 20 /* TrafficLights.GREEN */; 42 | console.log(redColor); 43 | -------------------------------------------------------------------------------- /thursday/class4/main.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // function greet(firstName: string, age: number) { 3 | // console.log(`Hello ${firstName} your age is ${age}`); 4 | // } 5 | // greet("Hamzah", 22); 6 | // greet("Arham", 24); 7 | // function calc(kg: number) { 8 | // let result = Math.round(kg / 7); 9 | // console.log(`${result} KG`); 10 | // return result; 11 | // } 12 | // let calculatedMeat = calc(100); // 14 13 | // console.log(calculatedMeat); 14 | // // if (calculatedMeat > 15) { 15 | // // console.log("Pack in 2 Shoppers"); 16 | // // } else { 17 | // // console.log("Pack in one Shooper"); 18 | // // } 19 | // function IsEvenOrOdd(Value: number) { 20 | // if (Value % 2 == 0) { 21 | // console.log("Even"); 22 | // } else { 23 | // console.log("odd"); 24 | // } 25 | // } 26 | // IsEvenOrOdd(23); 27 | // let i = 0; 28 | // i++ 29 | // i++ 30 | // i++ 31 | // console.log(i) 32 | // for (let i = 0; i <= 100; i++ ) { 33 | // console.log(i) 34 | // } 35 | // 0 1 2 3 4 36 | let fruits = ['Apple', 'Orange', 'Banana', "Mango", "Pineapple"]; 37 | // 5 38 | for (let i = 0; i < fruits.length; i++) { 39 | let fruit = fruits[i]; 40 | console.log(fruit); 41 | } 42 | -------------------------------------------------------------------------------- /thursday/class5-online/node_modules/@types/node/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE 22 | -------------------------------------------------------------------------------- /wednesday/class5-online/node_modules/@types/node/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE 22 | -------------------------------------------------------------------------------- /thursday/class4/main.ts: -------------------------------------------------------------------------------- 1 | // function greet(firstName: string, age: number) { 2 | // console.log(`Hello ${firstName} your age is ${age}`); 3 | // } 4 | 5 | // greet("Hamzah", 22); 6 | // greet("Arham", 24); 7 | 8 | // function calc(kg: number) { 9 | // let result = Math.round(kg / 7); 10 | 11 | // console.log(`${result} KG`); 12 | // return result; 13 | // } 14 | 15 | // let calculatedMeat = calc(100); // 14 16 | 17 | // console.log(calculatedMeat); 18 | 19 | // // if (calculatedMeat > 15) { 20 | // // console.log("Pack in 2 Shoppers"); 21 | // // } else { 22 | // // console.log("Pack in one Shooper"); 23 | // // } 24 | 25 | // function IsEvenOrOdd(Value: number) { 26 | // if (Value % 2 == 0) { 27 | // console.log("Even"); 28 | // } else { 29 | // console.log("odd"); 30 | // } 31 | // } 32 | // IsEvenOrOdd(23); 33 | 34 | 35 | // let i = 0; 36 | // i++ 37 | // i++ 38 | // i++ 39 | // console.log(i) 40 | 41 | 42 | 43 | // for (let i = 0; i <= 100; i++ ) { 44 | 45 | // console.log(i) 46 | 47 | // } 48 | 49 | // 0 1 2 3 4 50 | let fruits = ['Apple', 'Orange', 'Banana', "Mango", "Pineapple"] 51 | 52 | // 5 53 | 54 | 55 | for (let i = 0; i < fruits.length; i++) { 56 | 57 | let fruit = fruits[i] 58 | 59 | console.log(fruit) 60 | 61 | } 62 | 63 | -------------------------------------------------------------------------------- /thursday/class5/main.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | // students 3 | // let objectName = { 4 | // "key1": "value1", 5 | // // key2: "value2", 6 | // // key3: "value3", 7 | // } 8 | ``; 9 | // let stduent1 = { 10 | // name: "hamzah", 11 | // age: 22, 12 | // isTeacher: true, 13 | // englishSubject: { 14 | // marks: "100%", 15 | // grade: "A+" 16 | // }, 17 | // subjects: ["english", "maths"], 18 | // } 19 | // stduent1.subjects[1] 20 | // console.log(stduent1.subjects) 21 | // // let grade = stduent1.englishSubject.grade 22 | // // console.log(stduent1.englishSubject.grade) 23 | // const students = [ 24 | // { 25 | // studentName: "Hamzah", 26 | // studentAge: 22 27 | // }, 28 | // { 29 | // "studentName": "Hamzah", 30 | // "studentAge": 22 31 | // }, 32 | // { 33 | // "studentName": "Hamzah", 34 | // "studentAge": 22 35 | // } 36 | // ] 37 | // const firstName = "Hamzah"; 38 | import inquirer from "inquirer"; 39 | import { sum } from "./operations/add.js"; 40 | let answers = await inquirer.prompt([ 41 | { 42 | message: "Enter your first number", 43 | type: "number", 44 | name: "number1" 45 | }, 46 | { 47 | message: "Enter your second number", 48 | type: "number", 49 | name: "num2" 50 | }, 51 | { 52 | message: "Select operator", 53 | type: "list", 54 | choices: ["+", "-", "*", "/"], 55 | name: "operator" 56 | } 57 | ]); 58 | if (answers.operator === "+") { 59 | let result = sum(answers.num1, answers.num2); 60 | console.log(result); 61 | } 62 | -------------------------------------------------------------------------------- /wednesday/class4/main.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // function greet(name: string, age: number) { 3 | // let message = `Hello ${name}, you are ${age} years old!`; 4 | // return message; 5 | // } 6 | // let message = greet("Hamzah", 22); // Hello Hamzah, you are 22 years 7 | // function EvenOdd(num: number) { 8 | // if (num % 2 == 0) { 9 | // return "Even Number"; 10 | // } else { 11 | // return "Odd Number"; 12 | // } 13 | // } 14 | // let checknum = 8; 15 | // let result = EvenOdd(checknum); 16 | // console.log(result); 17 | // let i = 0; 18 | // i++ // 1 19 | // i++ // 2 20 | // console.log(i); 21 | // let i = 0; 22 | // for (i; i < 3; i++) { 23 | // console.log("Hello"); 24 | // } 25 | // for(let i = 100; i >= 0; i--){ 26 | // console.log(i) 27 | // } 28 | // var cleanestCities = ["Karachi", "Lahore", "Islamabad", "Peshawar"]; 29 | // for (var i = 0; i <= 4; i++) { 30 | // } 31 | // let i = 0 32 | // 0 1 2 3 4 5 33 | // let fruits = ["Apple", "Orange", "Banana", "Mango", "Grapes", "Pineapple"]; 34 | // for(let i = 0; i < fruits.length; i++) { 35 | // console.log(fruits[i]) 36 | // } 37 | // var firstNames = ["BlueRay ", "Upchuck ", "Lojack ", "Gizmo ", "Do-Rag "]; 38 | // var lastNames = ["Zzz", "Burp", "Dogbone", "Droop"]; 39 | // var fullNames = []; 40 | // for (var i = 0; i < firstNames.length; i++) { 41 | // for (var j = 0; j < lastNames.length; j++) { 42 | // fullNames.push(firstNames[i] + lastNames[j]); 43 | // } 44 | // } 45 | for (let i = 0; i < 3; i++) { 46 | console.log("Loop"); 47 | for (let j = 0; j < 3; j++) { 48 | console.log("Nested Loop"); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /wednesday/class4/main.ts: -------------------------------------------------------------------------------- 1 | // function greet(name: string, age: number) { 2 | // let message = `Hello ${name}, you are ${age} years old!`; 3 | 4 | // return message; 5 | // } 6 | 7 | // let message = greet("Hamzah", 22); // Hello Hamzah, you are 22 years 8 | 9 | // function EvenOdd(num: number) { 10 | // if (num % 2 == 0) { 11 | // return "Even Number"; 12 | // } else { 13 | // return "Odd Number"; 14 | // } 15 | // } 16 | 17 | // let checknum = 8; 18 | // let result = EvenOdd(checknum); 19 | // console.log(result); 20 | 21 | // let i = 0; 22 | // i++ // 1 23 | // i++ // 2 24 | 25 | // console.log(i); 26 | 27 | // let i = 0; 28 | // for (i; i < 3; i++) { 29 | // console.log("Hello"); 30 | // } 31 | 32 | // for(let i = 100; i >= 0; i--){ 33 | // console.log(i) 34 | // } 35 | 36 | // var cleanestCities = ["Karachi", "Lahore", "Islamabad", "Peshawar"]; 37 | 38 | // for (var i = 0; i <= 4; i++) { 39 | 40 | // } 41 | 42 | // let i = 0 43 | 44 | // 0 1 2 3 4 5 45 | // let fruits = ["Apple", "Orange", "Banana", "Mango", "Grapes", "Pineapple"]; 46 | 47 | // for(let i = 0; i < fruits.length; i++) { 48 | // console.log(fruits[i]) 49 | // } 50 | 51 | // var firstNames = ["BlueRay ", "Upchuck ", "Lojack ", "Gizmo ", "Do-Rag "]; 52 | // var lastNames = ["Zzz", "Burp", "Dogbone", "Droop"]; 53 | // var fullNames = []; 54 | 55 | // for (var i = 0; i < firstNames.length; i++) { 56 | // for (var j = 0; j < lastNames.length; j++) { 57 | // fullNames.push(firstNames[i] + lastNames[j]); 58 | // } 59 | // } 60 | 61 | for (let i = 0; i < 3; i++) { 62 | console.log("Loop"); 63 | 64 | for (let j = 0; j < 3; j++) { 65 | console.log("Nested Loop"); 66 | } 67 | 68 | 69 | 70 | } 71 | -------------------------------------------------------------------------------- /thursday/class5/main.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | // students 4 | 5 | // let objectName = { 6 | // "key1": "value1", 7 | // // key2: "value2", 8 | // // key3: "value3", 9 | // } 10 | 11 | 12 | 13 | `` 14 | // let stduent1 = { 15 | // name: "hamzah", 16 | // age: 22, 17 | // isTeacher: true, 18 | // englishSubject: { 19 | // marks: "100%", 20 | // grade: "A+" 21 | // }, 22 | // subjects: ["english", "maths"], 23 | // } 24 | 25 | 26 | // stduent1.subjects[1] 27 | 28 | // console.log(stduent1.subjects) 29 | 30 | // // let grade = stduent1.englishSubject.grade 31 | 32 | // // console.log(stduent1.englishSubject.grade) 33 | 34 | 35 | 36 | // const students = [ 37 | // { 38 | // studentName: "Hamzah", 39 | // studentAge: 22 40 | // }, 41 | // { 42 | // "studentName": "Hamzah", 43 | // "studentAge": 22 44 | // }, 45 | // { 46 | // "studentName": "Hamzah", 47 | // "studentAge": 22 48 | // } 49 | // ] 50 | 51 | 52 | // const firstName = "Hamzah"; 53 | 54 | 55 | import inquirer from "inquirer" 56 | import { sum } from "./operations/add.js" 57 | 58 | let answers = await inquirer.prompt([ 59 | { 60 | message: "Enter your first number", 61 | type: "number", 62 | name: "num1" 63 | }, 64 | { 65 | message: "Enter your second number", 66 | type: "number", 67 | name: "num2" 68 | }, 69 | { 70 | message: "Select operator", 71 | type: "list", 72 | choices: ["+", "-", "*", "/"], 73 | name: "operator" 74 | } 75 | ] 76 | ) 77 | 78 | if (answers.operator === "+") { 79 | let result = sum(answers.num1, answers.num2) 80 | 81 | console.log(result) 82 | } 83 | -------------------------------------------------------------------------------- /wednesday/class10/main.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | //this is not part of the overload list, 3 | //so it has only three overloads 4 | //its customary to order overloads from most specific to least specific 5 | // function add(arg1: string, arg2: string): string; //option 1 6 | // function add(arg1: number, arg2: number): number; //option 1 7 | // function add(arg1: string, arg2: number): boolean; //option 1 8 | // function add(arg1: any, arg2: any): any { 9 | // if (typeof arg1 === "string" && typeof arg2 === "number") { 10 | // return arg1 + arg2; 11 | // } else { 12 | // return arg1 + arg2; 13 | // } 14 | // } 15 | // // let result = add(33, "22"); 16 | // let result = add("33", 22); 17 | // console.log(result); 18 | // class Person { 19 | // name: string = "Hamzah"; 20 | // age: number = 22; 21 | // constructor(name: string, age: number) { 22 | // this.name = name; 23 | // this.age = age; 24 | // } 25 | // } 26 | // let hamzahInfo = new Person("Hamzah", 33); 27 | // let aliInfo = new Person("Ali", 44); 28 | // console.log(hamzahInfo); 29 | // console.log(aliInfo); 30 | // console.log(hamzahInfo); 31 | // class Point { 32 | // x = 0; 33 | // y = 0; 34 | // } 35 | // const pt = new Point(); 36 | // class GoodGreeter { 37 | // readonly name: string; 38 | // constructor(name: string) { 39 | // this.name = name; 40 | // } 41 | // greet() { 42 | // console.log("Hello", this.name) 43 | // } 44 | // } 45 | // let myGreeter = new GoodGreeter("Hamzah") 46 | // myGreeter.name = "Ali"; 47 | // class Point { 48 | // // Overloads 49 | // constructor(x: number, y: string); 50 | // constructor(s: string); 51 | // constructor(s: any, y?: any) { 52 | // // TBD 53 | // } 54 | // } 55 | // new Point("Hamzah"); 56 | class Person { 57 | constructor(name) { 58 | this.name = name; 59 | } 60 | } 61 | class Student extends Person { 62 | constructor(grade, name) { 63 | super(name); 64 | this.grade = grade; 65 | } 66 | } 67 | let std = new Student(5, "Hamzah"); 68 | std.name; 69 | class Teacher { 70 | constructor(name, salary) { 71 | this.name = name; 72 | this.salary = salary; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /wednesday/class9/main.ts: -------------------------------------------------------------------------------- 1 | // console.log("Task 1"); 2 | 3 | 4 | // for (let i = 0; i < 10000000000; i++) { } 5 | 6 | 7 | // console.log("Task 2"); 8 | 9 | 10 | 11 | // function parentFunction( cbFunc: () => void ) { 12 | // cbFunc() 13 | // console.log("Parent function") 14 | // cbFunc() 15 | // } 16 | 17 | // function cb(){ 18 | // console.log("Callback function") 19 | // } 20 | 21 | // // parentFunction( () => {} ) 22 | 23 | // parentFunction( cb ) 24 | 25 | 26 | // console.log("first") 27 | // console.log("second"); 28 | 29 | 30 | // setTimeout( () => { 31 | // console.log("Second") 32 | // }, 0) 33 | 34 | // console.log("mid"); 35 | 36 | // setTimeout( () => { 37 | // console.log("third") 38 | // }, 0) 39 | 40 | // console.log("last"); 41 | 42 | 43 | // for (let i = 0; i < 10000000000; i++) { } 44 | // console.log("third") 45 | 46 | 47 | // let orderPizza = (ringBellcb: () => void, handleErrorcb: () => void) => { 48 | // console.log("Preparing Pizza"); 49 | 50 | // let isBurnt = true; 51 | 52 | // setTimeout(() => { 53 | // if (!isBurnt) { 54 | // ringBellcb() 55 | // } else { 56 | // handleErrorcb() 57 | // } 58 | // }, 5000); 59 | 60 | // console.log("Test Console") 61 | 62 | // } 63 | 64 | 65 | // let ringBell = () => { 66 | // console.log("Your pizza is ready"); 67 | // } 68 | 69 | // let handleError = () => { 70 | // console.log("Something went wrong"); 71 | // } 72 | 73 | 74 | // orderPizza(ringBell, handleError); 75 | 76 | 77 | let makeOrder = () => { 78 | return new Promise((resolve, reject) => { 79 | 80 | setTimeout(() => { 81 | 82 | let isBurnt = true; 83 | 84 | if (isBurnt) { 85 | reject("Something went wrong") 86 | } else { 87 | resolve("Your pizza is ready") 88 | } 89 | 90 | }, 2000) 91 | 92 | }) 93 | } 94 | 95 | 96 | // makeOrder() 97 | // .then((value) => console.log(value)) 98 | // .catch((error) => console.log(error)) 99 | 100 | 101 | let getOrder = async () => { 102 | 103 | 104 | try { 105 | let result = await makeOrder(); 106 | console.log(result) 107 | } 108 | catch (error) { 109 | console.log(error) 110 | } 111 | 112 | 113 | 114 | 115 | } 116 | 117 | 118 | getOrder() -------------------------------------------------------------------------------- /thursday/class5-online/node_modules/@types/node/README.md: -------------------------------------------------------------------------------- 1 | # Installation 2 | > `npm install --save @types/node` 3 | 4 | # Summary 5 | This package contains type definitions for Node.js (https://nodejs.org/). 6 | 7 | # Details 8 | Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node. 9 | 10 | ### Additional Details 11 | * Last updated: Sun, 13 Aug 2023 19:32:51 GMT 12 | * Dependencies: none 13 | * Global values: `AbortController`, `AbortSignal`, `__dirname`, `__filename`, `console`, `exports`, `gc`, `global`, `module`, `process`, `require`, `structuredClone` 14 | 15 | # Credits 16 | These definitions were written by [Microsoft TypeScript](https://github.com/Microsoft), [DefinitelyTyped](https://github.com/DefinitelyTyped), [Alberto Schiabel](https://github.com/jkomyno), [Alvis HT Tang](https://github.com/alvis), [Andrew Makarov](https://github.com/r3nya), [Benjamin Toueg](https://github.com/btoueg), [Chigozirim C.](https://github.com/smac89), [David Junger](https://github.com/touffy), [Deividas Bakanas](https://github.com/DeividasBakanas), [Eugene Y. Q. Shen](https://github.com/eyqs), [Hannes Magnusson](https://github.com/Hannes-Magnusson-CK), [Huw](https://github.com/hoo29), [Kelvin Jin](https://github.com/kjin), [Klaus Meinhardt](https://github.com/ajafff), [Lishude](https://github.com/islishude), [Mariusz Wiktorczyk](https://github.com/mwiktorczyk), [Mohsen Azimi](https://github.com/mohsen1), [Nicolas Even](https://github.com/n-e), [Nikita Galkin](https://github.com/galkin), [Parambir Singh](https://github.com/parambirs), [Sebastian Silbermann](https://github.com/eps1lon), [Thomas den Hollander](https://github.com/ThomasdenH), [Wilco Bakker](https://github.com/WilcoBakker), [wwwy3y3](https://github.com/wwwy3y3), [Samuel Ainsworth](https://github.com/samuela), [Kyle Uehlein](https://github.com/kuehlein), [Thanik Bhongbhibhat](https://github.com/bhongy), [Marcin Kopacz](https://github.com/chyzwar), [Trivikram Kamat](https://github.com/trivikr), [Junxiao Shi](https://github.com/yoursunny), [Ilia Baryshnikov](https://github.com/qwelias), [ExE Boss](https://github.com/ExE-Boss), [Piotr Błażejewicz](https://github.com/peterblazejewicz), [Anna Henningsen](https://github.com/addaleax), [Victor Perin](https://github.com/victorperin), [Yongsheng Zhang](https://github.com/ZYSzys), [NodeJS Contributors](https://github.com/NodeJS), [Linus Unnebäck](https://github.com/LinusU), [wafuwafu13](https://github.com/wafuwafu13), [Matteo Collina](https://github.com/mcollina), and [Dmitry Semigradsky](https://github.com/Semigradsky). 17 | -------------------------------------------------------------------------------- /wednesday/class5-online/node_modules/@types/node/README.md: -------------------------------------------------------------------------------- 1 | # Installation 2 | > `npm install --save @types/node` 3 | 4 | # Summary 5 | This package contains type definitions for Node.js (https://nodejs.org/). 6 | 7 | # Details 8 | Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node. 9 | 10 | ### Additional Details 11 | * Last updated: Sun, 13 Aug 2023 19:32:51 GMT 12 | * Dependencies: none 13 | * Global values: `AbortController`, `AbortSignal`, `__dirname`, `__filename`, `console`, `exports`, `gc`, `global`, `module`, `process`, `require`, `structuredClone` 14 | 15 | # Credits 16 | These definitions were written by [Microsoft TypeScript](https://github.com/Microsoft), [DefinitelyTyped](https://github.com/DefinitelyTyped), [Alberto Schiabel](https://github.com/jkomyno), [Alvis HT Tang](https://github.com/alvis), [Andrew Makarov](https://github.com/r3nya), [Benjamin Toueg](https://github.com/btoueg), [Chigozirim C.](https://github.com/smac89), [David Junger](https://github.com/touffy), [Deividas Bakanas](https://github.com/DeividasBakanas), [Eugene Y. Q. Shen](https://github.com/eyqs), [Hannes Magnusson](https://github.com/Hannes-Magnusson-CK), [Huw](https://github.com/hoo29), [Kelvin Jin](https://github.com/kjin), [Klaus Meinhardt](https://github.com/ajafff), [Lishude](https://github.com/islishude), [Mariusz Wiktorczyk](https://github.com/mwiktorczyk), [Mohsen Azimi](https://github.com/mohsen1), [Nicolas Even](https://github.com/n-e), [Nikita Galkin](https://github.com/galkin), [Parambir Singh](https://github.com/parambirs), [Sebastian Silbermann](https://github.com/eps1lon), [Thomas den Hollander](https://github.com/ThomasdenH), [Wilco Bakker](https://github.com/WilcoBakker), [wwwy3y3](https://github.com/wwwy3y3), [Samuel Ainsworth](https://github.com/samuela), [Kyle Uehlein](https://github.com/kuehlein), [Thanik Bhongbhibhat](https://github.com/bhongy), [Marcin Kopacz](https://github.com/chyzwar), [Trivikram Kamat](https://github.com/trivikr), [Junxiao Shi](https://github.com/yoursunny), [Ilia Baryshnikov](https://github.com/qwelias), [ExE Boss](https://github.com/ExE-Boss), [Piotr Błażejewicz](https://github.com/peterblazejewicz), [Anna Henningsen](https://github.com/addaleax), [Victor Perin](https://github.com/victorperin), [Yongsheng Zhang](https://github.com/ZYSzys), [NodeJS Contributors](https://github.com/NodeJS), [Linus Unnebäck](https://github.com/LinusU), [wafuwafu13](https://github.com/wafuwafu13), [Matteo Collina](https://github.com/mcollina), and [Dmitry Semigradsky](https://github.com/Semigradsky). 17 | -------------------------------------------------------------------------------- /thursday/class5-online/node_modules/@types/node/stream/promises.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'stream/promises' { 2 | import { FinishedOptions, PipelineSource, PipelineTransform, PipelineDestination, PipelinePromise, PipelineOptions } from 'node:stream'; 3 | function finished(stream: NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream, options?: FinishedOptions): Promise; 4 | function pipeline, B extends PipelineDestination>(source: A, destination: B, options?: PipelineOptions): PipelinePromise; 5 | function pipeline, T1 extends PipelineTransform, B extends PipelineDestination>( 6 | source: A, 7 | transform1: T1, 8 | destination: B, 9 | options?: PipelineOptions 10 | ): PipelinePromise; 11 | function pipeline, T1 extends PipelineTransform, T2 extends PipelineTransform, B extends PipelineDestination>( 12 | source: A, 13 | transform1: T1, 14 | transform2: T2, 15 | destination: B, 16 | options?: PipelineOptions 17 | ): PipelinePromise; 18 | function pipeline< 19 | A extends PipelineSource, 20 | T1 extends PipelineTransform, 21 | T2 extends PipelineTransform, 22 | T3 extends PipelineTransform, 23 | B extends PipelineDestination 24 | >(source: A, transform1: T1, transform2: T2, transform3: T3, destination: B, options?: PipelineOptions): PipelinePromise; 25 | function pipeline< 26 | A extends PipelineSource, 27 | T1 extends PipelineTransform, 28 | T2 extends PipelineTransform, 29 | T3 extends PipelineTransform, 30 | T4 extends PipelineTransform, 31 | B extends PipelineDestination 32 | >(source: A, transform1: T1, transform2: T2, transform3: T3, transform4: T4, destination: B, options?: PipelineOptions): PipelinePromise; 33 | function pipeline(streams: ReadonlyArray, options?: PipelineOptions): Promise; 34 | function pipeline( 35 | stream1: NodeJS.ReadableStream, 36 | stream2: NodeJS.ReadWriteStream | NodeJS.WritableStream, 37 | ...streams: Array 38 | ): Promise; 39 | } 40 | declare module 'node:stream/promises' { 41 | export * from 'stream/promises'; 42 | } 43 | -------------------------------------------------------------------------------- /wednesday/class5-online/node_modules/@types/node/stream/promises.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'stream/promises' { 2 | import { FinishedOptions, PipelineSource, PipelineTransform, PipelineDestination, PipelinePromise, PipelineOptions } from 'node:stream'; 3 | function finished(stream: NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream, options?: FinishedOptions): Promise; 4 | function pipeline, B extends PipelineDestination>(source: A, destination: B, options?: PipelineOptions): PipelinePromise; 5 | function pipeline, T1 extends PipelineTransform, B extends PipelineDestination>( 6 | source: A, 7 | transform1: T1, 8 | destination: B, 9 | options?: PipelineOptions 10 | ): PipelinePromise; 11 | function pipeline, T1 extends PipelineTransform, T2 extends PipelineTransform, B extends PipelineDestination>( 12 | source: A, 13 | transform1: T1, 14 | transform2: T2, 15 | destination: B, 16 | options?: PipelineOptions 17 | ): PipelinePromise; 18 | function pipeline< 19 | A extends PipelineSource, 20 | T1 extends PipelineTransform, 21 | T2 extends PipelineTransform, 22 | T3 extends PipelineTransform, 23 | B extends PipelineDestination 24 | >(source: A, transform1: T1, transform2: T2, transform3: T3, destination: B, options?: PipelineOptions): PipelinePromise; 25 | function pipeline< 26 | A extends PipelineSource, 27 | T1 extends PipelineTransform, 28 | T2 extends PipelineTransform, 29 | T3 extends PipelineTransform, 30 | T4 extends PipelineTransform, 31 | B extends PipelineDestination 32 | >(source: A, transform1: T1, transform2: T2, transform3: T3, transform4: T4, destination: B, options?: PipelineOptions): PipelinePromise; 33 | function pipeline(streams: ReadonlyArray, options?: PipelineOptions): Promise; 34 | function pipeline( 35 | stream1: NodeJS.ReadableStream, 36 | stream2: NodeJS.ReadWriteStream | NodeJS.WritableStream, 37 | ...streams: Array 38 | ): Promise; 39 | } 40 | declare module 'node:stream/promises' { 41 | export * from 'stream/promises'; 42 | } 43 | -------------------------------------------------------------------------------- /thursday/class5-online/node_modules/@types/node/ts4.8/stream/promises.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'stream/promises' { 2 | import { FinishedOptions, PipelineSource, PipelineTransform, PipelineDestination, PipelinePromise, PipelineOptions } from 'node:stream'; 3 | function finished(stream: NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream, options?: FinishedOptions): Promise; 4 | function pipeline, B extends PipelineDestination>(source: A, destination: B, options?: PipelineOptions): PipelinePromise; 5 | function pipeline, T1 extends PipelineTransform, B extends PipelineDestination>( 6 | source: A, 7 | transform1: T1, 8 | destination: B, 9 | options?: PipelineOptions 10 | ): PipelinePromise; 11 | function pipeline, T1 extends PipelineTransform, T2 extends PipelineTransform, B extends PipelineDestination>( 12 | source: A, 13 | transform1: T1, 14 | transform2: T2, 15 | destination: B, 16 | options?: PipelineOptions 17 | ): PipelinePromise; 18 | function pipeline< 19 | A extends PipelineSource, 20 | T1 extends PipelineTransform, 21 | T2 extends PipelineTransform, 22 | T3 extends PipelineTransform, 23 | B extends PipelineDestination 24 | >(source: A, transform1: T1, transform2: T2, transform3: T3, destination: B, options?: PipelineOptions): PipelinePromise; 25 | function pipeline< 26 | A extends PipelineSource, 27 | T1 extends PipelineTransform, 28 | T2 extends PipelineTransform, 29 | T3 extends PipelineTransform, 30 | T4 extends PipelineTransform, 31 | B extends PipelineDestination 32 | >(source: A, transform1: T1, transform2: T2, transform3: T3, transform4: T4, destination: B, options?: PipelineOptions): PipelinePromise; 33 | function pipeline(streams: ReadonlyArray, options?: PipelineOptions): Promise; 34 | function pipeline( 35 | stream1: NodeJS.ReadableStream, 36 | stream2: NodeJS.ReadWriteStream | NodeJS.WritableStream, 37 | ...streams: Array 38 | ): Promise; 39 | } 40 | declare module 'node:stream/promises' { 41 | export * from 'stream/promises'; 42 | } 43 | -------------------------------------------------------------------------------- /wednesday/class5-online/node_modules/@types/node/ts4.8/stream/promises.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'stream/promises' { 2 | import { FinishedOptions, PipelineSource, PipelineTransform, PipelineDestination, PipelinePromise, PipelineOptions } from 'node:stream'; 3 | function finished(stream: NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream, options?: FinishedOptions): Promise; 4 | function pipeline, B extends PipelineDestination>(source: A, destination: B, options?: PipelineOptions): PipelinePromise; 5 | function pipeline, T1 extends PipelineTransform, B extends PipelineDestination>( 6 | source: A, 7 | transform1: T1, 8 | destination: B, 9 | options?: PipelineOptions 10 | ): PipelinePromise; 11 | function pipeline, T1 extends PipelineTransform, T2 extends PipelineTransform, B extends PipelineDestination>( 12 | source: A, 13 | transform1: T1, 14 | transform2: T2, 15 | destination: B, 16 | options?: PipelineOptions 17 | ): PipelinePromise; 18 | function pipeline< 19 | A extends PipelineSource, 20 | T1 extends PipelineTransform, 21 | T2 extends PipelineTransform, 22 | T3 extends PipelineTransform, 23 | B extends PipelineDestination 24 | >(source: A, transform1: T1, transform2: T2, transform3: T3, destination: B, options?: PipelineOptions): PipelinePromise; 25 | function pipeline< 26 | A extends PipelineSource, 27 | T1 extends PipelineTransform, 28 | T2 extends PipelineTransform, 29 | T3 extends PipelineTransform, 30 | T4 extends PipelineTransform, 31 | B extends PipelineDestination 32 | >(source: A, transform1: T1, transform2: T2, transform3: T3, transform4: T4, destination: B, options?: PipelineOptions): PipelinePromise; 33 | function pipeline(streams: ReadonlyArray, options?: PipelineOptions): Promise; 34 | function pipeline( 35 | stream1: NodeJS.ReadableStream, 36 | stream2: NodeJS.ReadWriteStream | NodeJS.WritableStream, 37 | ...streams: Array 38 | ): Promise; 39 | } 40 | declare module 'node:stream/promises' { 41 | export * from 'stream/promises'; 42 | } 43 | -------------------------------------------------------------------------------- /wednesday/class10/main.ts: -------------------------------------------------------------------------------- 1 | 2 | //this is not part of the overload list, 3 | //so it has only three overloads 4 | //its customary to order overloads from most specific to least specific 5 | // function add(arg1: string, arg2: string): string; //option 1 6 | // function add(arg1: number, arg2: number): number; //option 1 7 | // function add(arg1: string, arg2: number): boolean; //option 1 8 | // function add(arg1: any, arg2: any): any { 9 | // if (typeof arg1 === "string" && typeof arg2 === "number") { 10 | // return arg1 + arg2; 11 | // } else { 12 | // return arg1 + arg2; 13 | // } 14 | // } 15 | 16 | 17 | // // let result = add(33, "22"); 18 | 19 | // let result = add("33", 22); 20 | // console.log(result); 21 | 22 | 23 | // class Person { 24 | // name: string = "Hamzah"; 25 | // age: number = 22; 26 | 27 | // constructor(name: string, age: number) { 28 | // this.name = name; 29 | // this.age = age; 30 | // } 31 | 32 | // } 33 | 34 | // let hamzahInfo = new Person("Hamzah", 33); 35 | 36 | // let aliInfo = new Person("Ali", 44); 37 | 38 | 39 | // console.log(hamzahInfo); 40 | // console.log(aliInfo); 41 | 42 | // console.log(hamzahInfo); 43 | 44 | 45 | // class Point { 46 | // x = 0; 47 | // y = 0; 48 | // } 49 | 50 | // const pt = new Point(); 51 | 52 | 53 | // class GoodGreeter { 54 | // readonly name: string; 55 | // constructor(name: string) { 56 | // this.name = name; 57 | // } 58 | 59 | // greet() { 60 | // console.log("Hello", this.name) 61 | // } 62 | // } 63 | 64 | // let myGreeter = new GoodGreeter("Hamzah") 65 | // myGreeter.name = "Ali"; 66 | 67 | 68 | 69 | 70 | // class Point { 71 | // // Overloads 72 | // constructor(x: number, y: string); 73 | // constructor(s: string); 74 | // constructor(s: any, y?: any) { 75 | // // TBD 76 | // } 77 | // } 78 | 79 | // new Point("Hamzah"); 80 | 81 | 82 | class Person { 83 | name: string 84 | constructor(name: string) { 85 | this.name = name; 86 | } 87 | } 88 | 89 | class Student extends Person { 90 | grade: number; 91 | 92 | constructor(grade: number, name: string) { 93 | super(name) 94 | this.grade = grade; 95 | } 96 | } 97 | let std = new Student(5, "Hamzah"); 98 | std.name 99 | 100 | class Teacher { 101 | name: string; 102 | salary: number; 103 | 104 | constructor(name: string, salary: number) { 105 | this.name = name; 106 | this.salary = salary; 107 | } 108 | } 109 | 110 | 111 | -------------------------------------------------------------------------------- /wednesday/class9/main.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // console.log("Task 1"); 3 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 4 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 5 | return new (P || (P = Promise))(function (resolve, reject) { 6 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 7 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 8 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 9 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 10 | }); 11 | }; 12 | // for (let i = 0; i < 10000000000; i++) { } 13 | // console.log("Task 2"); 14 | // function parentFunction( cbFunc: () => void ) { 15 | // cbFunc() 16 | // console.log("Parent function") 17 | // cbFunc() 18 | // } 19 | // function cb(){ 20 | // console.log("Callback function") 21 | // } 22 | // // parentFunction( () => {} ) 23 | // parentFunction( cb ) 24 | // console.log("first") 25 | // console.log("second"); 26 | // setTimeout( () => { 27 | // console.log("Second") 28 | // }, 0) 29 | // console.log("mid"); 30 | // setTimeout( () => { 31 | // console.log("third") 32 | // }, 0) 33 | // console.log("last"); 34 | // for (let i = 0; i < 10000000000; i++) { } 35 | // console.log("third") 36 | // let orderPizza = (ringBellcb: () => void, handleErrorcb: () => void) => { 37 | // console.log("Preparing Pizza"); 38 | // let isBurnt = true; 39 | // setTimeout(() => { 40 | // if (!isBurnt) { 41 | // ringBellcb() 42 | // } else { 43 | // handleErrorcb() 44 | // } 45 | // }, 5000); 46 | // console.log("Test Console") 47 | // } 48 | // let ringBell = () => { 49 | // console.log("Your pizza is ready"); 50 | // } 51 | // let handleError = () => { 52 | // console.log("Something went wrong"); 53 | // } 54 | // orderPizza(ringBell, handleError); 55 | let makeOrder = () => { 56 | return new Promise((resolve, reject) => { 57 | setTimeout(() => { 58 | let isBurnt = true; 59 | if (isBurnt) { 60 | reject("Something went wrong"); 61 | } 62 | else { 63 | resolve("Your pizza is ready"); 64 | } 65 | }, 2000); 66 | }); 67 | }; 68 | // makeOrder() 69 | // .then((value) => console.log(value)) 70 | // .catch((error) => console.log(error)) 71 | let getOrder = () => __awaiter(void 0, void 0, void 0, function* () { 72 | try { 73 | let result = yield makeOrder(); 74 | console.log(result); 75 | } 76 | catch (error) { 77 | console.log(error); 78 | } 79 | }); 80 | getOrder(); 81 | -------------------------------------------------------------------------------- /thursday/class9/main.ts: -------------------------------------------------------------------------------- 1 | // let restParam = (name: string, ...restNames: string[]) => { 2 | // console.log(restNames) 3 | // } 4 | 5 | // // restParam("Hamzah", "ali") 6 | 7 | // restParam("Hamzah", "ali", "arham") 8 | 9 | // // restParam("Hamzah", "ali", "arham", "22") 10 | 11 | 12 | 13 | // console.log("Hamzah", "ali", "arham") 14 | // // console.log("Hamzah") 15 | 16 | 17 | // console.log("First Task"); 18 | 19 | // for (let i = 0; i < 2000000000; i++) { } 20 | 21 | // console.log("Second Task"); 22 | 23 | 24 | 25 | // let parentFunction = (cb: () => void) => { 26 | // cb() 27 | // console.log("parent function called") 28 | // cb() 29 | 30 | // } 31 | 32 | // let callbackFunc = () => { 33 | // console.log("Callback function called"); 34 | // } 35 | 36 | 37 | // parentFunction(callbackFunc); 38 | 39 | 40 | // parentFunction(() => {console.log("hello")}) 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | // console.log("First") 49 | // console.log("Second") 50 | 51 | // setTimeout(() => { 52 | // console.log("Forth"); 53 | // }, 3000); 54 | 55 | // setTimeout(() => { 56 | // console.log("Forth"); 57 | // }, 1000); 58 | 59 | // console.log("Test"); 60 | 61 | 62 | // console.log("Third") 63 | 64 | // let orderPizza = ( 65 | // resolve: () => void, 66 | // handleErrorCb: () => void) => { 67 | // console.log("Order placed"); 68 | // let isBurnt = Math.random() < 0.2; 69 | // // let isBurnt = true; 70 | 71 | // setTimeout(() => { 72 | 73 | // if (isBurnt) { 74 | // handleErrorCb() 75 | // } else { 76 | // ringBellCb() 77 | // } 78 | 79 | // }, 5000); 80 | 81 | 82 | // } 83 | 84 | // let errorHandle = () => { 85 | // console.log("something went wrong!") 86 | // } 87 | 88 | // let ringBell = () => { 89 | // console.log("Your pizza is ready") 90 | // } 91 | // orderPizza(ringBell, errorHandle); 92 | 93 | 94 | let orderPizza = () => { 95 | return new Promise((resolve, reject) => { 96 | 97 | let isBurnt = true; 98 | 99 | setTimeout(() => { 100 | if (isBurnt) { 101 | reject("Something went wrong") 102 | } else { 103 | resolve("your pizza is ready"); 104 | } 105 | 106 | }, 5000) 107 | 108 | }) 109 | } 110 | 111 | // orderPizza() 112 | // .then((value) => { 113 | // console.log(value) 114 | // }) 115 | // .catch(() => { 116 | // console.log("SOMTHING WENT WRONG!") 117 | // }) 118 | 119 | let getOrder = async () => { 120 | 121 | try { 122 | const value = await orderPizza(); 123 | console.log(value) 124 | } 125 | catch (err) { 126 | console.log(err) 127 | } 128 | 129 | } 130 | 131 | getOrder(); -------------------------------------------------------------------------------- /thursday/class6/main2.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // let trafficLight: boolean | "red" | "yellow" | "green" = false; 3 | Object.defineProperty(exports, "__esModule", { value: true }); 4 | // trafficLight = 'red'; 5 | // trafficLight = false; 6 | // trafficLight = "green"; 7 | // trafficLight = "red"; 8 | // let firstName = "Hamzah"; 9 | // firstName = "Ali" 10 | // const firstName: string | boolean = "Hamzah"; 11 | // let firstName = "Hamzah" 12 | // let updatedFirstName = firstName.toUpperCase(); 13 | // console.log(updatedFirstName) 14 | // let age = 4; 15 | // let updatedAge = age.toFixed(2); 16 | // console.log(updatedAge); 17 | // let myAge: string | number; 18 | // myAge = 16; // Narrowing 19 | // myAge.toFixed(2) 20 | // myAge = '16'; 21 | // myAge.toUpperCase(); 22 | // console.log(myAge); 23 | // let age = '16'; 24 | // console.log(typeof age) 25 | // function renderValue(val: number | string) { 26 | // if (typeof val === "string") { 27 | // val.toUpperCase() 28 | // } 29 | // else { 30 | // val.toFixed(2) 31 | // } 32 | // val = 18 33 | // val; 34 | // } 35 | // renderValue("Hamzah") 36 | // renderValue(12) 37 | // let age: number | "died" | "unknown"; 38 | // age = 90;//OK 39 | // age 40 | // age = "died";//OK 41 | // age 42 | // age = "unknown";//OK 43 | // let teacher = { 44 | // "first-name": "Zeeshan", 45 | // experience: "10" 46 | // } 47 | // // console.log(teacher.name); 48 | // let keyName: string = "first-name" 49 | // console.log(teacher["first-name"]) 50 | // let student = { 51 | // name: "Hira", 52 | // age: 30 53 | // } 54 | // interface ITeacher { 55 | // name: string 56 | // salary: number 57 | // } 58 | // // Method #1 59 | // let teacher: ITeacher; 60 | // teacher = { 61 | // name: "Hamzah", 62 | // salary: 100000 63 | // } 64 | // // Method #2 65 | // let teacher2: ITeacher = { 66 | // name: "Hamzah", 67 | // salary: 100000 68 | // }; 69 | // console.log(teacher.salary) 70 | // let firstName = "Hamzah"; 71 | // let lastName = 22; 72 | // firstName = lastName; 73 | // console.log(firstName); 74 | // let teacher1 = { 75 | // name: "Hamzah", 76 | // salary: 100000 77 | // } 78 | // let teacher2 = { 79 | // name: "Okasha", 80 | // salary: "100" 81 | // } 82 | // teacher1 = teacher2 83 | // interface Deal1 { 84 | // food: string 85 | // } 86 | // interface Deal2 { 87 | // food: string 88 | // drink: string 89 | // } 90 | // let hamzahOrderPlate: Deal1 = { 91 | // food: "Biryani" 92 | // } 93 | // let okashaOrderPlate: Deal2 = { 94 | // food: "Biryani", 95 | // drink: "Pepsi" 96 | // } 97 | // hamzahOrderPlate = okashaOrderPlate; // No Error 98 | // okashaOrderPlate = hamzahOrderPlate // missing property error 99 | // console.log() 100 | const randomeNUm = Math.random() * 10; 101 | console.log(Math.round(randomeNUm)); 102 | -------------------------------------------------------------------------------- /wednesday/class6/main2.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // let trafficLight: boolean | "red" | "yellow" | "green" = false; 3 | Object.defineProperty(exports, "__esModule", { value: true }); 4 | // trafficLight = 'red'; 5 | // trafficLight = false; 6 | // trafficLight = "green"; 7 | // trafficLight = "red"; 8 | // let firstName = "Hamzah"; 9 | // firstName = "Ali" 10 | // const firstName: string | boolean = "Hamzah"; 11 | // let firstName = "Hamzah" 12 | // let updatedFirstName = firstName.toUpperCase(); 13 | // console.log(updatedFirstName) 14 | // let age = 4; 15 | // let updatedAge = age.toFixed(2); 16 | // console.log(updatedAge); 17 | // let myAge: string | number; 18 | // myAge = 16; // Narrowing 19 | // myAge.toFixed(2) 20 | // myAge = '16'; 21 | // myAge.toUpperCase(); 22 | // console.log(myAge); 23 | // let age = '16'; 24 | // console.log(typeof age) 25 | // function renderValue(val: number | string) { 26 | // if (typeof val === "string") { 27 | // val.toUpperCase() 28 | // } 29 | // else { 30 | // val.toFixed(2) 31 | // } 32 | // val = 18 33 | // val; 34 | // } 35 | // renderValue("Hamzah") 36 | // renderValue(12) 37 | // let age: number | "died" | "unknown"; 38 | // age = 90;//OK 39 | // age 40 | // age = "died";//OK 41 | // age 42 | // age = "unknown";//OK 43 | // let teacher = { 44 | // "first-name": "Zeeshan", 45 | // experience: "10" 46 | // } 47 | // // console.log(teacher.name); 48 | // let keyName: string = "first-name" 49 | // console.log(teacher["first-name"]) 50 | // let student = { 51 | // name: "Hira", 52 | // age: 30 53 | // } 54 | // interface ITeacher { 55 | // name: string 56 | // salary: number 57 | // } 58 | // // Method #1 59 | // let teacher: ITeacher; 60 | // teacher = { 61 | // name: "Hamzah", 62 | // salary: 100000 63 | // } 64 | // // Method #2 65 | // let teacher2: ITeacher = { 66 | // name: "Hamzah", 67 | // salary: 100000 68 | // }; 69 | // console.log(teacher.salary) 70 | // let firstName = "Hamzah"; 71 | // let lastName = 22; 72 | // firstName = lastName; 73 | // console.log(firstName); 74 | // let teacher1 = { 75 | // name: "Hamzah", 76 | // salary: 100000 77 | // } 78 | // let teacher2 = { 79 | // name: "Okasha", 80 | // salary: "100" 81 | // } 82 | // teacher1 = teacher2 83 | // interface Deal1 { 84 | // food: string 85 | // } 86 | // interface Deal2 { 87 | // food: string 88 | // drink: string 89 | // } 90 | // let hamzahOrderPlate: Deal1 = { 91 | // food: "Biryani" 92 | // } 93 | // let okashaOrderPlate: Deal2 = { 94 | // food: "Biryani", 95 | // drink: "Pepsi" 96 | // } 97 | // hamzahOrderPlate = okashaOrderPlate; // No Error 98 | // okashaOrderPlate = hamzahOrderPlate // missing property error 99 | // console.log() 100 | const randomeNUm = Math.random() * 10; 101 | console.log(Math.round(randomeNUm)); 102 | -------------------------------------------------------------------------------- /thursday/class10/main.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // function calc(param1: string, param2: number): number 3 | // function calc(param1: number, param2: string): string 4 | // function calc(param1: number, param2: number): number 5 | // function calc(param1: any , param2: any): any { 6 | // if(typeof param1 === "string" && typeof param2 === "string") { 7 | // // ... 8 | // } 9 | // console.log(param1 + param2) 10 | // } 11 | // calc(22, "22"); 12 | // calc(22, "22"); 13 | // calc("22", 22); 14 | // //its customary to order overloads from most specific to least specific 15 | // function add(arg1: any, arg2: string): string;//option 1 16 | // function add(arg1: number, arg2: number): number;//option 2 17 | // function add(arg1: boolean, arg2: boolean): boolean;//option 3 18 | // function add(arg1: any, arg2: any): any { 19 | // return arg1 + arg2; 20 | // } 21 | // // add("Hello", "World"); 22 | // // add("Hello", 22); 23 | // // add(22, 22); 24 | // add(22, 22); 25 | // function greet(name: string, isHappy: boolean): string { 26 | // return isHappy ? `Hello, ${name}! 😊` : `Hello, ${name}. 😐`; 27 | // } 28 | // greet("Alex", false) 29 | // class Person { 30 | // name: string; 31 | // age: number; 32 | // constructor(name: string, age: number) { 33 | // this.name = name; 34 | // this.age = age; 35 | // } 36 | // this = { 37 | // name: string = "hamzah"; 38 | // age: number = 22; 39 | // } 40 | // } 41 | // let alex = new Person("Alex", 23); 42 | // let hamzah = new Person("hamzah", 22); 43 | // console.log(new Person("Alex", 23)) 44 | // class Point { 45 | // x: number = 2; 46 | // y: number; 47 | // } 48 | // const pt = new Point(); 49 | // pt.x = 0; 50 | // pt.y = 0; 51 | // class GoodGreeter { 52 | // name: string; 53 | // constructor() { 54 | // this.name = "Hamzah"; 55 | // } 56 | // greet() { 57 | // console.log(`Hello ${this.name}`) 58 | // } 59 | // } 60 | // let person = new GoodGreeter(); 61 | // let person1 = new GoodGreeter(); 62 | // person.greet(); 63 | // class Point { 64 | // // Overloads 65 | // constructor(x: number, y: string); 66 | // constructor(s: string); 67 | // constructor(xs: any, y?: any) { 68 | // // TBD 69 | // } 70 | // } 71 | // // new Point(22, "hamzah") 72 | // new Point("22") 73 | // class Person{ 74 | // name:string 75 | // constructor(name:string){ 76 | // this.name = name 77 | // } 78 | // } 79 | // class Student extends Person { 80 | // rollNo: number; 81 | // constructor(name:string, rollNo:number){ 82 | // // this.name = name 83 | // super(name) 84 | // this.rollNo = rollNo 85 | // } 86 | // } 87 | // let std1 = new Student("okasha",1) 88 | // console.log(std1) 89 | // class Teacher { 90 | // salary:number 91 | // constructor(name:string,salary:number){ 92 | // // this.name = name 93 | // this.salary = salary 94 | // } 95 | // } 96 | -------------------------------------------------------------------------------- /thursday/class6/main.ts: -------------------------------------------------------------------------------- 1 | // let fan: boolean | number = 1; 2 | 3 | // fan = "false" 4 | 5 | // if (fan) { 6 | // console.log("Fan is On") 7 | // } 8 | 9 | 10 | // else { 11 | // console.log("Fan Is Off") 12 | // } 13 | 14 | 15 | 16 | // let myname: string | null; 17 | 18 | // myname = null; 19 | // console.log(myname); 20 | 21 | // // myname = "zia"; 22 | // // console.log(myname); 23 | 24 | // // const firstName = "hamzah" 25 | 26 | // // let num1 = 2; 27 | 28 | // // console.log(num1.toFixed(2)) 29 | 30 | 31 | // // let myAge: string | number; 32 | 33 | // // myAge = 16; // narrowing 34 | // // myAge.toFixed(2) 35 | 36 | // // myAge = "16" 37 | 38 | // // myAge.toUpperCase() 39 | 40 | 41 | 42 | // // let fan: boolean | number = 1; 43 | 44 | // // fan = false 45 | 46 | // // if (typeof fan === "number") { 47 | 48 | // // fan.toFixed(2) 49 | // // console.log("Fan is On") 50 | // // } 51 | 52 | // // else { 53 | 54 | // // console.log("Fan Is Off") 55 | // // } 56 | 57 | 58 | // let random = Math.random() * 100 59 | // let roundedVal = Math.round(random) 60 | // // console.log(roundedVal) 61 | 62 | // let myAge: number | string 63 | 64 | // if (roundedVal > 50) { 65 | // myAge = 25 66 | // console.log("This is a number: ", myAge) 67 | // } else { 68 | // myAge = "25" 69 | // console.log("This is a string: ", myAge) 70 | // } 71 | 72 | 73 | // let age = Math.random() > 0.6 ? "60" : 60; 74 | 75 | // if (typeof age === "number") { 76 | 77 | // age 78 | // } 79 | 80 | // else { 81 | // age 82 | // } 83 | 84 | 85 | 86 | 87 | // let trafficLight: "red" | "green" | "yellow" | 5 = "red" 88 | 89 | // trafficLight = 5 90 | 91 | // let firstName = "Hamzah" 92 | // firstName = "Ali" 93 | 94 | // const firstName1 = "Hamzah" 95 | 96 | // if ( firstName1 === "") 97 | 98 | // let teacher = { 99 | // "first-name": "Zeeshan", 100 | // experience: "10" 101 | // } 102 | 103 | // console.log(teacher.experience); 104 | 105 | // console.log(teacher["first-name"]); 106 | 107 | 108 | 109 | // console.log(teacher["experience"]); 110 | 111 | 112 | // interface IStudent { 113 | // name: string, 114 | // age: number 115 | // } 116 | 117 | // let student1: IStudent = { 118 | // name: "Hamzah", 119 | // age: 28 120 | // } 121 | 122 | // let student2: IStudent = { 123 | // name: "Hamzah", 124 | // age: 28 125 | // } 126 | 127 | 128 | // type All = string | number | boolean 129 | 130 | // let age: All = "" 131 | 132 | // let age1: All = "" 133 | 134 | interface Deal1 { 135 | food: string, 136 | } 137 | 138 | interface Deal2 { 139 | food: string, 140 | drink: string, 141 | } 142 | 143 | 144 | let hamzahOrder: Deal1 = { 145 | food: "Biryani" 146 | } 147 | 148 | let shezadOrder: Deal2 = { 149 | food: "Biryani", 150 | drink: "Pepsi" 151 | } 152 | 153 | hamzahOrder.food 154 | 155 | hamzahOrder = shezadOrder; 156 | console.log(hamzahOrder) 157 | 158 | // shezadOrder = hamzahOrder 159 | 160 | 161 | 162 | -------------------------------------------------------------------------------- /wednesday/class6/main.ts: -------------------------------------------------------------------------------- 1 | // let fan: boolean | number = 1; 2 | 3 | // fan = "false" 4 | 5 | // if (fan) { 6 | // console.log("Fan is On") 7 | // } 8 | 9 | 10 | // else { 11 | // console.log("Fan Is Off") 12 | // } 13 | 14 | 15 | 16 | // let myname: string | null; 17 | 18 | // myname = null; 19 | // console.log(myname); 20 | 21 | // // myname = "zia"; 22 | // // console.log(myname); 23 | 24 | // // const firstName = "hamzah" 25 | 26 | // // let num1 = 2; 27 | 28 | // // console.log(num1.toFixed(2)) 29 | 30 | 31 | // // let myAge: string | number; 32 | 33 | // // myAge = 16; // narrowing 34 | // // myAge.toFixed(2) 35 | 36 | // // myAge = "16" 37 | 38 | // // myAge.toUpperCase() 39 | 40 | 41 | 42 | // // let fan: boolean | number = 1; 43 | 44 | // // fan = false 45 | 46 | // // if (typeof fan === "number") { 47 | 48 | // // fan.toFixed(2) 49 | // // console.log("Fan is On") 50 | // // } 51 | 52 | // // else { 53 | 54 | // // console.log("Fan Is Off") 55 | // // } 56 | 57 | 58 | // let random = Math.random() * 100 59 | // let roundedVal = Math.round(random) 60 | // // console.log(roundedVal) 61 | 62 | // let myAge: number | string 63 | 64 | // if (roundedVal > 50) { 65 | // myAge = 25 66 | // console.log("This is a number: ", myAge) 67 | // } else { 68 | // myAge = "25" 69 | // console.log("This is a string: ", myAge) 70 | // } 71 | 72 | 73 | // let age = Math.random() > 0.6 ? "60" : 60; 74 | 75 | // if (typeof age === "number") { 76 | 77 | // age 78 | // } 79 | 80 | // else { 81 | // age 82 | // } 83 | 84 | 85 | 86 | 87 | // let trafficLight: "red" | "green" | "yellow" | 5 = "red" 88 | 89 | // trafficLight = 5 90 | 91 | // let firstName = "Hamzah" 92 | // firstName = "Ali" 93 | 94 | // const firstName1 = "Hamzah" 95 | 96 | // if ( firstName1 === "") 97 | 98 | // let teacher = { 99 | // "first-name": "Zeeshan", 100 | // experience: "10" 101 | // } 102 | 103 | // console.log(teacher.experience); 104 | 105 | // console.log(teacher["first-name"]); 106 | 107 | 108 | 109 | // console.log(teacher["experience"]); 110 | 111 | 112 | // interface IStudent { 113 | // name: string, 114 | // age: number 115 | // } 116 | 117 | // let student1: IStudent = { 118 | // name: "Hamzah", 119 | // age: 28 120 | // } 121 | 122 | // let student2: IStudent = { 123 | // name: "Hamzah", 124 | // age: 28 125 | // } 126 | 127 | 128 | // type All = string | number | boolean 129 | 130 | // let age: All = "" 131 | 132 | // let age1: All = "" 133 | 134 | interface Deal1 { 135 | food: string, 136 | } 137 | 138 | interface Deal2 { 139 | food: string, 140 | drink: string, 141 | } 142 | 143 | 144 | let hamzahOrder: Deal1 = { 145 | food: "Biryani" 146 | } 147 | 148 | let shezadOrder: Deal2 = { 149 | food: "Biryani", 150 | drink: "Pepsi" 151 | } 152 | 153 | hamzahOrder.food 154 | 155 | hamzahOrder = shezadOrder; 156 | console.log(hamzahOrder) 157 | 158 | // shezadOrder = hamzahOrder 159 | 160 | 161 | 162 | -------------------------------------------------------------------------------- /thursday/class5-online/node_modules/@types/node/string_decoder.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The `node:string_decoder` module provides an API for decoding `Buffer` objects 3 | * into strings in a manner that preserves encoded multi-byte UTF-8 and UTF-16 4 | * characters. It can be accessed using: 5 | * 6 | * ```js 7 | * const { StringDecoder } = require('node:string_decoder'); 8 | * ``` 9 | * 10 | * The following example shows the basic use of the `StringDecoder` class. 11 | * 12 | * ```js 13 | * const { StringDecoder } = require('node:string_decoder'); 14 | * const decoder = new StringDecoder('utf8'); 15 | * 16 | * const cent = Buffer.from([0xC2, 0xA2]); 17 | * console.log(decoder.write(cent)); 18 | * 19 | * const euro = Buffer.from([0xE2, 0x82, 0xAC]); 20 | * console.log(decoder.write(euro)); 21 | * ``` 22 | * 23 | * When a `Buffer` instance is written to the `StringDecoder` instance, an 24 | * internal buffer is used to ensure that the decoded string does not contain 25 | * any incomplete multibyte characters. These are held in the buffer until the 26 | * next call to `stringDecoder.write()` or until `stringDecoder.end()` is called. 27 | * 28 | * In the following example, the three UTF-8 encoded bytes of the European Euro 29 | * symbol (`€`) are written over three separate operations: 30 | * 31 | * ```js 32 | * const { StringDecoder } = require('node:string_decoder'); 33 | * const decoder = new StringDecoder('utf8'); 34 | * 35 | * decoder.write(Buffer.from([0xE2])); 36 | * decoder.write(Buffer.from([0x82])); 37 | * console.log(decoder.end(Buffer.from([0xAC]))); 38 | * ``` 39 | * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/string_decoder.js) 40 | */ 41 | declare module 'string_decoder' { 42 | class StringDecoder { 43 | constructor(encoding?: BufferEncoding); 44 | /** 45 | * Returns a decoded string, ensuring that any incomplete multibyte characters at 46 | * the end of the `Buffer`, or `TypedArray`, or `DataView` are omitted from the 47 | * returned string and stored in an internal buffer for the next call to`stringDecoder.write()` or `stringDecoder.end()`. 48 | * @since v0.1.99 49 | * @param buffer A `Buffer`, or `TypedArray`, or `DataView` containing the bytes to decode. 50 | */ 51 | write(buffer: Buffer): string; 52 | /** 53 | * Returns any remaining input stored in the internal buffer as a string. Bytes 54 | * representing incomplete UTF-8 and UTF-16 characters will be replaced with 55 | * substitution characters appropriate for the character encoding. 56 | * 57 | * If the `buffer` argument is provided, one final call to `stringDecoder.write()`is performed before returning the remaining input. 58 | * After `end()` is called, the `stringDecoder` object can be reused for new input. 59 | * @since v0.9.3 60 | * @param buffer A `Buffer`, or `TypedArray`, or `DataView` containing the bytes to decode. 61 | */ 62 | end(buffer?: Buffer): string; 63 | } 64 | } 65 | declare module 'node:string_decoder' { 66 | export * from 'string_decoder'; 67 | } 68 | -------------------------------------------------------------------------------- /wednesday/class5-online/node_modules/@types/node/string_decoder.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The `node:string_decoder` module provides an API for decoding `Buffer` objects 3 | * into strings in a manner that preserves encoded multi-byte UTF-8 and UTF-16 4 | * characters. It can be accessed using: 5 | * 6 | * ```js 7 | * const { StringDecoder } = require('node:string_decoder'); 8 | * ``` 9 | * 10 | * The following example shows the basic use of the `StringDecoder` class. 11 | * 12 | * ```js 13 | * const { StringDecoder } = require('node:string_decoder'); 14 | * const decoder = new StringDecoder('utf8'); 15 | * 16 | * const cent = Buffer.from([0xC2, 0xA2]); 17 | * console.log(decoder.write(cent)); 18 | * 19 | * const euro = Buffer.from([0xE2, 0x82, 0xAC]); 20 | * console.log(decoder.write(euro)); 21 | * ``` 22 | * 23 | * When a `Buffer` instance is written to the `StringDecoder` instance, an 24 | * internal buffer is used to ensure that the decoded string does not contain 25 | * any incomplete multibyte characters. These are held in the buffer until the 26 | * next call to `stringDecoder.write()` or until `stringDecoder.end()` is called. 27 | * 28 | * In the following example, the three UTF-8 encoded bytes of the European Euro 29 | * symbol (`€`) are written over three separate operations: 30 | * 31 | * ```js 32 | * const { StringDecoder } = require('node:string_decoder'); 33 | * const decoder = new StringDecoder('utf8'); 34 | * 35 | * decoder.write(Buffer.from([0xE2])); 36 | * decoder.write(Buffer.from([0x82])); 37 | * console.log(decoder.end(Buffer.from([0xAC]))); 38 | * ``` 39 | * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/string_decoder.js) 40 | */ 41 | declare module 'string_decoder' { 42 | class StringDecoder { 43 | constructor(encoding?: BufferEncoding); 44 | /** 45 | * Returns a decoded string, ensuring that any incomplete multibyte characters at 46 | * the end of the `Buffer`, or `TypedArray`, or `DataView` are omitted from the 47 | * returned string and stored in an internal buffer for the next call to`stringDecoder.write()` or `stringDecoder.end()`. 48 | * @since v0.1.99 49 | * @param buffer A `Buffer`, or `TypedArray`, or `DataView` containing the bytes to decode. 50 | */ 51 | write(buffer: Buffer): string; 52 | /** 53 | * Returns any remaining input stored in the internal buffer as a string. Bytes 54 | * representing incomplete UTF-8 and UTF-16 characters will be replaced with 55 | * substitution characters appropriate for the character encoding. 56 | * 57 | * If the `buffer` argument is provided, one final call to `stringDecoder.write()`is performed before returning the remaining input. 58 | * After `end()` is called, the `stringDecoder` object can be reused for new input. 59 | * @since v0.9.3 60 | * @param buffer A `Buffer`, or `TypedArray`, or `DataView` containing the bytes to decode. 61 | */ 62 | end(buffer?: Buffer): string; 63 | } 64 | } 65 | declare module 'node:string_decoder' { 66 | export * from 'string_decoder'; 67 | } 68 | -------------------------------------------------------------------------------- /thursday/class5-online/node_modules/@types/node/ts4.8/string_decoder.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The `node:string_decoder` module provides an API for decoding `Buffer` objects 3 | * into strings in a manner that preserves encoded multi-byte UTF-8 and UTF-16 4 | * characters. It can be accessed using: 5 | * 6 | * ```js 7 | * const { StringDecoder } = require('node:string_decoder'); 8 | * ``` 9 | * 10 | * The following example shows the basic use of the `StringDecoder` class. 11 | * 12 | * ```js 13 | * const { StringDecoder } = require('node:string_decoder'); 14 | * const decoder = new StringDecoder('utf8'); 15 | * 16 | * const cent = Buffer.from([0xC2, 0xA2]); 17 | * console.log(decoder.write(cent)); 18 | * 19 | * const euro = Buffer.from([0xE2, 0x82, 0xAC]); 20 | * console.log(decoder.write(euro)); 21 | * ``` 22 | * 23 | * When a `Buffer` instance is written to the `StringDecoder` instance, an 24 | * internal buffer is used to ensure that the decoded string does not contain 25 | * any incomplete multibyte characters. These are held in the buffer until the 26 | * next call to `stringDecoder.write()` or until `stringDecoder.end()` is called. 27 | * 28 | * In the following example, the three UTF-8 encoded bytes of the European Euro 29 | * symbol (`€`) are written over three separate operations: 30 | * 31 | * ```js 32 | * const { StringDecoder } = require('node:string_decoder'); 33 | * const decoder = new StringDecoder('utf8'); 34 | * 35 | * decoder.write(Buffer.from([0xE2])); 36 | * decoder.write(Buffer.from([0x82])); 37 | * console.log(decoder.end(Buffer.from([0xAC]))); 38 | * ``` 39 | * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/string_decoder.js) 40 | */ 41 | declare module 'string_decoder' { 42 | class StringDecoder { 43 | constructor(encoding?: BufferEncoding); 44 | /** 45 | * Returns a decoded string, ensuring that any incomplete multibyte characters at 46 | * the end of the `Buffer`, or `TypedArray`, or `DataView` are omitted from the 47 | * returned string and stored in an internal buffer for the next call to`stringDecoder.write()` or `stringDecoder.end()`. 48 | * @since v0.1.99 49 | * @param buffer A `Buffer`, or `TypedArray`, or `DataView` containing the bytes to decode. 50 | */ 51 | write(buffer: Buffer): string; 52 | /** 53 | * Returns any remaining input stored in the internal buffer as a string. Bytes 54 | * representing incomplete UTF-8 and UTF-16 characters will be replaced with 55 | * substitution characters appropriate for the character encoding. 56 | * 57 | * If the `buffer` argument is provided, one final call to `stringDecoder.write()`is performed before returning the remaining input. 58 | * After `end()` is called, the `stringDecoder` object can be reused for new input. 59 | * @since v0.9.3 60 | * @param buffer A `Buffer`, or `TypedArray`, or `DataView` containing the bytes to decode. 61 | */ 62 | end(buffer?: Buffer): string; 63 | } 64 | } 65 | declare module 'node:string_decoder' { 66 | export * from 'string_decoder'; 67 | } 68 | -------------------------------------------------------------------------------- /wednesday/class5-online/node_modules/@types/node/ts4.8/string_decoder.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The `node:string_decoder` module provides an API for decoding `Buffer` objects 3 | * into strings in a manner that preserves encoded multi-byte UTF-8 and UTF-16 4 | * characters. It can be accessed using: 5 | * 6 | * ```js 7 | * const { StringDecoder } = require('node:string_decoder'); 8 | * ``` 9 | * 10 | * The following example shows the basic use of the `StringDecoder` class. 11 | * 12 | * ```js 13 | * const { StringDecoder } = require('node:string_decoder'); 14 | * const decoder = new StringDecoder('utf8'); 15 | * 16 | * const cent = Buffer.from([0xC2, 0xA2]); 17 | * console.log(decoder.write(cent)); 18 | * 19 | * const euro = Buffer.from([0xE2, 0x82, 0xAC]); 20 | * console.log(decoder.write(euro)); 21 | * ``` 22 | * 23 | * When a `Buffer` instance is written to the `StringDecoder` instance, an 24 | * internal buffer is used to ensure that the decoded string does not contain 25 | * any incomplete multibyte characters. These are held in the buffer until the 26 | * next call to `stringDecoder.write()` or until `stringDecoder.end()` is called. 27 | * 28 | * In the following example, the three UTF-8 encoded bytes of the European Euro 29 | * symbol (`€`) are written over three separate operations: 30 | * 31 | * ```js 32 | * const { StringDecoder } = require('node:string_decoder'); 33 | * const decoder = new StringDecoder('utf8'); 34 | * 35 | * decoder.write(Buffer.from([0xE2])); 36 | * decoder.write(Buffer.from([0x82])); 37 | * console.log(decoder.end(Buffer.from([0xAC]))); 38 | * ``` 39 | * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/string_decoder.js) 40 | */ 41 | declare module 'string_decoder' { 42 | class StringDecoder { 43 | constructor(encoding?: BufferEncoding); 44 | /** 45 | * Returns a decoded string, ensuring that any incomplete multibyte characters at 46 | * the end of the `Buffer`, or `TypedArray`, or `DataView` are omitted from the 47 | * returned string and stored in an internal buffer for the next call to`stringDecoder.write()` or `stringDecoder.end()`. 48 | * @since v0.1.99 49 | * @param buffer A `Buffer`, or `TypedArray`, or `DataView` containing the bytes to decode. 50 | */ 51 | write(buffer: Buffer): string; 52 | /** 53 | * Returns any remaining input stored in the internal buffer as a string. Bytes 54 | * representing incomplete UTF-8 and UTF-16 characters will be replaced with 55 | * substitution characters appropriate for the character encoding. 56 | * 57 | * If the `buffer` argument is provided, one final call to `stringDecoder.write()`is performed before returning the remaining input. 58 | * After `end()` is called, the `stringDecoder` object can be reused for new input. 59 | * @since v0.9.3 60 | * @param buffer A `Buffer`, or `TypedArray`, or `DataView` containing the bytes to decode. 61 | */ 62 | end(buffer?: Buffer): string; 63 | } 64 | } 65 | declare module 'node:string_decoder' { 66 | export * from 'string_decoder'; 67 | } 68 | -------------------------------------------------------------------------------- /thursday/class9/main.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // let restParam = (name: string, ...restNames: string[]) => { 3 | // console.log(restNames) 4 | // } 5 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 6 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 7 | return new (P || (P = Promise))(function (resolve, reject) { 8 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 9 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 10 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 11 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 12 | }); 13 | }; 14 | // // restParam("Hamzah", "ali") 15 | // restParam("Hamzah", "ali", "arham") 16 | // // restParam("Hamzah", "ali", "arham", "22") 17 | // console.log("Hamzah", "ali", "arham") 18 | // // console.log("Hamzah") 19 | // console.log("First Task"); 20 | // for (let i = 0; i < 2000000000; i++) { } 21 | // console.log("Second Task"); 22 | // let parentFunction = (cb: () => void) => { 23 | // cb() 24 | // console.log("parent function called") 25 | // cb() 26 | // } 27 | // let callbackFunc = () => { 28 | // console.log("Callback function called"); 29 | // } 30 | // parentFunction(callbackFunc); 31 | // parentFunction(() => {console.log("hello")}) 32 | // console.log("First") 33 | // console.log("Second") 34 | // setTimeout(() => { 35 | // console.log("Forth"); 36 | // }, 3000); 37 | // setTimeout(() => { 38 | // console.log("Forth"); 39 | // }, 1000); 40 | // console.log("Test"); 41 | // console.log("Third") 42 | // let orderPizza = ( 43 | // resolve: () => void, 44 | // handleErrorCb: () => void) => { 45 | // console.log("Order placed"); 46 | // let isBurnt = Math.random() < 0.2; 47 | // // let isBurnt = true; 48 | // setTimeout(() => { 49 | // if (isBurnt) { 50 | // handleErrorCb() 51 | // } else { 52 | // ringBellCb() 53 | // } 54 | // }, 5000); 55 | // } 56 | // let errorHandle = () => { 57 | // console.log("something went wrong!") 58 | // } 59 | // let ringBell = () => { 60 | // console.log("Your pizza is ready") 61 | // } 62 | // orderPizza(ringBell, errorHandle); 63 | let orderPizza = () => { 64 | return new Promise((resolve, reject) => { 65 | let isBurnt = true; 66 | setTimeout(() => { 67 | if (isBurnt) { 68 | reject("Something went wrong"); 69 | } 70 | else { 71 | resolve("your pizza is ready"); 72 | } 73 | }, 5000); 74 | }); 75 | }; 76 | // orderPizza() 77 | // .then((value) => { 78 | // console.log(value) 79 | // }) 80 | // .catch(() => { 81 | // console.log("SOMTHING WENT WRONG!") 82 | // }) 83 | let getOrder = () => __awaiter(void 0, void 0, void 0, function* () { 84 | try { 85 | const value = yield orderPizza(); 86 | console.log(value); 87 | } 88 | catch (err) { 89 | console.log(err); 90 | } 91 | }); 92 | getOrder(); 93 | -------------------------------------------------------------------------------- /thursday/class10/main.ts: -------------------------------------------------------------------------------- 1 | // function calc(param1: string, param2: number): number 2 | // function calc(param1: number, param2: string): string 3 | // function calc(param1: number, param2: number): number 4 | 5 | // function calc(param1: any , param2: any): any { 6 | 7 | // if(typeof param1 === "string" && typeof param2 === "string") { 8 | // // ... 9 | // } 10 | 11 | 12 | // console.log(param1 + param2) 13 | // } 14 | 15 | // calc(22, "22"); 16 | // calc(22, "22"); 17 | 18 | // calc("22", 22); 19 | 20 | 21 | // //its customary to order overloads from most specific to least specific 22 | // function add(arg1: any, arg2: string): string;//option 1 23 | // function add(arg1: number, arg2: number): number;//option 2 24 | // function add(arg1: boolean, arg2: boolean): boolean;//option 3 25 | 26 | // function add(arg1: any, arg2: any): any { 27 | // return arg1 + arg2; 28 | // } 29 | 30 | // // add("Hello", "World"); 31 | // // add("Hello", 22); 32 | // // add(22, 22); 33 | // add(22, 22); 34 | 35 | 36 | 37 | // function greet(name: string, isHappy: boolean): string { 38 | 39 | // return isHappy ? `Hello, ${name}! 😊` : `Hello, ${name}. 😐`; 40 | // } 41 | 42 | 43 | // greet("Alex", false) 44 | 45 | 46 | // class Person { 47 | // name: string; 48 | // age: number; 49 | 50 | // constructor(name: string, age: number) { 51 | // this.name = name; 52 | // this.age = age; 53 | // } 54 | 55 | // this = { 56 | // name: string = "hamzah"; 57 | // age: number = 22; 58 | // } 59 | 60 | // } 61 | 62 | // let alex = new Person("Alex", 23); 63 | // let hamzah = new Person("hamzah", 22); 64 | 65 | 66 | // console.log(new Person("Alex", 23)) 67 | 68 | // class Point { 69 | // x: number = 2; 70 | // y: number; 71 | // } 72 | 73 | // const pt = new Point(); 74 | 75 | // pt.x = 0; 76 | // pt.y = 0; 77 | 78 | // class GoodGreeter { 79 | // name: string; 80 | // constructor() { 81 | // this.name = "Hamzah"; 82 | // } 83 | 84 | // greet() { 85 | // console.log(`Hello ${this.name}`) 86 | // } 87 | // } 88 | 89 | // let person = new GoodGreeter(); 90 | // let person1 = new GoodGreeter(); 91 | 92 | // person.greet(); 93 | 94 | 95 | // class Point { 96 | // // Overloads 97 | // constructor(x: number, y: string); 98 | // constructor(s: string); 99 | // constructor(xs: any, y?: any) { 100 | // // TBD 101 | // } 102 | // } 103 | 104 | // // new Point(22, "hamzah") 105 | // new Point("22") 106 | 107 | // class Person{ 108 | // name:string 109 | // constructor(name:string){ 110 | // this.name = name 111 | // } 112 | // } 113 | 114 | // class Student extends Person { 115 | // rollNo: number; 116 | // constructor(name:string, rollNo:number){ 117 | // // this.name = name 118 | // super(name) 119 | // this.rollNo = rollNo 120 | // } 121 | // } 122 | 123 | // let std1 = new Student("okasha",1) 124 | // console.log(std1) 125 | 126 | // class Teacher { 127 | // salary:number 128 | // constructor(name:string,salary:number){ 129 | // // this.name = name 130 | // this.salary = salary 131 | // } 132 | // } -------------------------------------------------------------------------------- /thursday/class6/main2.ts: -------------------------------------------------------------------------------- 1 | // let trafficLight: boolean | "red" | "yellow" | "green" = false; 2 | 3 | // trafficLight = 'red'; 4 | 5 | // trafficLight = false; 6 | 7 | // trafficLight = "green"; 8 | 9 | // trafficLight = "red"; 10 | 11 | 12 | 13 | // let firstName = "Hamzah"; 14 | // firstName = "Ali" 15 | 16 | // const firstName: string | boolean = "Hamzah"; 17 | 18 | // let firstName = "Hamzah" 19 | 20 | // let updatedFirstName = firstName.toUpperCase(); 21 | // console.log(updatedFirstName) 22 | 23 | // let age = 4; 24 | 25 | // let updatedAge = age.toFixed(2); 26 | // console.log(updatedAge); 27 | 28 | // let myAge: string | number; 29 | 30 | // myAge = 16; // Narrowing 31 | // myAge.toFixed(2) 32 | 33 | // myAge = '16'; 34 | 35 | // myAge.toUpperCase(); 36 | 37 | 38 | // console.log(myAge); 39 | 40 | 41 | // let age = '16'; 42 | 43 | // console.log(typeof age) 44 | 45 | 46 | // function renderValue(val: number | string) { 47 | 48 | // if (typeof val === "string") { 49 | // val.toUpperCase() 50 | // } 51 | 52 | // else { 53 | // val.toFixed(2) 54 | // } 55 | 56 | // val = 18 57 | // val; 58 | 59 | // } 60 | 61 | 62 | // renderValue("Hamzah") 63 | // renderValue(12) 64 | 65 | // let age: number | "died" | "unknown"; 66 | 67 | // age = 90;//OK 68 | 69 | // age 70 | 71 | // age = "died";//OK 72 | 73 | // age 74 | 75 | 76 | // age = "unknown";//OK 77 | 78 | 79 | // let teacher = { 80 | // "first-name": "Zeeshan", 81 | // experience: "10" 82 | // } 83 | 84 | // // console.log(teacher.name); 85 | 86 | // let keyName: string = "first-name" 87 | 88 | // console.log(teacher["first-name"]) 89 | 90 | 91 | 92 | // let student = { 93 | // name: "Hira", 94 | // age: 30 95 | // } 96 | 97 | // interface ITeacher { 98 | // name: string 99 | // salary: number 100 | // } 101 | 102 | // // Method #1 103 | // let teacher: ITeacher; 104 | 105 | // teacher = { 106 | // name: "Hamzah", 107 | // salary: 100000 108 | // } 109 | // // Method #2 110 | // let teacher2: ITeacher = { 111 | // name: "Hamzah", 112 | // salary: 100000 113 | // }; 114 | 115 | 116 | 117 | 118 | 119 | // console.log(teacher.salary) 120 | 121 | 122 | 123 | // let firstName = "Hamzah"; 124 | 125 | // let lastName = 22; 126 | 127 | // firstName = lastName; 128 | 129 | // console.log(firstName); 130 | 131 | 132 | 133 | // let teacher1 = { 134 | // name: "Hamzah", 135 | // salary: 100000 136 | // } 137 | 138 | // let teacher2 = { 139 | // name: "Okasha", 140 | // salary: "100" 141 | // } 142 | 143 | // teacher1 = teacher2 144 | 145 | 146 | // interface Deal1 { 147 | // food: string 148 | // } 149 | 150 | // interface Deal2 { 151 | // food: string 152 | // drink: string 153 | // } 154 | 155 | 156 | // let hamzahOrderPlate: Deal1 = { 157 | // food: "Biryani" 158 | // } 159 | 160 | // let okashaOrderPlate: Deal2 = { 161 | // food: "Biryani", 162 | // drink: "Pepsi" 163 | // } 164 | 165 | 166 | // hamzahOrderPlate = okashaOrderPlate; // No Error 167 | 168 | // okashaOrderPlate = hamzahOrderPlate // missing property error 169 | 170 | 171 | 172 | // console.log() 173 | const randomeNUm = Math.random() * 10 174 | 175 | console.log(Math.round(randomeNUm)) 176 | 177 | 178 | 179 | export { } -------------------------------------------------------------------------------- /wednesday/class6/main2.ts: -------------------------------------------------------------------------------- 1 | // let trafficLight: boolean | "red" | "yellow" | "green" = false; 2 | 3 | // trafficLight = 'red'; 4 | 5 | // trafficLight = false; 6 | 7 | // trafficLight = "green"; 8 | 9 | // trafficLight = "red"; 10 | 11 | 12 | 13 | // let firstName = "Hamzah"; 14 | // firstName = "Ali" 15 | 16 | // const firstName: string | boolean = "Hamzah"; 17 | 18 | // let firstName = "Hamzah" 19 | 20 | // let updatedFirstName = firstName.toUpperCase(); 21 | // console.log(updatedFirstName) 22 | 23 | // let age = 4; 24 | 25 | // let updatedAge = age.toFixed(2); 26 | // console.log(updatedAge); 27 | 28 | // let myAge: string | number; 29 | 30 | // myAge = 16; // Narrowing 31 | // myAge.toFixed(2) 32 | 33 | // myAge = '16'; 34 | 35 | // myAge.toUpperCase(); 36 | 37 | 38 | // console.log(myAge); 39 | 40 | 41 | // let age = '16'; 42 | 43 | // console.log(typeof age) 44 | 45 | 46 | // function renderValue(val: number | string) { 47 | 48 | // if (typeof val === "string") { 49 | // val.toUpperCase() 50 | // } 51 | 52 | // else { 53 | // val.toFixed(2) 54 | // } 55 | 56 | // val = 18 57 | // val; 58 | 59 | // } 60 | 61 | 62 | // renderValue("Hamzah") 63 | // renderValue(12) 64 | 65 | // let age: number | "died" | "unknown"; 66 | 67 | // age = 90;//OK 68 | 69 | // age 70 | 71 | // age = "died";//OK 72 | 73 | // age 74 | 75 | 76 | // age = "unknown";//OK 77 | 78 | 79 | // let teacher = { 80 | // "first-name": "Zeeshan", 81 | // experience: "10" 82 | // } 83 | 84 | // // console.log(teacher.name); 85 | 86 | // let keyName: string = "first-name" 87 | 88 | // console.log(teacher["first-name"]) 89 | 90 | 91 | 92 | // let student = { 93 | // name: "Hira", 94 | // age: 30 95 | // } 96 | 97 | // interface ITeacher { 98 | // name: string 99 | // salary: number 100 | // } 101 | 102 | // // Method #1 103 | // let teacher: ITeacher; 104 | 105 | // teacher = { 106 | // name: "Hamzah", 107 | // salary: 100000 108 | // } 109 | // // Method #2 110 | // let teacher2: ITeacher = { 111 | // name: "Hamzah", 112 | // salary: 100000 113 | // }; 114 | 115 | 116 | 117 | 118 | 119 | // console.log(teacher.salary) 120 | 121 | 122 | 123 | // let firstName = "Hamzah"; 124 | 125 | // let lastName = 22; 126 | 127 | // firstName = lastName; 128 | 129 | // console.log(firstName); 130 | 131 | 132 | 133 | // let teacher1 = { 134 | // name: "Hamzah", 135 | // salary: 100000 136 | // } 137 | 138 | // let teacher2 = { 139 | // name: "Okasha", 140 | // salary: "100" 141 | // } 142 | 143 | // teacher1 = teacher2 144 | 145 | 146 | // interface Deal1 { 147 | // food: string 148 | // } 149 | 150 | // interface Deal2 { 151 | // food: string 152 | // drink: string 153 | // } 154 | 155 | 156 | // let hamzahOrderPlate: Deal1 = { 157 | // food: "Biryani" 158 | // } 159 | 160 | // let okashaOrderPlate: Deal2 = { 161 | // food: "Biryani", 162 | // drink: "Pepsi" 163 | // } 164 | 165 | 166 | // hamzahOrderPlate = okashaOrderPlate; // No Error 167 | 168 | // okashaOrderPlate = hamzahOrderPlate // missing property error 169 | 170 | 171 | 172 | // console.log() 173 | const randomeNUm = Math.random() * 10 174 | 175 | console.log(Math.round(randomeNUm)) 176 | 177 | 178 | 179 | export { } -------------------------------------------------------------------------------- /wednesday/class11/main.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | // class Person { 3 | // name: string 4 | // age: number 5 | // address: string 6 | // constructor(name: string, age: number, address: string) { 7 | // this.name = name 8 | // this.age = age 9 | // this.address = address 10 | // } 11 | // } 12 | Object.defineProperty(exports, "__esModule", { value: true }); 13 | // class Teacher extends Person { 14 | // salary: number 15 | // constructor(salary: number, name: string, age: number, address: string) { 16 | // super(name, age, address) 17 | // this.salary = salary 18 | // } 19 | // } 20 | // let teacher1 = new Teacher(50000, 'john', 20, 'USA') 21 | // console.log(teacher1); 22 | // class Animal { 23 | // eat(){ 24 | // console.log('Animal is eating..'); 25 | // } 26 | // } 27 | // class Tiger extends Animal { 28 | // } 29 | // let tiger = new Tiger(); 30 | // tiger.eat(); 31 | // let x: number = 0; 32 | // class C { 33 | // x: string = "hello"; 34 | // m() { 35 | // x = 12; 36 | // } 37 | // } 38 | // class C { 39 | // private _length = 0; 40 | // get length() { 41 | // return this._length; 42 | // } 43 | // set length(value) { 44 | // if (value < 10) { 45 | // this._length = value; 46 | // } 47 | // } 48 | // } 49 | // let obj1 = new C() 50 | // obj1.length = 10 51 | // console.log(obj1.length) 52 | // interface IPerson { 53 | // name: string 54 | // } 55 | // class Person implements IPerson { 56 | // name!: string; 57 | // age!: number 58 | // } 59 | // let person1: Person = new Person() 60 | // console.log(person1.name); 61 | // class Person { 62 | // name: string 63 | // age: number 64 | // address: string 65 | // constructor(name: string, age: number, address: string) { 66 | // this.name = name 67 | // this.age = age 68 | // this.address = address 69 | // } 70 | // eat(raita:boolean) { 71 | // console.log("Biryani + " , raita); 72 | // } 73 | // } 74 | // class Teacher extends Person { 75 | // constructor(name: string, age: number, address: string) { 76 | // super(name, age, address) 77 | // } 78 | // } 79 | // class Student extends Person { 80 | // constructor(name: string, age: number, address: string) { 81 | // super(name, age, address) 82 | // } 83 | // eat(){ 84 | // console.log("Burger"); 85 | // super.eat(false) 86 | // } 87 | // } 88 | // let teacher1 = new Teacher('john', 20, 'USA') 89 | // teacher1.eat(true) 90 | // let student1 = new Student("ali", 30, "PAK") 91 | // student1.eat() 92 | // class Person{ 93 | // protected name:string = "okasha" 94 | // } 95 | // class Teacher extends Person{ 96 | // updateName(){ 97 | // this.name = "hamza" 98 | // } 99 | // displayName(){ 100 | // return this.name 101 | // } 102 | // } 103 | // let teacher1 = new Teacher() 104 | // teacher1.updateName() 105 | // console.log(teacher1.displayName()) 106 | class Student { 107 | constructor(name, rollNo) { 108 | this.name = name; 109 | this.rollNo = rollNo; 110 | Student.serialNo += 1; 111 | } 112 | } 113 | Student.serialNo = 0; 114 | let student1 = new Student("ali", "12345"); 115 | let student2 = new Student("ali", "12345"); 116 | let student3 = new Student("ali", "12345"); 117 | let student4 = new Student("ali", "12345"); 118 | let student5 = new Student("ali", "12345"); 119 | let student6 = new Student("ali", "12345"); 120 | console.log(Student.serialNo); 121 | -------------------------------------------------------------------------------- /thursday/class5-online/node_modules/@types/node/timers/promises.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The `timers/promises` API provides an alternative set of timer functions 3 | * that return `Promise` objects. The API is accessible via`require('node:timers/promises')`. 4 | * 5 | * ```js 6 | * import { 7 | * setTimeout, 8 | * setImmediate, 9 | * setInterval, 10 | * } from 'timers/promises'; 11 | * ``` 12 | * @since v15.0.0 13 | */ 14 | declare module 'timers/promises' { 15 | import { TimerOptions } from 'node:timers'; 16 | /** 17 | * ```js 18 | * import { 19 | * setTimeout, 20 | * } from 'timers/promises'; 21 | * 22 | * const res = await setTimeout(100, 'result'); 23 | * 24 | * console.log(res); // Prints 'result' 25 | * ``` 26 | * @since v15.0.0 27 | * @param [delay=1] The number of milliseconds to wait before fulfilling the promise. 28 | * @param value A value with which the promise is fulfilled. 29 | */ 30 | function setTimeout(delay?: number, value?: T, options?: TimerOptions): Promise; 31 | /** 32 | * ```js 33 | * import { 34 | * setImmediate, 35 | * } from 'timers/promises'; 36 | * 37 | * const res = await setImmediate('result'); 38 | * 39 | * console.log(res); // Prints 'result' 40 | * ``` 41 | * @since v15.0.0 42 | * @param value A value with which the promise is fulfilled. 43 | */ 44 | function setImmediate(value?: T, options?: TimerOptions): Promise; 45 | /** 46 | * Returns an async iterator that generates values in an interval of `delay` ms. 47 | * If `ref` is `true`, you need to call `next()` of async iterator explicitly 48 | * or implicitly to keep the event loop alive. 49 | * 50 | * ```js 51 | * import { 52 | * setInterval, 53 | * } from 'timers/promises'; 54 | * 55 | * const interval = 100; 56 | * for await (const startTime of setInterval(interval, Date.now())) { 57 | * const now = Date.now(); 58 | * console.log(now); 59 | * if ((now - startTime) > 1000) 60 | * break; 61 | * } 62 | * console.log(Date.now()); 63 | * ``` 64 | * @since v15.9.0 65 | */ 66 | function setInterval(delay?: number, value?: T, options?: TimerOptions): AsyncIterable; 67 | interface Scheduler { 68 | /** 69 | * ```js 70 | * import { scheduler } from 'node:timers/promises'; 71 | * 72 | * await scheduler.wait(1000); // Wait one second before continuing 73 | * ``` 74 | * An experimental API defined by the Scheduling APIs draft specification being developed as a standard Web Platform API. 75 | * Calling timersPromises.scheduler.wait(delay, options) is roughly equivalent to calling timersPromises.setTimeout(delay, undefined, options) except that the ref option is not supported. 76 | * @since v16.14.0 77 | * @experimental 78 | * @param [delay=1] The number of milliseconds to wait before fulfilling the promise. 79 | */ 80 | wait: (delay?: number, options?: TimerOptions) => Promise; 81 | /** 82 | * An experimental API defined by the Scheduling APIs draft specification being developed as a standard Web Platform API. 83 | * Calling timersPromises.scheduler.yield() is equivalent to calling timersPromises.setImmediate() with no arguments. 84 | * @since v16.14.0 85 | * @experimental 86 | */ 87 | yield: () => Promise; 88 | } 89 | const scheduler: Scheduler; 90 | } 91 | declare module 'node:timers/promises' { 92 | export * from 'timers/promises'; 93 | } 94 | -------------------------------------------------------------------------------- /wednesday/class5-online/node_modules/@types/node/timers/promises.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The `timers/promises` API provides an alternative set of timer functions 3 | * that return `Promise` objects. The API is accessible via`require('node:timers/promises')`. 4 | * 5 | * ```js 6 | * import { 7 | * setTimeout, 8 | * setImmediate, 9 | * setInterval, 10 | * } from 'timers/promises'; 11 | * ``` 12 | * @since v15.0.0 13 | */ 14 | declare module 'timers/promises' { 15 | import { TimerOptions } from 'node:timers'; 16 | /** 17 | * ```js 18 | * import { 19 | * setTimeout, 20 | * } from 'timers/promises'; 21 | * 22 | * const res = await setTimeout(100, 'result'); 23 | * 24 | * console.log(res); // Prints 'result' 25 | * ``` 26 | * @since v15.0.0 27 | * @param [delay=1] The number of milliseconds to wait before fulfilling the promise. 28 | * @param value A value with which the promise is fulfilled. 29 | */ 30 | function setTimeout(delay?: number, value?: T, options?: TimerOptions): Promise; 31 | /** 32 | * ```js 33 | * import { 34 | * setImmediate, 35 | * } from 'timers/promises'; 36 | * 37 | * const res = await setImmediate('result'); 38 | * 39 | * console.log(res); // Prints 'result' 40 | * ``` 41 | * @since v15.0.0 42 | * @param value A value with which the promise is fulfilled. 43 | */ 44 | function setImmediate(value?: T, options?: TimerOptions): Promise; 45 | /** 46 | * Returns an async iterator that generates values in an interval of `delay` ms. 47 | * If `ref` is `true`, you need to call `next()` of async iterator explicitly 48 | * or implicitly to keep the event loop alive. 49 | * 50 | * ```js 51 | * import { 52 | * setInterval, 53 | * } from 'timers/promises'; 54 | * 55 | * const interval = 100; 56 | * for await (const startTime of setInterval(interval, Date.now())) { 57 | * const now = Date.now(); 58 | * console.log(now); 59 | * if ((now - startTime) > 1000) 60 | * break; 61 | * } 62 | * console.log(Date.now()); 63 | * ``` 64 | * @since v15.9.0 65 | */ 66 | function setInterval(delay?: number, value?: T, options?: TimerOptions): AsyncIterable; 67 | interface Scheduler { 68 | /** 69 | * ```js 70 | * import { scheduler } from 'node:timers/promises'; 71 | * 72 | * await scheduler.wait(1000); // Wait one second before continuing 73 | * ``` 74 | * An experimental API defined by the Scheduling APIs draft specification being developed as a standard Web Platform API. 75 | * Calling timersPromises.scheduler.wait(delay, options) is roughly equivalent to calling timersPromises.setTimeout(delay, undefined, options) except that the ref option is not supported. 76 | * @since v16.14.0 77 | * @experimental 78 | * @param [delay=1] The number of milliseconds to wait before fulfilling the promise. 79 | */ 80 | wait: (delay?: number, options?: TimerOptions) => Promise; 81 | /** 82 | * An experimental API defined by the Scheduling APIs draft specification being developed as a standard Web Platform API. 83 | * Calling timersPromises.scheduler.yield() is equivalent to calling timersPromises.setImmediate() with no arguments. 84 | * @since v16.14.0 85 | * @experimental 86 | */ 87 | yield: () => Promise; 88 | } 89 | const scheduler: Scheduler; 90 | } 91 | declare module 'node:timers/promises' { 92 | export * from 'timers/promises'; 93 | } 94 | -------------------------------------------------------------------------------- /thursday/class5-online/node_modules/@types/node/ts4.8/timers/promises.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The `timers/promises` API provides an alternative set of timer functions 3 | * that return `Promise` objects. The API is accessible via`require('node:timers/promises')`. 4 | * 5 | * ```js 6 | * import { 7 | * setTimeout, 8 | * setImmediate, 9 | * setInterval, 10 | * } from 'timers/promises'; 11 | * ``` 12 | * @since v15.0.0 13 | */ 14 | declare module 'timers/promises' { 15 | import { TimerOptions } from 'node:timers'; 16 | /** 17 | * ```js 18 | * import { 19 | * setTimeout, 20 | * } from 'timers/promises'; 21 | * 22 | * const res = await setTimeout(100, 'result'); 23 | * 24 | * console.log(res); // Prints 'result' 25 | * ``` 26 | * @since v15.0.0 27 | * @param [delay=1] The number of milliseconds to wait before fulfilling the promise. 28 | * @param value A value with which the promise is fulfilled. 29 | */ 30 | function setTimeout(delay?: number, value?: T, options?: TimerOptions): Promise; 31 | /** 32 | * ```js 33 | * import { 34 | * setImmediate, 35 | * } from 'timers/promises'; 36 | * 37 | * const res = await setImmediate('result'); 38 | * 39 | * console.log(res); // Prints 'result' 40 | * ``` 41 | * @since v15.0.0 42 | * @param value A value with which the promise is fulfilled. 43 | */ 44 | function setImmediate(value?: T, options?: TimerOptions): Promise; 45 | /** 46 | * Returns an async iterator that generates values in an interval of `delay` ms. 47 | * If `ref` is `true`, you need to call `next()` of async iterator explicitly 48 | * or implicitly to keep the event loop alive. 49 | * 50 | * ```js 51 | * import { 52 | * setInterval, 53 | * } from 'timers/promises'; 54 | * 55 | * const interval = 100; 56 | * for await (const startTime of setInterval(interval, Date.now())) { 57 | * const now = Date.now(); 58 | * console.log(now); 59 | * if ((now - startTime) > 1000) 60 | * break; 61 | * } 62 | * console.log(Date.now()); 63 | * ``` 64 | * @since v15.9.0 65 | */ 66 | function setInterval(delay?: number, value?: T, options?: TimerOptions): AsyncIterable; 67 | interface Scheduler { 68 | /** 69 | * ```js 70 | * import { scheduler } from 'node:timers/promises'; 71 | * 72 | * await scheduler.wait(1000); // Wait one second before continuing 73 | * ``` 74 | * An experimental API defined by the Scheduling APIs draft specification being developed as a standard Web Platform API. 75 | * Calling timersPromises.scheduler.wait(delay, options) is roughly equivalent to calling timersPromises.setTimeout(delay, undefined, options) except that the ref option is not supported. 76 | * @since v16.14.0 77 | * @experimental 78 | * @param [delay=1] The number of milliseconds to wait before fulfilling the promise. 79 | */ 80 | wait: (delay?: number, options?: TimerOptions) => Promise; 81 | /** 82 | * An experimental API defined by the Scheduling APIs draft specification being developed as a standard Web Platform API. 83 | * Calling timersPromises.scheduler.yield() is equivalent to calling timersPromises.setImmediate() with no arguments. 84 | * @since v16.14.0 85 | * @experimental 86 | */ 87 | yield: () => Promise; 88 | } 89 | const scheduler: Scheduler; 90 | } 91 | declare module 'node:timers/promises' { 92 | export * from 'timers/promises'; 93 | } 94 | -------------------------------------------------------------------------------- /wednesday/class5-online/node_modules/@types/node/ts4.8/timers/promises.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * The `timers/promises` API provides an alternative set of timer functions 3 | * that return `Promise` objects. The API is accessible via`require('node:timers/promises')`. 4 | * 5 | * ```js 6 | * import { 7 | * setTimeout, 8 | * setImmediate, 9 | * setInterval, 10 | * } from 'timers/promises'; 11 | * ``` 12 | * @since v15.0.0 13 | */ 14 | declare module 'timers/promises' { 15 | import { TimerOptions } from 'node:timers'; 16 | /** 17 | * ```js 18 | * import { 19 | * setTimeout, 20 | * } from 'timers/promises'; 21 | * 22 | * const res = await setTimeout(100, 'result'); 23 | * 24 | * console.log(res); // Prints 'result' 25 | * ``` 26 | * @since v15.0.0 27 | * @param [delay=1] The number of milliseconds to wait before fulfilling the promise. 28 | * @param value A value with which the promise is fulfilled. 29 | */ 30 | function setTimeout(delay?: number, value?: T, options?: TimerOptions): Promise; 31 | /** 32 | * ```js 33 | * import { 34 | * setImmediate, 35 | * } from 'timers/promises'; 36 | * 37 | * const res = await setImmediate('result'); 38 | * 39 | * console.log(res); // Prints 'result' 40 | * ``` 41 | * @since v15.0.0 42 | * @param value A value with which the promise is fulfilled. 43 | */ 44 | function setImmediate(value?: T, options?: TimerOptions): Promise; 45 | /** 46 | * Returns an async iterator that generates values in an interval of `delay` ms. 47 | * If `ref` is `true`, you need to call `next()` of async iterator explicitly 48 | * or implicitly to keep the event loop alive. 49 | * 50 | * ```js 51 | * import { 52 | * setInterval, 53 | * } from 'timers/promises'; 54 | * 55 | * const interval = 100; 56 | * for await (const startTime of setInterval(interval, Date.now())) { 57 | * const now = Date.now(); 58 | * console.log(now); 59 | * if ((now - startTime) > 1000) 60 | * break; 61 | * } 62 | * console.log(Date.now()); 63 | * ``` 64 | * @since v15.9.0 65 | */ 66 | function setInterval(delay?: number, value?: T, options?: TimerOptions): AsyncIterable; 67 | interface Scheduler { 68 | /** 69 | * ```js 70 | * import { scheduler } from 'node:timers/promises'; 71 | * 72 | * await scheduler.wait(1000); // Wait one second before continuing 73 | * ``` 74 | * An experimental API defined by the Scheduling APIs draft specification being developed as a standard Web Platform API. 75 | * Calling timersPromises.scheduler.wait(delay, options) is roughly equivalent to calling timersPromises.setTimeout(delay, undefined, options) except that the ref option is not supported. 76 | * @since v16.14.0 77 | * @experimental 78 | * @param [delay=1] The number of milliseconds to wait before fulfilling the promise. 79 | */ 80 | wait: (delay?: number, options?: TimerOptions) => Promise; 81 | /** 82 | * An experimental API defined by the Scheduling APIs draft specification being developed as a standard Web Platform API. 83 | * Calling timersPromises.scheduler.yield() is equivalent to calling timersPromises.setImmediate() with no arguments. 84 | * @since v16.14.0 85 | * @experimental 86 | */ 87 | yield: () => Promise; 88 | } 89 | const scheduler: Scheduler; 90 | } 91 | declare module 'node:timers/promises' { 92 | export * from 'timers/promises'; 93 | } 94 | -------------------------------------------------------------------------------- /wednesday/class11/main.ts: -------------------------------------------------------------------------------- 1 | // class Person { 2 | // name: string 3 | // age: number 4 | // address: string 5 | // constructor(name: string, age: number, address: string) { 6 | // this.name = name 7 | // this.age = age 8 | // this.address = address 9 | // } 10 | // } 11 | 12 | // class Teacher extends Person { 13 | // salary: number 14 | // constructor(salary: number, name: string, age: number, address: string) { 15 | // super(name, age, address) 16 | // this.salary = salary 17 | // } 18 | // } 19 | 20 | // let teacher1 = new Teacher(50000, 'john', 20, 'USA') 21 | // console.log(teacher1); 22 | 23 | // class Animal { 24 | // eat(){ 25 | // console.log('Animal is eating..'); 26 | // } 27 | // } 28 | 29 | // class Tiger extends Animal { 30 | 31 | // } 32 | 33 | // let tiger = new Tiger(); 34 | // tiger.eat(); 35 | 36 | 37 | 38 | // let x: number = 0; 39 | 40 | // class C { 41 | // x: string = "hello"; 42 | 43 | // m() { 44 | // x = 12; 45 | // } 46 | // } 47 | 48 | 49 | 50 | 51 | // class C { 52 | // private _length = 0; 53 | // get length() { 54 | // return this._length; 55 | // } 56 | // set length(value) { 57 | // if (value < 10) { 58 | // this._length = value; 59 | // } 60 | // } 61 | 62 | 63 | // } 64 | 65 | // let obj1 = new C() 66 | // obj1.length = 10 67 | // console.log(obj1.length) 68 | 69 | 70 | // interface IPerson { 71 | // name: string 72 | // } 73 | 74 | // class Person implements IPerson { 75 | // name!: string; 76 | // age!: number 77 | // } 78 | // let person1: Person = new Person() 79 | // console.log(person1.name); 80 | 81 | 82 | 83 | 84 | // class Person { 85 | // name: string 86 | // age: number 87 | // address: string 88 | // constructor(name: string, age: number, address: string) { 89 | // this.name = name 90 | // this.age = age 91 | // this.address = address 92 | // } 93 | // eat(raita:boolean) { 94 | // console.log("Biryani + " , raita); 95 | // } 96 | // } 97 | 98 | // class Teacher extends Person { 99 | // constructor(name: string, age: number, address: string) { 100 | // super(name, age, address) 101 | // } 102 | // } 103 | // class Student extends Person { 104 | // constructor(name: string, age: number, address: string) { 105 | // super(name, age, address) 106 | // } 107 | // eat(){ 108 | // console.log("Burger"); 109 | // super.eat(false) 110 | // } 111 | // } 112 | 113 | // let teacher1 = new Teacher('john', 20, 'USA') 114 | // teacher1.eat(true) 115 | 116 | // let student1 = new Student("ali", 30, "PAK") 117 | // student1.eat() 118 | 119 | 120 | 121 | 122 | // class Person{ 123 | // protected name:string = "okasha" 124 | // } 125 | // class Teacher extends Person{ 126 | // updateName(){ 127 | // this.name = "hamza" 128 | // } 129 | // displayName(){ 130 | // return this.name 131 | // } 132 | // } 133 | // let teacher1 = new Teacher() 134 | // teacher1.updateName() 135 | // console.log(teacher1.displayName()) 136 | 137 | 138 | 139 | 140 | 141 | class Student { 142 | name: string 143 | rollNo: string 144 | static serialNo: number = 0 145 | constructor(name: string, rollNo: string) { 146 | this.name = name 147 | this.rollNo = rollNo 148 | Student.serialNo += 1 149 | } 150 | } 151 | 152 | let student1 = new Student("ali", "12345") 153 | let student2 = new Student("ali", "12345") 154 | let student3 = new Student("ali", "12345") 155 | let student4 = new Student("ali", "12345") 156 | let student5 = new Student("ali", "12345") 157 | let student6 = new Student("ali", "12345") 158 | 159 | console.log(Student.serialNo); 160 | 161 | 162 | 163 | 164 | -------------------------------------------------------------------------------- /thursday/class5-online/node_modules/@types/node/ts4.8/index.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * License for programmatically and manually incorporated 3 | * documentation aka. `JSDoc` from https://github.com/nodejs/node/tree/master/doc 4 | * 5 | * Copyright Node.js contributors. All rights reserved. 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | */ 24 | 25 | // NOTE: These definitions support NodeJS and TypeScript 4.8 and earlier. 26 | 27 | // Reference required types from the default lib: 28 | /// 29 | /// 30 | /// 31 | /// 32 | 33 | // Base definitions for all NodeJS modules that are not specific to any version of TypeScript: 34 | /// 35 | /// 36 | /// 37 | /// 38 | /// 39 | /// 40 | /// 41 | /// 42 | /// 43 | /// 44 | /// 45 | /// 46 | /// 47 | /// 48 | /// 49 | /// 50 | /// 51 | /// 52 | /// 53 | /// 54 | /// 55 | /// 56 | /// 57 | /// 58 | /// 59 | /// 60 | /// 61 | /// 62 | /// 63 | /// 64 | /// 65 | /// 66 | /// 67 | /// 68 | /// 69 | /// 70 | /// 71 | /// 72 | /// 73 | /// 74 | /// 75 | /// 76 | /// 77 | /// 78 | /// 79 | /// 80 | /// 81 | /// 82 | /// 83 | /// 84 | /// 85 | /// 86 | /// 87 | 88 | /// 89 | -------------------------------------------------------------------------------- /wednesday/class5-online/node_modules/@types/node/ts4.8/index.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * License for programmatically and manually incorporated 3 | * documentation aka. `JSDoc` from https://github.com/nodejs/node/tree/master/doc 4 | * 5 | * Copyright Node.js contributors. All rights reserved. 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | */ 24 | 25 | // NOTE: These definitions support NodeJS and TypeScript 4.8 and earlier. 26 | 27 | // Reference required types from the default lib: 28 | /// 29 | /// 30 | /// 31 | /// 32 | 33 | // Base definitions for all NodeJS modules that are not specific to any version of TypeScript: 34 | /// 35 | /// 36 | /// 37 | /// 38 | /// 39 | /// 40 | /// 41 | /// 42 | /// 43 | /// 44 | /// 45 | /// 46 | /// 47 | /// 48 | /// 49 | /// 50 | /// 51 | /// 52 | /// 53 | /// 54 | /// 55 | /// 56 | /// 57 | /// 58 | /// 59 | /// 60 | /// 61 | /// 62 | /// 63 | /// 64 | /// 65 | /// 66 | /// 67 | /// 68 | /// 69 | /// 70 | /// 71 | /// 72 | /// 73 | /// 74 | /// 75 | /// 76 | /// 77 | /// 78 | /// 79 | /// 80 | /// 81 | /// 82 | /// 83 | /// 84 | /// 85 | /// 86 | /// 87 | 88 | /// 89 | -------------------------------------------------------------------------------- /wednesday/class7/main.ts: -------------------------------------------------------------------------------- 1 | interface Deal1 { 2 | food: string 3 | } 4 | 5 | interface Deal2 { 6 | food: string; 7 | drink: string 8 | } 9 | 10 | let hamzahOrderTray: Deal1 = { 11 | food: "biryani", 12 | } 13 | 14 | let okashaOrderTray: Deal2 = { 15 | food: "biryani", 16 | drink: "pepsi", 17 | } 18 | 19 | 20 | // let hamzah: Deal1 = hamzahOrderTray; // No Error 21 | 22 | // Stale Object 23 | let hamzah1: Deal1 = okashaOrderTray; // No Error 24 | 25 | // Fresh Object 26 | // let hamzah: Deal1 = { 27 | // food: "biryani", 28 | // drink: "pepsi" 29 | // } 30 | 31 | 32 | 33 | interface Ball { 34 | diameter: number; 35 | } 36 | 37 | interface Sphere { 38 | diameter: number; 39 | } 40 | 41 | interface ITube { 42 | diameter: number; 43 | length: number; 44 | } 45 | 46 | let ball: Ball = { diameter: 10 }; 47 | let sphere: Sphere = { diameter: 20 }; 48 | 49 | sphere = ball; 50 | ball = sphere; 51 | 52 | 53 | let tube: ITube = { 54 | diameter: 22, 55 | length: 10 56 | } 57 | 58 | ball = tube 59 | 60 | // tube = ball 61 | 62 | // let user1 = { name: "Zia", id: 1 }; 63 | 64 | // user1 = { id: 2, name: "hamzah" } 65 | 66 | // user1 = { id: 2, name: "hamzah" } 67 | 68 | // // user1 = {id: 3, firstName: "Ali"} 69 | 70 | // // user1 = {id: 4, name: "arham", age: 22} 71 | 72 | // let user1 = { name: "Zia", id: 1 }; 73 | 74 | // let user2 = { 75 | // name: "Hamzah Syed", 76 | // id: 22, 77 | // firstName: "Hamzah", 78 | // }; 79 | 80 | 81 | // user1 = user2 82 | 83 | 84 | // type Author = { 85 | // firstName: string, 86 | // lastName: string 87 | // } 88 | 89 | // let author: Author = { 90 | // firstName: "okasha", 91 | // lastName: "aijaz" 92 | // } 93 | 94 | // type Author = { 95 | // firstName: string, 96 | // lastName: string 97 | // } 98 | // type Book = { 99 | // name: string, 100 | // author: Author 101 | // } 102 | 103 | // let book1: Book = { 104 | // author: { 105 | // firstName: "Hamzah", 106 | // lastName: "Syed" 107 | // }, 108 | // name: "Javascript" 109 | // } 110 | 111 | 112 | // interface Student { 113 | // student_id: number; 114 | // name: string; 115 | // age: number 116 | // } 117 | 118 | // interface Teacher { 119 | // teacher_Id: number; 120 | // teacher_name: string; 121 | // age: number 122 | // } 123 | // type Intersection = Student & Teacher 124 | // let intersection: Intersection = { 125 | // name: 'okasha', 126 | // student_id: 1, 127 | // teacher_Id: 2, 128 | // teacher_name: "hamza", 129 | // age: 12, 130 | // } 131 | 132 | // let student: Student = { 133 | // name: "ali", 134 | // student_id: 1 135 | // } 136 | 137 | // let teacher:Teacher = { 138 | // teacher_Id:2, 139 | // teacher_name:"zia" 140 | // } 141 | 142 | 143 | 144 | // let a: any = 10 145 | // a = 20 146 | // a = "20" 147 | // a = { a: "abc" } 148 | // a = [1, 2, 3] 149 | 150 | 151 | // let b: unknown 152 | // b = 10 153 | // b = "abc" 154 | // b = { ab: "ab" } 155 | // b = [1, 2, 3] 156 | // b = function () { 157 | 158 | // } 159 | // b = true 160 | 161 | // let c:boolean = a 162 | // let c: boolean = b 163 | 164 | 165 | // let firstName: string = "okasha" 166 | // if (typeof firstName === "string") { 167 | // console.log(firstName); 168 | // } 169 | // else { 170 | // console.log(`else ${firstName}`); 171 | // } 172 | 173 | 174 | // type Custom = string & number 175 | // let a:Custom = "10" 176 | 177 | 178 | // let something: unknown = "zia" 179 | // let knownType = something as string 180 | // let knownType = something 181 | // let a = something as unknown as number 182 | 183 | 184 | const enum Days { 185 | MONDAY = 1, 186 | TUESDAY, 187 | WEDNESDAY = 20, 188 | THURSDAY, 189 | FRIDAY, 190 | SATURDAY, 191 | SUNDAY 192 | } 193 | 194 | function assignTask(day: Days) { 195 | if (day === Days.MONDAY) { 196 | console.log("Admin word"); 197 | } 198 | else if (day === Days.TUESDAY) { 199 | console.log("Admin word"); 200 | } 201 | else if (day === Days.THURSDAY) { 202 | console.log("Admin word"); 203 | } 204 | else { 205 | console.log("else"); 206 | } 207 | } 208 | 209 | assignTask(Days.MONDAY) 210 | // console.log(Days[1]); 211 | console.log(Days.FRIDAY); 212 | 213 | 214 | 215 | 216 | -------------------------------------------------------------------------------- /thursday/class7/main.ts: -------------------------------------------------------------------------------- 1 | // let user1 = { 2 | // name: "hamzah", 3 | // age: 18 4 | // } 5 | 6 | // let user2 = { 7 | // name: "Ali", 8 | // age:22 9 | // } 10 | 11 | 12 | // user1 = user2 13 | 14 | // console.log(user1.name) 15 | 16 | 17 | interface Deal1 { 18 | food: string; 19 | } 20 | 21 | interface Deal2 { 22 | food: string; 23 | drink: string; 24 | } 25 | 26 | 27 | 28 | let hamzahTray: Deal1 = { 29 | food: "Biryani", 30 | }; 31 | 32 | let okashaTray: Deal2 = { 33 | food: "Biryani", 34 | drink: "Pepsi", 35 | } 36 | 37 | 38 | // let hamzah: Deal1 = hamzahTray; 39 | 40 | // Stale Object 41 | // let hamzah: Deal1 = okashaTray // NO ERROR 42 | 43 | // // Fresh Object 44 | // let hamzah1: Deal1 = { // Error 45 | // food: "Biryani", 46 | // drink: "Pepsi" // No extra property 47 | // } 48 | 49 | // // let okasha: Deal2 = hamzahTray 50 | 51 | // let okasha: Deal2 = okashaTray 52 | 53 | 54 | 55 | // let okasha: Deal2 56 | 57 | 58 | interface Ball { 59 | diameter: number; 60 | } 61 | 62 | interface Sphere { 63 | diameter: number; 64 | } 65 | 66 | interface Tube { 67 | diameter: number; 68 | length: number; 69 | } 70 | 71 | // let ball: Ball = { 72 | // diameter: 50, 73 | // } 74 | 75 | // let sphere: Sphere = { 76 | // diameter: 10 77 | // } 78 | 79 | // ball = sphere; 80 | // sphere = ball; 81 | 82 | let ball: Ball = { 83 | diameter: 50, 84 | } 85 | 86 | let tube: Tube = { 87 | length: 20, 88 | diameter: 50 89 | } 90 | 91 | // ball = tube 92 | 93 | // tube = ball 94 | 95 | 96 | // let user1 = { name: "Zia", id: 1 }; 97 | // user1 = {id: 2, name:"Hamzah"}; 98 | 99 | // user1 = {id: 3, firstName: "Hamzah"} 100 | 101 | 102 | // user1 = {id:4, name:"Hamzah", age:22} 103 | 104 | 105 | let user1 = { name: "Zia", id: 1 }; 106 | let user2 = { name: "Hamzah", id: 2, age: 22 } 107 | let user3 = { firstName: "Hamzah", id: 3 } 108 | 109 | // user1 = user3x 110 | 111 | // console.log(user1) 112 | 113 | // type AllTypes = string | number | boolean 114 | // let a: AllTypes = 10 115 | // let b: AllTypes = "10" 116 | 117 | // type Author = { 118 | // firstName: string; 119 | // lastName: string; 120 | // }; 121 | 122 | // type Book = { 123 | // name: string; 124 | // author: Author; 125 | // }; 126 | 127 | // let book: Book = { 128 | // name: "Javascript", 129 | // author: { 130 | // firstName: "Hmaza", 131 | // lastName: "Syed" 132 | // } 133 | // } 134 | 135 | // console.log(book.author); 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | // interface Student { 144 | // student_id: number; 145 | // name: string; 146 | // } 147 | 148 | // interface Teacher { 149 | // teacher_Id: number; 150 | // teacher_name: string; 151 | // } 152 | 153 | // let student1: Student = { 154 | // name: "Ali", 155 | // student_id: 1 156 | // } 157 | 158 | // let teacher1: Teacher = { 159 | // teacher_name: "zia", 160 | // teacher_Id: 1 161 | // } 162 | 163 | // type InterSection = Student & Teacher 164 | 165 | // let obj: InterSection = { 166 | // student_id: 1, 167 | // name: "okasha", 168 | // teacher_Id: 2, 169 | // teacher_name: "Hamza" 170 | // } 171 | 172 | 173 | 174 | 175 | // let a: any = 10 176 | // a = "abc" 177 | // a = true 178 | // a = { name: "okasha" } 179 | // a = [1, 2, 3] 180 | // a = function () { 181 | // console.log("abc"); 182 | // } 183 | 184 | 185 | 186 | // let b: unknown = 10 187 | // b = "abc" 188 | // b = false 189 | // b = { name: "okasha" } 190 | // b = [1, 2, 2] 191 | // b = function () { 192 | 193 | // } 194 | 195 | 196 | // let c: boolean = a 197 | // let c: boolean = b 198 | 199 | 200 | 201 | // let a = 10 202 | // if (typeof a === "number") { 203 | // console.log(a); 204 | // } 205 | // else { 206 | // console.log("else", a); 207 | // } 208 | 209 | // type Custom = string & number 210 | 211 | 212 | 213 | // let myname: string = "okasha" 214 | // let myupdatedtype = myname as string 215 | // let myupdatedtype = myname 216 | // let myupdatedtype = myname as unknown as number 217 | 218 | 219 | 220 | 221 | const enum TrafficLights { 222 | RED, 223 | GREEN = 20, 224 | YELLOW 225 | } 226 | 227 | let redColor: TrafficLights = TrafficLights.RED 228 | let greenColor: TrafficLights = TrafficLights.GREEN 229 | 230 | console.log(redColor); 231 | 232 | -------------------------------------------------------------------------------- /thursday/class5-online/node_modules/@types/node/module.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @since v0.3.7 3 | */ 4 | declare module 'module' { 5 | import { URL } from 'node:url'; 6 | namespace Module { 7 | /** 8 | * The `module.syncBuiltinESMExports()` method updates all the live bindings for 9 | * builtin `ES Modules` to match the properties of the `CommonJS` exports. It 10 | * does not add or remove exported names from the `ES Modules`. 11 | * 12 | * ```js 13 | * const fs = require('node:fs'); 14 | * const assert = require('node:assert'); 15 | * const { syncBuiltinESMExports } = require('node:module'); 16 | * 17 | * fs.readFile = newAPI; 18 | * 19 | * delete fs.readFileSync; 20 | * 21 | * function newAPI() { 22 | * // ... 23 | * } 24 | * 25 | * fs.newAPI = newAPI; 26 | * 27 | * syncBuiltinESMExports(); 28 | * 29 | * import('node:fs').then((esmFS) => { 30 | * // It syncs the existing readFile property with the new value 31 | * assert.strictEqual(esmFS.readFile, newAPI); 32 | * // readFileSync has been deleted from the required fs 33 | * assert.strictEqual('readFileSync' in fs, false); 34 | * // syncBuiltinESMExports() does not remove readFileSync from esmFS 35 | * assert.strictEqual('readFileSync' in esmFS, true); 36 | * // syncBuiltinESMExports() does not add names 37 | * assert.strictEqual(esmFS.newAPI, undefined); 38 | * }); 39 | * ``` 40 | * @since v12.12.0 41 | */ 42 | function syncBuiltinESMExports(): void; 43 | /** 44 | * `path` is the resolved path for the file for which a corresponding source map 45 | * should be fetched. 46 | * @since v13.7.0, v12.17.0 47 | * @return Returns `module.SourceMap` if a source map is found, `undefined` otherwise. 48 | */ 49 | function findSourceMap(path: string, error?: Error): SourceMap; 50 | interface SourceMapPayload { 51 | file: string; 52 | version: number; 53 | sources: string[]; 54 | sourcesContent: string[]; 55 | names: string[]; 56 | mappings: string; 57 | sourceRoot: string; 58 | } 59 | interface SourceMapping { 60 | generatedLine: number; 61 | generatedColumn: number; 62 | originalSource: string; 63 | originalLine: number; 64 | originalColumn: number; 65 | } 66 | /** 67 | * @since v13.7.0, v12.17.0 68 | */ 69 | class SourceMap { 70 | /** 71 | * Getter for the payload used to construct the `SourceMap` instance. 72 | */ 73 | readonly payload: SourceMapPayload; 74 | constructor(payload: SourceMapPayload); 75 | /** 76 | * Given a line offset and column offset in the generated source 77 | * file, returns an object representing the SourceMap range in the 78 | * original file if found, or an empty object if not. 79 | * 80 | * The object returned contains the following keys: 81 | * 82 | * The returned value represents the raw range as it appears in the 83 | * SourceMap, based on zero-indexed offsets, _not_ 1-indexed line and 84 | * column numbers as they appear in Error messages and CallSite 85 | * objects. 86 | * 87 | * To get the corresponding 1-indexed line and column numbers from a 88 | * lineNumber and columnNumber as they are reported by Error stacks 89 | * and CallSite objects, use `sourceMap.findOrigin(lineNumber, columnNumber)` 90 | * @param lineOffset The zero-indexed line number offset in the generated source 91 | * @param columnOffset The zero-indexed column number offset in the generated source 92 | */ 93 | findEntry(lineOffset: number, columnOffset: number): SourceMapping; 94 | } 95 | } 96 | interface Module extends NodeModule {} 97 | class Module { 98 | static runMain(): void; 99 | static wrap(code: string): string; 100 | static createRequire(path: string | URL): NodeRequire; 101 | static builtinModules: string[]; 102 | static isBuiltin(moduleName: string): boolean; 103 | static Module: typeof Module; 104 | constructor(id: string, parent?: Module); 105 | } 106 | global { 107 | interface ImportMeta { 108 | url: string; 109 | /** 110 | * @experimental 111 | * This feature is only available with the `--experimental-import-meta-resolve` 112 | * command flag enabled. 113 | * 114 | * Provides a module-relative resolution function scoped to each module, returning 115 | * the URL string. 116 | * 117 | * @param specified The module specifier to resolve relative to `parent`. 118 | * @param parent The absolute parent module URL to resolve from. If none 119 | * is specified, the value of `import.meta.url` is used as the default. 120 | */ 121 | resolve?(specified: string, parent?: string | URL): Promise; 122 | } 123 | } 124 | export = Module; 125 | } 126 | declare module 'node:module' { 127 | import module = require('module'); 128 | export = module; 129 | } 130 | -------------------------------------------------------------------------------- /wednesday/class5-online/node_modules/@types/node/module.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @since v0.3.7 3 | */ 4 | declare module 'module' { 5 | import { URL } from 'node:url'; 6 | namespace Module { 7 | /** 8 | * The `module.syncBuiltinESMExports()` method updates all the live bindings for 9 | * builtin `ES Modules` to match the properties of the `CommonJS` exports. It 10 | * does not add or remove exported names from the `ES Modules`. 11 | * 12 | * ```js 13 | * const fs = require('node:fs'); 14 | * const assert = require('node:assert'); 15 | * const { syncBuiltinESMExports } = require('node:module'); 16 | * 17 | * fs.readFile = newAPI; 18 | * 19 | * delete fs.readFileSync; 20 | * 21 | * function newAPI() { 22 | * // ... 23 | * } 24 | * 25 | * fs.newAPI = newAPI; 26 | * 27 | * syncBuiltinESMExports(); 28 | * 29 | * import('node:fs').then((esmFS) => { 30 | * // It syncs the existing readFile property with the new value 31 | * assert.strictEqual(esmFS.readFile, newAPI); 32 | * // readFileSync has been deleted from the required fs 33 | * assert.strictEqual('readFileSync' in fs, false); 34 | * // syncBuiltinESMExports() does not remove readFileSync from esmFS 35 | * assert.strictEqual('readFileSync' in esmFS, true); 36 | * // syncBuiltinESMExports() does not add names 37 | * assert.strictEqual(esmFS.newAPI, undefined); 38 | * }); 39 | * ``` 40 | * @since v12.12.0 41 | */ 42 | function syncBuiltinESMExports(): void; 43 | /** 44 | * `path` is the resolved path for the file for which a corresponding source map 45 | * should be fetched. 46 | * @since v13.7.0, v12.17.0 47 | * @return Returns `module.SourceMap` if a source map is found, `undefined` otherwise. 48 | */ 49 | function findSourceMap(path: string, error?: Error): SourceMap; 50 | interface SourceMapPayload { 51 | file: string; 52 | version: number; 53 | sources: string[]; 54 | sourcesContent: string[]; 55 | names: string[]; 56 | mappings: string; 57 | sourceRoot: string; 58 | } 59 | interface SourceMapping { 60 | generatedLine: number; 61 | generatedColumn: number; 62 | originalSource: string; 63 | originalLine: number; 64 | originalColumn: number; 65 | } 66 | /** 67 | * @since v13.7.0, v12.17.0 68 | */ 69 | class SourceMap { 70 | /** 71 | * Getter for the payload used to construct the `SourceMap` instance. 72 | */ 73 | readonly payload: SourceMapPayload; 74 | constructor(payload: SourceMapPayload); 75 | /** 76 | * Given a line offset and column offset in the generated source 77 | * file, returns an object representing the SourceMap range in the 78 | * original file if found, or an empty object if not. 79 | * 80 | * The object returned contains the following keys: 81 | * 82 | * The returned value represents the raw range as it appears in the 83 | * SourceMap, based on zero-indexed offsets, _not_ 1-indexed line and 84 | * column numbers as they appear in Error messages and CallSite 85 | * objects. 86 | * 87 | * To get the corresponding 1-indexed line and column numbers from a 88 | * lineNumber and columnNumber as they are reported by Error stacks 89 | * and CallSite objects, use `sourceMap.findOrigin(lineNumber, columnNumber)` 90 | * @param lineOffset The zero-indexed line number offset in the generated source 91 | * @param columnOffset The zero-indexed column number offset in the generated source 92 | */ 93 | findEntry(lineOffset: number, columnOffset: number): SourceMapping; 94 | } 95 | } 96 | interface Module extends NodeModule {} 97 | class Module { 98 | static runMain(): void; 99 | static wrap(code: string): string; 100 | static createRequire(path: string | URL): NodeRequire; 101 | static builtinModules: string[]; 102 | static isBuiltin(moduleName: string): boolean; 103 | static Module: typeof Module; 104 | constructor(id: string, parent?: Module); 105 | } 106 | global { 107 | interface ImportMeta { 108 | url: string; 109 | /** 110 | * @experimental 111 | * This feature is only available with the `--experimental-import-meta-resolve` 112 | * command flag enabled. 113 | * 114 | * Provides a module-relative resolution function scoped to each module, returning 115 | * the URL string. 116 | * 117 | * @param specified The module specifier to resolve relative to `parent`. 118 | * @param parent The absolute parent module URL to resolve from. If none 119 | * is specified, the value of `import.meta.url` is used as the default. 120 | */ 121 | resolve?(specified: string, parent?: string | URL): Promise; 122 | } 123 | } 124 | export = Module; 125 | } 126 | declare module 'node:module' { 127 | import module = require('module'); 128 | export = module; 129 | } 130 | -------------------------------------------------------------------------------- /thursday/class5-online/node_modules/@types/node/ts4.8/module.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @since v0.3.7 3 | */ 4 | declare module 'module' { 5 | import { URL } from 'node:url'; 6 | namespace Module { 7 | /** 8 | * The `module.syncBuiltinESMExports()` method updates all the live bindings for 9 | * builtin `ES Modules` to match the properties of the `CommonJS` exports. It 10 | * does not add or remove exported names from the `ES Modules`. 11 | * 12 | * ```js 13 | * const fs = require('node:fs'); 14 | * const assert = require('node:assert'); 15 | * const { syncBuiltinESMExports } = require('node:module'); 16 | * 17 | * fs.readFile = newAPI; 18 | * 19 | * delete fs.readFileSync; 20 | * 21 | * function newAPI() { 22 | * // ... 23 | * } 24 | * 25 | * fs.newAPI = newAPI; 26 | * 27 | * syncBuiltinESMExports(); 28 | * 29 | * import('node:fs').then((esmFS) => { 30 | * // It syncs the existing readFile property with the new value 31 | * assert.strictEqual(esmFS.readFile, newAPI); 32 | * // readFileSync has been deleted from the required fs 33 | * assert.strictEqual('readFileSync' in fs, false); 34 | * // syncBuiltinESMExports() does not remove readFileSync from esmFS 35 | * assert.strictEqual('readFileSync' in esmFS, true); 36 | * // syncBuiltinESMExports() does not add names 37 | * assert.strictEqual(esmFS.newAPI, undefined); 38 | * }); 39 | * ``` 40 | * @since v12.12.0 41 | */ 42 | function syncBuiltinESMExports(): void; 43 | /** 44 | * `path` is the resolved path for the file for which a corresponding source map 45 | * should be fetched. 46 | * @since v13.7.0, v12.17.0 47 | * @return Returns `module.SourceMap` if a source map is found, `undefined` otherwise. 48 | */ 49 | function findSourceMap(path: string, error?: Error): SourceMap; 50 | interface SourceMapPayload { 51 | file: string; 52 | version: number; 53 | sources: string[]; 54 | sourcesContent: string[]; 55 | names: string[]; 56 | mappings: string; 57 | sourceRoot: string; 58 | } 59 | interface SourceMapping { 60 | generatedLine: number; 61 | generatedColumn: number; 62 | originalSource: string; 63 | originalLine: number; 64 | originalColumn: number; 65 | } 66 | /** 67 | * @since v13.7.0, v12.17.0 68 | */ 69 | class SourceMap { 70 | /** 71 | * Getter for the payload used to construct the `SourceMap` instance. 72 | */ 73 | readonly payload: SourceMapPayload; 74 | constructor(payload: SourceMapPayload); 75 | /** 76 | * Given a line offset and column offset in the generated source 77 | * file, returns an object representing the SourceMap range in the 78 | * original file if found, or an empty object if not. 79 | * 80 | * The object returned contains the following keys: 81 | * 82 | * The returned value represents the raw range as it appears in the 83 | * SourceMap, based on zero-indexed offsets, _not_ 1-indexed line and 84 | * column numbers as they appear in Error messages and CallSite 85 | * objects. 86 | * 87 | * To get the corresponding 1-indexed line and column numbers from a 88 | * lineNumber and columnNumber as they are reported by Error stacks 89 | * and CallSite objects, use `sourceMap.findOrigin(lineNumber, columnNumber)` 90 | * @param lineOffset The zero-indexed line number offset in the generated source 91 | * @param columnOffset The zero-indexed column number offset in the generated source 92 | */ 93 | findEntry(lineOffset: number, columnOffset: number): SourceMapping; 94 | } 95 | } 96 | interface Module extends NodeModule {} 97 | class Module { 98 | static runMain(): void; 99 | static wrap(code: string): string; 100 | static createRequire(path: string | URL): NodeRequire; 101 | static builtinModules: string[]; 102 | static isBuiltin(moduleName: string): boolean; 103 | static Module: typeof Module; 104 | constructor(id: string, parent?: Module); 105 | } 106 | global { 107 | interface ImportMeta { 108 | url: string; 109 | /** 110 | * @experimental 111 | * This feature is only available with the `--experimental-import-meta-resolve` 112 | * command flag enabled. 113 | * 114 | * Provides a module-relative resolution function scoped to each module, returning 115 | * the URL string. 116 | * 117 | * @param specified The module specifier to resolve relative to `parent`. 118 | * @param parent The absolute parent module URL to resolve from. If none 119 | * is specified, the value of `import.meta.url` is used as the default. 120 | */ 121 | resolve?(specified: string, parent?: string | URL): Promise; 122 | } 123 | } 124 | export = Module; 125 | } 126 | declare module 'node:module' { 127 | import module = require('module'); 128 | export = module; 129 | } 130 | -------------------------------------------------------------------------------- /wednesday/class5-online/node_modules/@types/node/ts4.8/module.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @since v0.3.7 3 | */ 4 | declare module 'module' { 5 | import { URL } from 'node:url'; 6 | namespace Module { 7 | /** 8 | * The `module.syncBuiltinESMExports()` method updates all the live bindings for 9 | * builtin `ES Modules` to match the properties of the `CommonJS` exports. It 10 | * does not add or remove exported names from the `ES Modules`. 11 | * 12 | * ```js 13 | * const fs = require('node:fs'); 14 | * const assert = require('node:assert'); 15 | * const { syncBuiltinESMExports } = require('node:module'); 16 | * 17 | * fs.readFile = newAPI; 18 | * 19 | * delete fs.readFileSync; 20 | * 21 | * function newAPI() { 22 | * // ... 23 | * } 24 | * 25 | * fs.newAPI = newAPI; 26 | * 27 | * syncBuiltinESMExports(); 28 | * 29 | * import('node:fs').then((esmFS) => { 30 | * // It syncs the existing readFile property with the new value 31 | * assert.strictEqual(esmFS.readFile, newAPI); 32 | * // readFileSync has been deleted from the required fs 33 | * assert.strictEqual('readFileSync' in fs, false); 34 | * // syncBuiltinESMExports() does not remove readFileSync from esmFS 35 | * assert.strictEqual('readFileSync' in esmFS, true); 36 | * // syncBuiltinESMExports() does not add names 37 | * assert.strictEqual(esmFS.newAPI, undefined); 38 | * }); 39 | * ``` 40 | * @since v12.12.0 41 | */ 42 | function syncBuiltinESMExports(): void; 43 | /** 44 | * `path` is the resolved path for the file for which a corresponding source map 45 | * should be fetched. 46 | * @since v13.7.0, v12.17.0 47 | * @return Returns `module.SourceMap` if a source map is found, `undefined` otherwise. 48 | */ 49 | function findSourceMap(path: string, error?: Error): SourceMap; 50 | interface SourceMapPayload { 51 | file: string; 52 | version: number; 53 | sources: string[]; 54 | sourcesContent: string[]; 55 | names: string[]; 56 | mappings: string; 57 | sourceRoot: string; 58 | } 59 | interface SourceMapping { 60 | generatedLine: number; 61 | generatedColumn: number; 62 | originalSource: string; 63 | originalLine: number; 64 | originalColumn: number; 65 | } 66 | /** 67 | * @since v13.7.0, v12.17.0 68 | */ 69 | class SourceMap { 70 | /** 71 | * Getter for the payload used to construct the `SourceMap` instance. 72 | */ 73 | readonly payload: SourceMapPayload; 74 | constructor(payload: SourceMapPayload); 75 | /** 76 | * Given a line offset and column offset in the generated source 77 | * file, returns an object representing the SourceMap range in the 78 | * original file if found, or an empty object if not. 79 | * 80 | * The object returned contains the following keys: 81 | * 82 | * The returned value represents the raw range as it appears in the 83 | * SourceMap, based on zero-indexed offsets, _not_ 1-indexed line and 84 | * column numbers as they appear in Error messages and CallSite 85 | * objects. 86 | * 87 | * To get the corresponding 1-indexed line and column numbers from a 88 | * lineNumber and columnNumber as they are reported by Error stacks 89 | * and CallSite objects, use `sourceMap.findOrigin(lineNumber, columnNumber)` 90 | * @param lineOffset The zero-indexed line number offset in the generated source 91 | * @param columnOffset The zero-indexed column number offset in the generated source 92 | */ 93 | findEntry(lineOffset: number, columnOffset: number): SourceMapping; 94 | } 95 | } 96 | interface Module extends NodeModule {} 97 | class Module { 98 | static runMain(): void; 99 | static wrap(code: string): string; 100 | static createRequire(path: string | URL): NodeRequire; 101 | static builtinModules: string[]; 102 | static isBuiltin(moduleName: string): boolean; 103 | static Module: typeof Module; 104 | constructor(id: string, parent?: Module); 105 | } 106 | global { 107 | interface ImportMeta { 108 | url: string; 109 | /** 110 | * @experimental 111 | * This feature is only available with the `--experimental-import-meta-resolve` 112 | * command flag enabled. 113 | * 114 | * Provides a module-relative resolution function scoped to each module, returning 115 | * the URL string. 116 | * 117 | * @param specified The module specifier to resolve relative to `parent`. 118 | * @param parent The absolute parent module URL to resolve from. If none 119 | * is specified, the value of `import.meta.url` is used as the default. 120 | */ 121 | resolve?(specified: string, parent?: string | URL): Promise; 122 | } 123 | } 124 | export = Module; 125 | } 126 | declare module 'node:module' { 127 | import module = require('module'); 128 | export = module; 129 | } 130 | -------------------------------------------------------------------------------- /thursday/class5-online/node_modules/@types/node/punycode.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * **The version of the punycode module bundled in Node.js is being deprecated.**In a future major version of Node.js this module will be removed. Users 3 | * currently depending on the `punycode` module should switch to using the 4 | * userland-provided [Punycode.js](https://github.com/bestiejs/punycode.js) module instead. For punycode-based URL 5 | * encoding, see `url.domainToASCII` or, more generally, the `WHATWG URL API`. 6 | * 7 | * The `punycode` module is a bundled version of the [Punycode.js](https://github.com/bestiejs/punycode.js) module. It 8 | * can be accessed using: 9 | * 10 | * ```js 11 | * const punycode = require('punycode'); 12 | * ``` 13 | * 14 | * [Punycode](https://tools.ietf.org/html/rfc3492) is a character encoding scheme defined by RFC 3492 that is 15 | * primarily intended for use in Internationalized Domain Names. Because host 16 | * names in URLs are limited to ASCII characters only, Domain Names that contain 17 | * non-ASCII characters must be converted into ASCII using the Punycode scheme. 18 | * For instance, the Japanese character that translates into the English word,`'example'` is `'例'`. The Internationalized Domain Name, `'例.com'` (equivalent 19 | * to `'example.com'`) is represented by Punycode as the ASCII string`'xn--fsq.com'`. 20 | * 21 | * The `punycode` module provides a simple implementation of the Punycode standard. 22 | * 23 | * The `punycode` module is a third-party dependency used by Node.js and 24 | * made available to developers as a convenience. Fixes or other modifications to 25 | * the module must be directed to the [Punycode.js](https://github.com/bestiejs/punycode.js) project. 26 | * @deprecated Since v7.0.0 - Deprecated 27 | * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/punycode.js) 28 | */ 29 | declare module 'punycode' { 30 | /** 31 | * The `punycode.decode()` method converts a [Punycode](https://tools.ietf.org/html/rfc3492) string of ASCII-only 32 | * characters to the equivalent string of Unicode codepoints. 33 | * 34 | * ```js 35 | * punycode.decode('maana-pta'); // 'mañana' 36 | * punycode.decode('--dqo34k'); // '☃-⌘' 37 | * ``` 38 | * @since v0.5.1 39 | */ 40 | function decode(string: string): string; 41 | /** 42 | * The `punycode.encode()` method converts a string of Unicode codepoints to a [Punycode](https://tools.ietf.org/html/rfc3492) string of ASCII-only characters. 43 | * 44 | * ```js 45 | * punycode.encode('mañana'); // 'maana-pta' 46 | * punycode.encode('☃-⌘'); // '--dqo34k' 47 | * ``` 48 | * @since v0.5.1 49 | */ 50 | function encode(string: string): string; 51 | /** 52 | * The `punycode.toUnicode()` method converts a string representing a domain name 53 | * containing [Punycode](https://tools.ietf.org/html/rfc3492) encoded characters into Unicode. Only the [Punycode](https://tools.ietf.org/html/rfc3492) encoded parts of the domain name are be 54 | * converted. 55 | * 56 | * ```js 57 | * // decode domain names 58 | * punycode.toUnicode('xn--maana-pta.com'); // 'mañana.com' 59 | * punycode.toUnicode('xn----dqo34k.com'); // '☃-⌘.com' 60 | * punycode.toUnicode('example.com'); // 'example.com' 61 | * ``` 62 | * @since v0.6.1 63 | */ 64 | function toUnicode(domain: string): string; 65 | /** 66 | * The `punycode.toASCII()` method converts a Unicode string representing an 67 | * Internationalized Domain Name to [Punycode](https://tools.ietf.org/html/rfc3492). Only the non-ASCII parts of the 68 | * domain name will be converted. Calling `punycode.toASCII()` on a string that 69 | * already only contains ASCII characters will have no effect. 70 | * 71 | * ```js 72 | * // encode domain names 73 | * punycode.toASCII('mañana.com'); // 'xn--maana-pta.com' 74 | * punycode.toASCII('☃-⌘.com'); // 'xn----dqo34k.com' 75 | * punycode.toASCII('example.com'); // 'example.com' 76 | * ``` 77 | * @since v0.6.1 78 | */ 79 | function toASCII(domain: string): string; 80 | /** 81 | * @deprecated since v7.0.0 82 | * The version of the punycode module bundled in Node.js is being deprecated. 83 | * In a future major version of Node.js this module will be removed. 84 | * Users currently depending on the punycode module should switch to using 85 | * the userland-provided Punycode.js module instead. 86 | */ 87 | const ucs2: ucs2; 88 | interface ucs2 { 89 | /** 90 | * @deprecated since v7.0.0 91 | * The version of the punycode module bundled in Node.js is being deprecated. 92 | * In a future major version of Node.js this module will be removed. 93 | * Users currently depending on the punycode module should switch to using 94 | * the userland-provided Punycode.js module instead. 95 | */ 96 | decode(string: string): number[]; 97 | /** 98 | * @deprecated since v7.0.0 99 | * The version of the punycode module bundled in Node.js is being deprecated. 100 | * In a future major version of Node.js this module will be removed. 101 | * Users currently depending on the punycode module should switch to using 102 | * the userland-provided Punycode.js module instead. 103 | */ 104 | encode(codePoints: ReadonlyArray): string; 105 | } 106 | /** 107 | * @deprecated since v7.0.0 108 | * The version of the punycode module bundled in Node.js is being deprecated. 109 | * In a future major version of Node.js this module will be removed. 110 | * Users currently depending on the punycode module should switch to using 111 | * the userland-provided Punycode.js module instead. 112 | */ 113 | const version: string; 114 | } 115 | declare module 'node:punycode' { 116 | export * from 'punycode'; 117 | } 118 | -------------------------------------------------------------------------------- /wednesday/class5-online/node_modules/@types/node/punycode.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * **The version of the punycode module bundled in Node.js is being deprecated.**In a future major version of Node.js this module will be removed. Users 3 | * currently depending on the `punycode` module should switch to using the 4 | * userland-provided [Punycode.js](https://github.com/bestiejs/punycode.js) module instead. For punycode-based URL 5 | * encoding, see `url.domainToASCII` or, more generally, the `WHATWG URL API`. 6 | * 7 | * The `punycode` module is a bundled version of the [Punycode.js](https://github.com/bestiejs/punycode.js) module. It 8 | * can be accessed using: 9 | * 10 | * ```js 11 | * const punycode = require('punycode'); 12 | * ``` 13 | * 14 | * [Punycode](https://tools.ietf.org/html/rfc3492) is a character encoding scheme defined by RFC 3492 that is 15 | * primarily intended for use in Internationalized Domain Names. Because host 16 | * names in URLs are limited to ASCII characters only, Domain Names that contain 17 | * non-ASCII characters must be converted into ASCII using the Punycode scheme. 18 | * For instance, the Japanese character that translates into the English word,`'example'` is `'例'`. The Internationalized Domain Name, `'例.com'` (equivalent 19 | * to `'example.com'`) is represented by Punycode as the ASCII string`'xn--fsq.com'`. 20 | * 21 | * The `punycode` module provides a simple implementation of the Punycode standard. 22 | * 23 | * The `punycode` module is a third-party dependency used by Node.js and 24 | * made available to developers as a convenience. Fixes or other modifications to 25 | * the module must be directed to the [Punycode.js](https://github.com/bestiejs/punycode.js) project. 26 | * @deprecated Since v7.0.0 - Deprecated 27 | * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/punycode.js) 28 | */ 29 | declare module 'punycode' { 30 | /** 31 | * The `punycode.decode()` method converts a [Punycode](https://tools.ietf.org/html/rfc3492) string of ASCII-only 32 | * characters to the equivalent string of Unicode codepoints. 33 | * 34 | * ```js 35 | * punycode.decode('maana-pta'); // 'mañana' 36 | * punycode.decode('--dqo34k'); // '☃-⌘' 37 | * ``` 38 | * @since v0.5.1 39 | */ 40 | function decode(string: string): string; 41 | /** 42 | * The `punycode.encode()` method converts a string of Unicode codepoints to a [Punycode](https://tools.ietf.org/html/rfc3492) string of ASCII-only characters. 43 | * 44 | * ```js 45 | * punycode.encode('mañana'); // 'maana-pta' 46 | * punycode.encode('☃-⌘'); // '--dqo34k' 47 | * ``` 48 | * @since v0.5.1 49 | */ 50 | function encode(string: string): string; 51 | /** 52 | * The `punycode.toUnicode()` method converts a string representing a domain name 53 | * containing [Punycode](https://tools.ietf.org/html/rfc3492) encoded characters into Unicode. Only the [Punycode](https://tools.ietf.org/html/rfc3492) encoded parts of the domain name are be 54 | * converted. 55 | * 56 | * ```js 57 | * // decode domain names 58 | * punycode.toUnicode('xn--maana-pta.com'); // 'mañana.com' 59 | * punycode.toUnicode('xn----dqo34k.com'); // '☃-⌘.com' 60 | * punycode.toUnicode('example.com'); // 'example.com' 61 | * ``` 62 | * @since v0.6.1 63 | */ 64 | function toUnicode(domain: string): string; 65 | /** 66 | * The `punycode.toASCII()` method converts a Unicode string representing an 67 | * Internationalized Domain Name to [Punycode](https://tools.ietf.org/html/rfc3492). Only the non-ASCII parts of the 68 | * domain name will be converted. Calling `punycode.toASCII()` on a string that 69 | * already only contains ASCII characters will have no effect. 70 | * 71 | * ```js 72 | * // encode domain names 73 | * punycode.toASCII('mañana.com'); // 'xn--maana-pta.com' 74 | * punycode.toASCII('☃-⌘.com'); // 'xn----dqo34k.com' 75 | * punycode.toASCII('example.com'); // 'example.com' 76 | * ``` 77 | * @since v0.6.1 78 | */ 79 | function toASCII(domain: string): string; 80 | /** 81 | * @deprecated since v7.0.0 82 | * The version of the punycode module bundled in Node.js is being deprecated. 83 | * In a future major version of Node.js this module will be removed. 84 | * Users currently depending on the punycode module should switch to using 85 | * the userland-provided Punycode.js module instead. 86 | */ 87 | const ucs2: ucs2; 88 | interface ucs2 { 89 | /** 90 | * @deprecated since v7.0.0 91 | * The version of the punycode module bundled in Node.js is being deprecated. 92 | * In a future major version of Node.js this module will be removed. 93 | * Users currently depending on the punycode module should switch to using 94 | * the userland-provided Punycode.js module instead. 95 | */ 96 | decode(string: string): number[]; 97 | /** 98 | * @deprecated since v7.0.0 99 | * The version of the punycode module bundled in Node.js is being deprecated. 100 | * In a future major version of Node.js this module will be removed. 101 | * Users currently depending on the punycode module should switch to using 102 | * the userland-provided Punycode.js module instead. 103 | */ 104 | encode(codePoints: ReadonlyArray): string; 105 | } 106 | /** 107 | * @deprecated since v7.0.0 108 | * The version of the punycode module bundled in Node.js is being deprecated. 109 | * In a future major version of Node.js this module will be removed. 110 | * Users currently depending on the punycode module should switch to using 111 | * the userland-provided Punycode.js module instead. 112 | */ 113 | const version: string; 114 | } 115 | declare module 'node:punycode' { 116 | export * from 'punycode'; 117 | } 118 | -------------------------------------------------------------------------------- /thursday/class5-online/node_modules/@types/node/ts4.8/punycode.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * **The version of the punycode module bundled in Node.js is being deprecated.**In a future major version of Node.js this module will be removed. Users 3 | * currently depending on the `punycode` module should switch to using the 4 | * userland-provided [Punycode.js](https://github.com/bestiejs/punycode.js) module instead. For punycode-based URL 5 | * encoding, see `url.domainToASCII` or, more generally, the `WHATWG URL API`. 6 | * 7 | * The `punycode` module is a bundled version of the [Punycode.js](https://github.com/bestiejs/punycode.js) module. It 8 | * can be accessed using: 9 | * 10 | * ```js 11 | * const punycode = require('punycode'); 12 | * ``` 13 | * 14 | * [Punycode](https://tools.ietf.org/html/rfc3492) is a character encoding scheme defined by RFC 3492 that is 15 | * primarily intended for use in Internationalized Domain Names. Because host 16 | * names in URLs are limited to ASCII characters only, Domain Names that contain 17 | * non-ASCII characters must be converted into ASCII using the Punycode scheme. 18 | * For instance, the Japanese character that translates into the English word,`'example'` is `'例'`. The Internationalized Domain Name, `'例.com'` (equivalent 19 | * to `'example.com'`) is represented by Punycode as the ASCII string`'xn--fsq.com'`. 20 | * 21 | * The `punycode` module provides a simple implementation of the Punycode standard. 22 | * 23 | * The `punycode` module is a third-party dependency used by Node.js and 24 | * made available to developers as a convenience. Fixes or other modifications to 25 | * the module must be directed to the [Punycode.js](https://github.com/bestiejs/punycode.js) project. 26 | * @deprecated Since v7.0.0 - Deprecated 27 | * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/punycode.js) 28 | */ 29 | declare module 'punycode' { 30 | /** 31 | * The `punycode.decode()` method converts a [Punycode](https://tools.ietf.org/html/rfc3492) string of ASCII-only 32 | * characters to the equivalent string of Unicode codepoints. 33 | * 34 | * ```js 35 | * punycode.decode('maana-pta'); // 'mañana' 36 | * punycode.decode('--dqo34k'); // '☃-⌘' 37 | * ``` 38 | * @since v0.5.1 39 | */ 40 | function decode(string: string): string; 41 | /** 42 | * The `punycode.encode()` method converts a string of Unicode codepoints to a [Punycode](https://tools.ietf.org/html/rfc3492) string of ASCII-only characters. 43 | * 44 | * ```js 45 | * punycode.encode('mañana'); // 'maana-pta' 46 | * punycode.encode('☃-⌘'); // '--dqo34k' 47 | * ``` 48 | * @since v0.5.1 49 | */ 50 | function encode(string: string): string; 51 | /** 52 | * The `punycode.toUnicode()` method converts a string representing a domain name 53 | * containing [Punycode](https://tools.ietf.org/html/rfc3492) encoded characters into Unicode. Only the [Punycode](https://tools.ietf.org/html/rfc3492) encoded parts of the domain name are be 54 | * converted. 55 | * 56 | * ```js 57 | * // decode domain names 58 | * punycode.toUnicode('xn--maana-pta.com'); // 'mañana.com' 59 | * punycode.toUnicode('xn----dqo34k.com'); // '☃-⌘.com' 60 | * punycode.toUnicode('example.com'); // 'example.com' 61 | * ``` 62 | * @since v0.6.1 63 | */ 64 | function toUnicode(domain: string): string; 65 | /** 66 | * The `punycode.toASCII()` method converts a Unicode string representing an 67 | * Internationalized Domain Name to [Punycode](https://tools.ietf.org/html/rfc3492). Only the non-ASCII parts of the 68 | * domain name will be converted. Calling `punycode.toASCII()` on a string that 69 | * already only contains ASCII characters will have no effect. 70 | * 71 | * ```js 72 | * // encode domain names 73 | * punycode.toASCII('mañana.com'); // 'xn--maana-pta.com' 74 | * punycode.toASCII('☃-⌘.com'); // 'xn----dqo34k.com' 75 | * punycode.toASCII('example.com'); // 'example.com' 76 | * ``` 77 | * @since v0.6.1 78 | */ 79 | function toASCII(domain: string): string; 80 | /** 81 | * @deprecated since v7.0.0 82 | * The version of the punycode module bundled in Node.js is being deprecated. 83 | * In a future major version of Node.js this module will be removed. 84 | * Users currently depending on the punycode module should switch to using 85 | * the userland-provided Punycode.js module instead. 86 | */ 87 | const ucs2: ucs2; 88 | interface ucs2 { 89 | /** 90 | * @deprecated since v7.0.0 91 | * The version of the punycode module bundled in Node.js is being deprecated. 92 | * In a future major version of Node.js this module will be removed. 93 | * Users currently depending on the punycode module should switch to using 94 | * the userland-provided Punycode.js module instead. 95 | */ 96 | decode(string: string): number[]; 97 | /** 98 | * @deprecated since v7.0.0 99 | * The version of the punycode module bundled in Node.js is being deprecated. 100 | * In a future major version of Node.js this module will be removed. 101 | * Users currently depending on the punycode module should switch to using 102 | * the userland-provided Punycode.js module instead. 103 | */ 104 | encode(codePoints: ReadonlyArray): string; 105 | } 106 | /** 107 | * @deprecated since v7.0.0 108 | * The version of the punycode module bundled in Node.js is being deprecated. 109 | * In a future major version of Node.js this module will be removed. 110 | * Users currently depending on the punycode module should switch to using 111 | * the userland-provided Punycode.js module instead. 112 | */ 113 | const version: string; 114 | } 115 | declare module 'node:punycode' { 116 | export * from 'punycode'; 117 | } 118 | -------------------------------------------------------------------------------- /wednesday/class5-online/node_modules/@types/node/ts4.8/punycode.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * **The version of the punycode module bundled in Node.js is being deprecated.**In a future major version of Node.js this module will be removed. Users 3 | * currently depending on the `punycode` module should switch to using the 4 | * userland-provided [Punycode.js](https://github.com/bestiejs/punycode.js) module instead. For punycode-based URL 5 | * encoding, see `url.domainToASCII` or, more generally, the `WHATWG URL API`. 6 | * 7 | * The `punycode` module is a bundled version of the [Punycode.js](https://github.com/bestiejs/punycode.js) module. It 8 | * can be accessed using: 9 | * 10 | * ```js 11 | * const punycode = require('punycode'); 12 | * ``` 13 | * 14 | * [Punycode](https://tools.ietf.org/html/rfc3492) is a character encoding scheme defined by RFC 3492 that is 15 | * primarily intended for use in Internationalized Domain Names. Because host 16 | * names in URLs are limited to ASCII characters only, Domain Names that contain 17 | * non-ASCII characters must be converted into ASCII using the Punycode scheme. 18 | * For instance, the Japanese character that translates into the English word,`'example'` is `'例'`. The Internationalized Domain Name, `'例.com'` (equivalent 19 | * to `'example.com'`) is represented by Punycode as the ASCII string`'xn--fsq.com'`. 20 | * 21 | * The `punycode` module provides a simple implementation of the Punycode standard. 22 | * 23 | * The `punycode` module is a third-party dependency used by Node.js and 24 | * made available to developers as a convenience. Fixes or other modifications to 25 | * the module must be directed to the [Punycode.js](https://github.com/bestiejs/punycode.js) project. 26 | * @deprecated Since v7.0.0 - Deprecated 27 | * @see [source](https://github.com/nodejs/node/blob/v20.2.0/lib/punycode.js) 28 | */ 29 | declare module 'punycode' { 30 | /** 31 | * The `punycode.decode()` method converts a [Punycode](https://tools.ietf.org/html/rfc3492) string of ASCII-only 32 | * characters to the equivalent string of Unicode codepoints. 33 | * 34 | * ```js 35 | * punycode.decode('maana-pta'); // 'mañana' 36 | * punycode.decode('--dqo34k'); // '☃-⌘' 37 | * ``` 38 | * @since v0.5.1 39 | */ 40 | function decode(string: string): string; 41 | /** 42 | * The `punycode.encode()` method converts a string of Unicode codepoints to a [Punycode](https://tools.ietf.org/html/rfc3492) string of ASCII-only characters. 43 | * 44 | * ```js 45 | * punycode.encode('mañana'); // 'maana-pta' 46 | * punycode.encode('☃-⌘'); // '--dqo34k' 47 | * ``` 48 | * @since v0.5.1 49 | */ 50 | function encode(string: string): string; 51 | /** 52 | * The `punycode.toUnicode()` method converts a string representing a domain name 53 | * containing [Punycode](https://tools.ietf.org/html/rfc3492) encoded characters into Unicode. Only the [Punycode](https://tools.ietf.org/html/rfc3492) encoded parts of the domain name are be 54 | * converted. 55 | * 56 | * ```js 57 | * // decode domain names 58 | * punycode.toUnicode('xn--maana-pta.com'); // 'mañana.com' 59 | * punycode.toUnicode('xn----dqo34k.com'); // '☃-⌘.com' 60 | * punycode.toUnicode('example.com'); // 'example.com' 61 | * ``` 62 | * @since v0.6.1 63 | */ 64 | function toUnicode(domain: string): string; 65 | /** 66 | * The `punycode.toASCII()` method converts a Unicode string representing an 67 | * Internationalized Domain Name to [Punycode](https://tools.ietf.org/html/rfc3492). Only the non-ASCII parts of the 68 | * domain name will be converted. Calling `punycode.toASCII()` on a string that 69 | * already only contains ASCII characters will have no effect. 70 | * 71 | * ```js 72 | * // encode domain names 73 | * punycode.toASCII('mañana.com'); // 'xn--maana-pta.com' 74 | * punycode.toASCII('☃-⌘.com'); // 'xn----dqo34k.com' 75 | * punycode.toASCII('example.com'); // 'example.com' 76 | * ``` 77 | * @since v0.6.1 78 | */ 79 | function toASCII(domain: string): string; 80 | /** 81 | * @deprecated since v7.0.0 82 | * The version of the punycode module bundled in Node.js is being deprecated. 83 | * In a future major version of Node.js this module will be removed. 84 | * Users currently depending on the punycode module should switch to using 85 | * the userland-provided Punycode.js module instead. 86 | */ 87 | const ucs2: ucs2; 88 | interface ucs2 { 89 | /** 90 | * @deprecated since v7.0.0 91 | * The version of the punycode module bundled in Node.js is being deprecated. 92 | * In a future major version of Node.js this module will be removed. 93 | * Users currently depending on the punycode module should switch to using 94 | * the userland-provided Punycode.js module instead. 95 | */ 96 | decode(string: string): number[]; 97 | /** 98 | * @deprecated since v7.0.0 99 | * The version of the punycode module bundled in Node.js is being deprecated. 100 | * In a future major version of Node.js this module will be removed. 101 | * Users currently depending on the punycode module should switch to using 102 | * the userland-provided Punycode.js module instead. 103 | */ 104 | encode(codePoints: ReadonlyArray): string; 105 | } 106 | /** 107 | * @deprecated since v7.0.0 108 | * The version of the punycode module bundled in Node.js is being deprecated. 109 | * In a future major version of Node.js this module will be removed. 110 | * Users currently depending on the punycode module should switch to using 111 | * the userland-provided Punycode.js module instead. 112 | */ 113 | const version: string; 114 | } 115 | declare module 'node:punycode' { 116 | export * from 'punycode'; 117 | } 118 | -------------------------------------------------------------------------------- /thursday/class5-online/node_modules/@types/node/dom-events.d.ts: -------------------------------------------------------------------------------- 1 | export {}; // Don't export anything! 2 | 3 | //// DOM-like Events 4 | // NB: The Event / EventTarget / EventListener implementations below were copied 5 | // from lib.dom.d.ts, then edited to reflect Node's documentation at 6 | // https://nodejs.org/api/events.html#class-eventtarget. 7 | // Please read that link to understand important implementation differences. 8 | 9 | // This conditional type will be the existing global Event in a browser, or 10 | // the copy below in a Node environment. 11 | type __Event = typeof globalThis extends { onmessage: any, Event: any } 12 | ? {} 13 | : { 14 | /** This is not used in Node.js and is provided purely for completeness. */ 15 | readonly bubbles: boolean; 16 | /** Alias for event.stopPropagation(). This is not used in Node.js and is provided purely for completeness. */ 17 | cancelBubble: () => void; 18 | /** True if the event was created with the cancelable option */ 19 | readonly cancelable: boolean; 20 | /** This is not used in Node.js and is provided purely for completeness. */ 21 | readonly composed: boolean; 22 | /** Returns an array containing the current EventTarget as the only entry or empty if the event is not being dispatched. This is not used in Node.js and is provided purely for completeness. */ 23 | composedPath(): [EventTarget?] 24 | /** Alias for event.target. */ 25 | readonly currentTarget: EventTarget | null; 26 | /** Is true if cancelable is true and event.preventDefault() has been called. */ 27 | readonly defaultPrevented: boolean; 28 | /** This is not used in Node.js and is provided purely for completeness. */ 29 | readonly eventPhase: 0 | 2; 30 | /** The `AbortSignal` "abort" event is emitted with `isTrusted` set to `true`. The value is `false` in all other cases. */ 31 | readonly isTrusted: boolean; 32 | /** Sets the `defaultPrevented` property to `true` if `cancelable` is `true`. */ 33 | preventDefault(): void; 34 | /** This is not used in Node.js and is provided purely for completeness. */ 35 | returnValue: boolean; 36 | /** Alias for event.target. */ 37 | readonly srcElement: EventTarget | null; 38 | /** Stops the invocation of event listeners after the current one completes. */ 39 | stopImmediatePropagation(): void; 40 | /** This is not used in Node.js and is provided purely for completeness. */ 41 | stopPropagation(): void; 42 | /** The `EventTarget` dispatching the event */ 43 | readonly target: EventTarget | null; 44 | /** The millisecond timestamp when the Event object was created. */ 45 | readonly timeStamp: number; 46 | /** Returns the type of event, e.g. "click", "hashchange", or "submit". */ 47 | readonly type: string; 48 | }; 49 | 50 | // See comment above explaining conditional type 51 | type __EventTarget = typeof globalThis extends { onmessage: any, EventTarget: any } 52 | ? {} 53 | : { 54 | /** 55 | * Adds a new handler for the `type` event. Any given `listener` is added only once per `type` and per `capture` option value. 56 | * 57 | * If the `once` option is true, the `listener` is removed after the next time a `type` event is dispatched. 58 | * 59 | * The `capture` option is not used by Node.js in any functional way other than tracking registered event listeners per the `EventTarget` specification. 60 | * Specifically, the `capture` option is used as part of the key when registering a `listener`. 61 | * Any individual `listener` may be added once with `capture = false`, and once with `capture = true`. 62 | */ 63 | addEventListener( 64 | type: string, 65 | listener: EventListener | EventListenerObject, 66 | options?: AddEventListenerOptions | boolean, 67 | ): void; 68 | /** Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise. */ 69 | dispatchEvent(event: Event): boolean; 70 | /** Removes the event listener in target's event listener list with the same type, callback, and options. */ 71 | removeEventListener( 72 | type: string, 73 | listener: EventListener | EventListenerObject, 74 | options?: EventListenerOptions | boolean, 75 | ): void; 76 | }; 77 | 78 | interface EventInit { 79 | bubbles?: boolean; 80 | cancelable?: boolean; 81 | composed?: boolean; 82 | } 83 | 84 | interface EventListenerOptions { 85 | /** Not directly used by Node.js. Added for API completeness. Default: `false`. */ 86 | capture?: boolean; 87 | } 88 | 89 | interface AddEventListenerOptions extends EventListenerOptions { 90 | /** When `true`, the listener is automatically removed when it is first invoked. Default: `false`. */ 91 | once?: boolean; 92 | /** When `true`, serves as a hint that the listener will not call the `Event` object's `preventDefault()` method. Default: false. */ 93 | passive?: boolean; 94 | } 95 | 96 | interface EventListener { 97 | (evt: Event): void; 98 | } 99 | 100 | interface EventListenerObject { 101 | handleEvent(object: Event): void; 102 | } 103 | 104 | import {} from 'events'; // Make this an ambient declaration 105 | declare global { 106 | /** An event which takes place in the DOM. */ 107 | interface Event extends __Event {} 108 | var Event: typeof globalThis extends { onmessage: any, Event: infer T } 109 | ? T 110 | : { 111 | prototype: __Event; 112 | new (type: string, eventInitDict?: EventInit): __Event; 113 | }; 114 | 115 | /** 116 | * EventTarget is a DOM interface implemented by objects that can 117 | * receive events and may have listeners for them. 118 | */ 119 | interface EventTarget extends __EventTarget {} 120 | var EventTarget: typeof globalThis extends { onmessage: any, EventTarget: infer T } 121 | ? T 122 | : { 123 | prototype: __EventTarget; 124 | new (): __EventTarget; 125 | }; 126 | } 127 | -------------------------------------------------------------------------------- /wednesday/class5-online/node_modules/@types/node/dom-events.d.ts: -------------------------------------------------------------------------------- 1 | export {}; // Don't export anything! 2 | 3 | //// DOM-like Events 4 | // NB: The Event / EventTarget / EventListener implementations below were copied 5 | // from lib.dom.d.ts, then edited to reflect Node's documentation at 6 | // https://nodejs.org/api/events.html#class-eventtarget. 7 | // Please read that link to understand important implementation differences. 8 | 9 | // This conditional type will be the existing global Event in a browser, or 10 | // the copy below in a Node environment. 11 | type __Event = typeof globalThis extends { onmessage: any, Event: any } 12 | ? {} 13 | : { 14 | /** This is not used in Node.js and is provided purely for completeness. */ 15 | readonly bubbles: boolean; 16 | /** Alias for event.stopPropagation(). This is not used in Node.js and is provided purely for completeness. */ 17 | cancelBubble: () => void; 18 | /** True if the event was created with the cancelable option */ 19 | readonly cancelable: boolean; 20 | /** This is not used in Node.js and is provided purely for completeness. */ 21 | readonly composed: boolean; 22 | /** Returns an array containing the current EventTarget as the only entry or empty if the event is not being dispatched. This is not used in Node.js and is provided purely for completeness. */ 23 | composedPath(): [EventTarget?] 24 | /** Alias for event.target. */ 25 | readonly currentTarget: EventTarget | null; 26 | /** Is true if cancelable is true and event.preventDefault() has been called. */ 27 | readonly defaultPrevented: boolean; 28 | /** This is not used in Node.js and is provided purely for completeness. */ 29 | readonly eventPhase: 0 | 2; 30 | /** The `AbortSignal` "abort" event is emitted with `isTrusted` set to `true`. The value is `false` in all other cases. */ 31 | readonly isTrusted: boolean; 32 | /** Sets the `defaultPrevented` property to `true` if `cancelable` is `true`. */ 33 | preventDefault(): void; 34 | /** This is not used in Node.js and is provided purely for completeness. */ 35 | returnValue: boolean; 36 | /** Alias for event.target. */ 37 | readonly srcElement: EventTarget | null; 38 | /** Stops the invocation of event listeners after the current one completes. */ 39 | stopImmediatePropagation(): void; 40 | /** This is not used in Node.js and is provided purely for completeness. */ 41 | stopPropagation(): void; 42 | /** The `EventTarget` dispatching the event */ 43 | readonly target: EventTarget | null; 44 | /** The millisecond timestamp when the Event object was created. */ 45 | readonly timeStamp: number; 46 | /** Returns the type of event, e.g. "click", "hashchange", or "submit". */ 47 | readonly type: string; 48 | }; 49 | 50 | // See comment above explaining conditional type 51 | type __EventTarget = typeof globalThis extends { onmessage: any, EventTarget: any } 52 | ? {} 53 | : { 54 | /** 55 | * Adds a new handler for the `type` event. Any given `listener` is added only once per `type` and per `capture` option value. 56 | * 57 | * If the `once` option is true, the `listener` is removed after the next time a `type` event is dispatched. 58 | * 59 | * The `capture` option is not used by Node.js in any functional way other than tracking registered event listeners per the `EventTarget` specification. 60 | * Specifically, the `capture` option is used as part of the key when registering a `listener`. 61 | * Any individual `listener` may be added once with `capture = false`, and once with `capture = true`. 62 | */ 63 | addEventListener( 64 | type: string, 65 | listener: EventListener | EventListenerObject, 66 | options?: AddEventListenerOptions | boolean, 67 | ): void; 68 | /** Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise. */ 69 | dispatchEvent(event: Event): boolean; 70 | /** Removes the event listener in target's event listener list with the same type, callback, and options. */ 71 | removeEventListener( 72 | type: string, 73 | listener: EventListener | EventListenerObject, 74 | options?: EventListenerOptions | boolean, 75 | ): void; 76 | }; 77 | 78 | interface EventInit { 79 | bubbles?: boolean; 80 | cancelable?: boolean; 81 | composed?: boolean; 82 | } 83 | 84 | interface EventListenerOptions { 85 | /** Not directly used by Node.js. Added for API completeness. Default: `false`. */ 86 | capture?: boolean; 87 | } 88 | 89 | interface AddEventListenerOptions extends EventListenerOptions { 90 | /** When `true`, the listener is automatically removed when it is first invoked. Default: `false`. */ 91 | once?: boolean; 92 | /** When `true`, serves as a hint that the listener will not call the `Event` object's `preventDefault()` method. Default: false. */ 93 | passive?: boolean; 94 | } 95 | 96 | interface EventListener { 97 | (evt: Event): void; 98 | } 99 | 100 | interface EventListenerObject { 101 | handleEvent(object: Event): void; 102 | } 103 | 104 | import {} from 'events'; // Make this an ambient declaration 105 | declare global { 106 | /** An event which takes place in the DOM. */ 107 | interface Event extends __Event {} 108 | var Event: typeof globalThis extends { onmessage: any, Event: infer T } 109 | ? T 110 | : { 111 | prototype: __Event; 112 | new (type: string, eventInitDict?: EventInit): __Event; 113 | }; 114 | 115 | /** 116 | * EventTarget is a DOM interface implemented by objects that can 117 | * receive events and may have listeners for them. 118 | */ 119 | interface EventTarget extends __EventTarget {} 120 | var EventTarget: typeof globalThis extends { onmessage: any, EventTarget: infer T } 121 | ? T 122 | : { 123 | prototype: __EventTarget; 124 | new (): __EventTarget; 125 | }; 126 | } 127 | -------------------------------------------------------------------------------- /thursday/class5-online/node_modules/@types/node/ts4.8/dom-events.d.ts: -------------------------------------------------------------------------------- 1 | export {}; // Don't export anything! 2 | 3 | //// DOM-like Events 4 | // NB: The Event / EventTarget / EventListener implementations below were copied 5 | // from lib.dom.d.ts, then edited to reflect Node's documentation at 6 | // https://nodejs.org/api/events.html#class-eventtarget. 7 | // Please read that link to understand important implementation differences. 8 | 9 | // This conditional type will be the existing global Event in a browser, or 10 | // the copy below in a Node environment. 11 | type __Event = typeof globalThis extends { onmessage: any, Event: any } 12 | ? {} 13 | : { 14 | /** This is not used in Node.js and is provided purely for completeness. */ 15 | readonly bubbles: boolean; 16 | /** Alias for event.stopPropagation(). This is not used in Node.js and is provided purely for completeness. */ 17 | cancelBubble: () => void; 18 | /** True if the event was created with the cancelable option */ 19 | readonly cancelable: boolean; 20 | /** This is not used in Node.js and is provided purely for completeness. */ 21 | readonly composed: boolean; 22 | /** Returns an array containing the current EventTarget as the only entry or empty if the event is not being dispatched. This is not used in Node.js and is provided purely for completeness. */ 23 | composedPath(): [EventTarget?] 24 | /** Alias for event.target. */ 25 | readonly currentTarget: EventTarget | null; 26 | /** Is true if cancelable is true and event.preventDefault() has been called. */ 27 | readonly defaultPrevented: boolean; 28 | /** This is not used in Node.js and is provided purely for completeness. */ 29 | readonly eventPhase: 0 | 2; 30 | /** The `AbortSignal` "abort" event is emitted with `isTrusted` set to `true`. The value is `false` in all other cases. */ 31 | readonly isTrusted: boolean; 32 | /** Sets the `defaultPrevented` property to `true` if `cancelable` is `true`. */ 33 | preventDefault(): void; 34 | /** This is not used in Node.js and is provided purely for completeness. */ 35 | returnValue: boolean; 36 | /** Alias for event.target. */ 37 | readonly srcElement: EventTarget | null; 38 | /** Stops the invocation of event listeners after the current one completes. */ 39 | stopImmediatePropagation(): void; 40 | /** This is not used in Node.js and is provided purely for completeness. */ 41 | stopPropagation(): void; 42 | /** The `EventTarget` dispatching the event */ 43 | readonly target: EventTarget | null; 44 | /** The millisecond timestamp when the Event object was created. */ 45 | readonly timeStamp: number; 46 | /** Returns the type of event, e.g. "click", "hashchange", or "submit". */ 47 | readonly type: string; 48 | }; 49 | 50 | // See comment above explaining conditional type 51 | type __EventTarget = typeof globalThis extends { onmessage: any, EventTarget: any } 52 | ? {} 53 | : { 54 | /** 55 | * Adds a new handler for the `type` event. Any given `listener` is added only once per `type` and per `capture` option value. 56 | * 57 | * If the `once` option is true, the `listener` is removed after the next time a `type` event is dispatched. 58 | * 59 | * The `capture` option is not used by Node.js in any functional way other than tracking registered event listeners per the `EventTarget` specification. 60 | * Specifically, the `capture` option is used as part of the key when registering a `listener`. 61 | * Any individual `listener` may be added once with `capture = false`, and once with `capture = true`. 62 | */ 63 | addEventListener( 64 | type: string, 65 | listener: EventListener | EventListenerObject, 66 | options?: AddEventListenerOptions | boolean, 67 | ): void; 68 | /** Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise. */ 69 | dispatchEvent(event: Event): boolean; 70 | /** Removes the event listener in target's event listener list with the same type, callback, and options. */ 71 | removeEventListener( 72 | type: string, 73 | listener: EventListener | EventListenerObject, 74 | options?: EventListenerOptions | boolean, 75 | ): void; 76 | }; 77 | 78 | interface EventInit { 79 | bubbles?: boolean; 80 | cancelable?: boolean; 81 | composed?: boolean; 82 | } 83 | 84 | interface EventListenerOptions { 85 | /** Not directly used by Node.js. Added for API completeness. Default: `false`. */ 86 | capture?: boolean; 87 | } 88 | 89 | interface AddEventListenerOptions extends EventListenerOptions { 90 | /** When `true`, the listener is automatically removed when it is first invoked. Default: `false`. */ 91 | once?: boolean; 92 | /** When `true`, serves as a hint that the listener will not call the `Event` object's `preventDefault()` method. Default: false. */ 93 | passive?: boolean; 94 | } 95 | 96 | interface EventListener { 97 | (evt: Event): void; 98 | } 99 | 100 | interface EventListenerObject { 101 | handleEvent(object: Event): void; 102 | } 103 | 104 | import {} from 'events'; // Make this an ambient declaration 105 | declare global { 106 | /** An event which takes place in the DOM. */ 107 | interface Event extends __Event {} 108 | var Event: typeof globalThis extends { onmessage: any, Event: infer T } 109 | ? T 110 | : { 111 | prototype: __Event; 112 | new (type: string, eventInitDict?: EventInit): __Event; 113 | }; 114 | 115 | /** 116 | * EventTarget is a DOM interface implemented by objects that can 117 | * receive events and may have listeners for them. 118 | */ 119 | interface EventTarget extends __EventTarget {} 120 | var EventTarget: typeof globalThis extends { onmessage: any, EventTarget: infer T } 121 | ? T 122 | : { 123 | prototype: __EventTarget; 124 | new (): __EventTarget; 125 | }; 126 | } 127 | -------------------------------------------------------------------------------- /wednesday/class5-online/node_modules/@types/node/ts4.8/dom-events.d.ts: -------------------------------------------------------------------------------- 1 | export {}; // Don't export anything! 2 | 3 | //// DOM-like Events 4 | // NB: The Event / EventTarget / EventListener implementations below were copied 5 | // from lib.dom.d.ts, then edited to reflect Node's documentation at 6 | // https://nodejs.org/api/events.html#class-eventtarget. 7 | // Please read that link to understand important implementation differences. 8 | 9 | // This conditional type will be the existing global Event in a browser, or 10 | // the copy below in a Node environment. 11 | type __Event = typeof globalThis extends { onmessage: any, Event: any } 12 | ? {} 13 | : { 14 | /** This is not used in Node.js and is provided purely for completeness. */ 15 | readonly bubbles: boolean; 16 | /** Alias for event.stopPropagation(). This is not used in Node.js and is provided purely for completeness. */ 17 | cancelBubble: () => void; 18 | /** True if the event was created with the cancelable option */ 19 | readonly cancelable: boolean; 20 | /** This is not used in Node.js and is provided purely for completeness. */ 21 | readonly composed: boolean; 22 | /** Returns an array containing the current EventTarget as the only entry or empty if the event is not being dispatched. This is not used in Node.js and is provided purely for completeness. */ 23 | composedPath(): [EventTarget?] 24 | /** Alias for event.target. */ 25 | readonly currentTarget: EventTarget | null; 26 | /** Is true if cancelable is true and event.preventDefault() has been called. */ 27 | readonly defaultPrevented: boolean; 28 | /** This is not used in Node.js and is provided purely for completeness. */ 29 | readonly eventPhase: 0 | 2; 30 | /** The `AbortSignal` "abort" event is emitted with `isTrusted` set to `true`. The value is `false` in all other cases. */ 31 | readonly isTrusted: boolean; 32 | /** Sets the `defaultPrevented` property to `true` if `cancelable` is `true`. */ 33 | preventDefault(): void; 34 | /** This is not used in Node.js and is provided purely for completeness. */ 35 | returnValue: boolean; 36 | /** Alias for event.target. */ 37 | readonly srcElement: EventTarget | null; 38 | /** Stops the invocation of event listeners after the current one completes. */ 39 | stopImmediatePropagation(): void; 40 | /** This is not used in Node.js and is provided purely for completeness. */ 41 | stopPropagation(): void; 42 | /** The `EventTarget` dispatching the event */ 43 | readonly target: EventTarget | null; 44 | /** The millisecond timestamp when the Event object was created. */ 45 | readonly timeStamp: number; 46 | /** Returns the type of event, e.g. "click", "hashchange", or "submit". */ 47 | readonly type: string; 48 | }; 49 | 50 | // See comment above explaining conditional type 51 | type __EventTarget = typeof globalThis extends { onmessage: any, EventTarget: any } 52 | ? {} 53 | : { 54 | /** 55 | * Adds a new handler for the `type` event. Any given `listener` is added only once per `type` and per `capture` option value. 56 | * 57 | * If the `once` option is true, the `listener` is removed after the next time a `type` event is dispatched. 58 | * 59 | * The `capture` option is not used by Node.js in any functional way other than tracking registered event listeners per the `EventTarget` specification. 60 | * Specifically, the `capture` option is used as part of the key when registering a `listener`. 61 | * Any individual `listener` may be added once with `capture = false`, and once with `capture = true`. 62 | */ 63 | addEventListener( 64 | type: string, 65 | listener: EventListener | EventListenerObject, 66 | options?: AddEventListenerOptions | boolean, 67 | ): void; 68 | /** Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise. */ 69 | dispatchEvent(event: Event): boolean; 70 | /** Removes the event listener in target's event listener list with the same type, callback, and options. */ 71 | removeEventListener( 72 | type: string, 73 | listener: EventListener | EventListenerObject, 74 | options?: EventListenerOptions | boolean, 75 | ): void; 76 | }; 77 | 78 | interface EventInit { 79 | bubbles?: boolean; 80 | cancelable?: boolean; 81 | composed?: boolean; 82 | } 83 | 84 | interface EventListenerOptions { 85 | /** Not directly used by Node.js. Added for API completeness. Default: `false`. */ 86 | capture?: boolean; 87 | } 88 | 89 | interface AddEventListenerOptions extends EventListenerOptions { 90 | /** When `true`, the listener is automatically removed when it is first invoked. Default: `false`. */ 91 | once?: boolean; 92 | /** When `true`, serves as a hint that the listener will not call the `Event` object's `preventDefault()` method. Default: false. */ 93 | passive?: boolean; 94 | } 95 | 96 | interface EventListener { 97 | (evt: Event): void; 98 | } 99 | 100 | interface EventListenerObject { 101 | handleEvent(object: Event): void; 102 | } 103 | 104 | import {} from 'events'; // Make this an ambient declaration 105 | declare global { 106 | /** An event which takes place in the DOM. */ 107 | interface Event extends __Event {} 108 | var Event: typeof globalThis extends { onmessage: any, Event: infer T } 109 | ? T 110 | : { 111 | prototype: __Event; 112 | new (type: string, eventInitDict?: EventInit): __Event; 113 | }; 114 | 115 | /** 116 | * EventTarget is a DOM interface implemented by objects that can 117 | * receive events and may have listeners for them. 118 | */ 119 | interface EventTarget extends __EventTarget {} 120 | var EventTarget: typeof globalThis extends { onmessage: any, EventTarget: infer T } 121 | ? T 122 | : { 123 | prototype: __EventTarget; 124 | new (): __EventTarget; 125 | }; 126 | } 127 | -------------------------------------------------------------------------------- /thursday/class5-online/node_modules/@types/node/readline/promises.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @since v17.0.0 3 | * @experimental 4 | */ 5 | declare module 'readline/promises' { 6 | import { Interface as _Interface, ReadLineOptions, Completer, AsyncCompleter, Direction } from 'node:readline'; 7 | import { Abortable } from 'node:events'; 8 | /** 9 | * Instances of the `readlinePromises.Interface` class are constructed using the`readlinePromises.createInterface()` method. Every instance is associated with a 10 | * single `input` `Readable` stream and a single `output` `Writable` stream. 11 | * The `output` stream is used to print prompts for user input that arrives on, 12 | * and is read from, the `input` stream. 13 | * @since v17.0.0 14 | */ 15 | class Interface extends _Interface { 16 | /** 17 | * The `rl.question()` method displays the `query` by writing it to the `output`, 18 | * waits for user input to be provided on `input`, then invokes the `callback`function passing the provided input as the first argument. 19 | * 20 | * When called, `rl.question()` will resume the `input` stream if it has been 21 | * paused. 22 | * 23 | * If the `Interface` was created with `output` set to `null` or`undefined` the `query` is not written. 24 | * 25 | * If the question is called after `rl.close()`, it returns a rejected promise. 26 | * 27 | * Example usage: 28 | * 29 | * ```js 30 | * const answer = await rl.question('What is your favorite food? '); 31 | * console.log(`Oh, so your favorite food is ${answer}`); 32 | * ``` 33 | * 34 | * Using an `AbortSignal` to cancel a question. 35 | * 36 | * ```js 37 | * const signal = AbortSignal.timeout(10_000); 38 | * 39 | * signal.addEventListener('abort', () => { 40 | * console.log('The food question timed out'); 41 | * }, { once: true }); 42 | * 43 | * const answer = await rl.question('What is your favorite food? ', { signal }); 44 | * console.log(`Oh, so your favorite food is ${answer}`); 45 | * ``` 46 | * @since v17.0.0 47 | * @param query A statement or query to write to `output`, prepended to the prompt. 48 | * @return A promise that is fulfilled with the user's input in response to the `query`. 49 | */ 50 | question(query: string): Promise; 51 | question(query: string, options: Abortable): Promise; 52 | } 53 | /** 54 | * @since v17.0.0 55 | */ 56 | class Readline { 57 | /** 58 | * @param stream A TTY stream. 59 | */ 60 | constructor( 61 | stream: NodeJS.WritableStream, 62 | options?: { 63 | autoCommit?: boolean; 64 | } 65 | ); 66 | /** 67 | * The `rl.clearLine()` method adds to the internal list of pending action an 68 | * action that clears current line of the associated `stream` in a specified 69 | * direction identified by `dir`. 70 | * Call `rl.commit()` to see the effect of this method, unless `autoCommit: true`was passed to the constructor. 71 | * @since v17.0.0 72 | * @return this 73 | */ 74 | clearLine(dir: Direction): this; 75 | /** 76 | * The `rl.clearScreenDown()` method adds to the internal list of pending action an 77 | * action that clears the associated stream from the current position of the 78 | * cursor down. 79 | * Call `rl.commit()` to see the effect of this method, unless `autoCommit: true`was passed to the constructor. 80 | * @since v17.0.0 81 | * @return this 82 | */ 83 | clearScreenDown(): this; 84 | /** 85 | * The `rl.commit()` method sends all the pending actions to the associated`stream` and clears the internal list of pending actions. 86 | * @since v17.0.0 87 | */ 88 | commit(): Promise; 89 | /** 90 | * The `rl.cursorTo()` method adds to the internal list of pending action an action 91 | * that moves cursor to the specified position in the associated `stream`. 92 | * Call `rl.commit()` to see the effect of this method, unless `autoCommit: true`was passed to the constructor. 93 | * @since v17.0.0 94 | * @return this 95 | */ 96 | cursorTo(x: number, y?: number): this; 97 | /** 98 | * The `rl.moveCursor()` method adds to the internal list of pending action an 99 | * action that moves the cursor _relative_ to its current position in the 100 | * associated `stream`. 101 | * Call `rl.commit()` to see the effect of this method, unless `autoCommit: true`was passed to the constructor. 102 | * @since v17.0.0 103 | * @return this 104 | */ 105 | moveCursor(dx: number, dy: number): this; 106 | /** 107 | * The `rl.rollback` methods clears the internal list of pending actions without 108 | * sending it to the associated `stream`. 109 | * @since v17.0.0 110 | * @return this 111 | */ 112 | rollback(): this; 113 | } 114 | /** 115 | * The `readlinePromises.createInterface()` method creates a new `readlinePromises.Interface`instance. 116 | * 117 | * ```js 118 | * const readlinePromises = require('node:readline/promises'); 119 | * const rl = readlinePromises.createInterface({ 120 | * input: process.stdin, 121 | * output: process.stdout, 122 | * }); 123 | * ``` 124 | * 125 | * Once the `readlinePromises.Interface` instance is created, the most common case 126 | * is to listen for the `'line'` event: 127 | * 128 | * ```js 129 | * rl.on('line', (line) => { 130 | * console.log(`Received: ${line}`); 131 | * }); 132 | * ``` 133 | * 134 | * If `terminal` is `true` for this instance then the `output` stream will get 135 | * the best compatibility if it defines an `output.columns` property and emits 136 | * a `'resize'` event on the `output` if or when the columns ever change 137 | * (`process.stdout` does this automatically when it is a TTY). 138 | * @since v17.0.0 139 | */ 140 | function createInterface(input: NodeJS.ReadableStream, output?: NodeJS.WritableStream, completer?: Completer | AsyncCompleter, terminal?: boolean): Interface; 141 | function createInterface(options: ReadLineOptions): Interface; 142 | } 143 | declare module 'node:readline/promises' { 144 | export * from 'readline/promises'; 145 | } 146 | --------------------------------------------------------------------------------