diff --git a/.eslintrc.cjs b/.eslintrc.js similarity index 100% rename from .eslintrc.cjs rename to .eslintrc.js index 640a514..a485170 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.js @@ -2,12 +2,12 @@ module.exports = { root: true, plugins: ["@typescript-eslint", "import", "prettier"], extends: [ + "airbnb-typescript/base", + "prettier", "plugin:@typescript-eslint/recommended", "plugin:@typescript-eslint/stylistic", "plugin:import/typescript", - "airbnb-typescript/base", "eslint:recommended", - "prettier", ], parser: "@typescript-eslint/parser", parserOptions: { diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 261eeb9..0000000 --- a/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/Notes/EventLoop.png b/Notes/EventLoop.png deleted file mode 100644 index 3a8e0c8..0000000 Binary files a/Notes/EventLoop.png and /dev/null differ diff --git a/Notes/JavaScript_CheatSheet.md b/Notes/JavaScript_CheatSheet.md deleted file mode 100644 index faee908..0000000 --- a/Notes/JavaScript_CheatSheet.md +++ /dev/null @@ -1,3067 +0,0 @@ - - -- [JavaScript](#javascript) - - [How JavaScript works](#how-javascript-works) - - [Execution Context : Component where JS is executed. It has](#execution-context--component-where-js-is-executed-it-has) - - [Memory or variable Env -](#memory-or-variable-env--) - - [Code Env or Thread of Execution -](#code-env-or-thread-of-execution--) - - [Variables](#variables) - - [Things to Keep in mind when naming a variable](#things-to-keep-in-mind-when-naming-a-variable) - - [JavaScript datatype](#javascript-datatype) - - [Use proper variable names](#use-proper-variable-names) - - [variable scope->Understanding](#variable-scope-understanding) - - [Data Conversion](#data-conversion) - - [Data Types](#data-types) - - [Conversion Operator](#conversion-operator) - - [Comparision](#comparision) - - [String](#string) - - [Num and Math](#num-and-math) - - [Date](#date) - - [Data Type Summary](#data-type-summary) - - [Array](#array) - - [Array Methods](#array-methods) - - [push](#push) - - [pop()](#pop) - - [unshift](#unshift) - - [shift](#shift) - - [includes](#includes) - - [indexOf](#indexof) - - [sort](#sort-) - - [toString](#tostring) - - [join](#join) - - [slice](#slice-) - - [splice](#splice) - - [push and concat example](#push-and-concat-example) - - [How to flat an array](#how-to-flat-an-array) - - [How to check if array](#how-to-check-if-array) - - [Converts String to array](#converts-string-to-array) - - [Converts variables to array](#converts-variables-to-array) - - [Objects](#objects) - - [Functions](#functions) - - [Arrow function](#arrow-function) - - [JS Execution](#js-execution) - - [Control Flow](#control-flow) - - [if](#if) - - [Multiple ways to write if conditions](#multiple-ways-to-write-if-conditions) - - [switch](#switch) - - [Truthy](#truthy) - - [Loops in JavaScript](#loops-in-javascript) - - [Different types of Loops supported in JavaScript](#different-types-of-loops-supported-in-javascript) - - [Using For Loop](#using-for-loop) - - [Output:](#output) - - [Using ForEach](#using-foreach) - - [Output:](#output-1) - - [Using ForOff](#using-foroff) - - [Output:](#output-2) - - [Using while loop](#using-while-loop) - - [Output:](#output-3) - - [Using Do while loop](#using-do-while-loop) - - [Output:](#output-4) - - [Using Map](#using-map) - - [Output:](#output-5) - - [What is console.log](#what-is-consolelog) - - [JavaScript Good Practice](#javascript-good-practice) - - [What is block scope and functional scope](#what-is-block-scope-and-functional-scope) - - [Why should not use `var`](#why-should-not-use-var) - - [What is undefined in JavaScript](#what-is-undefined-in-javascript) - - [set](#set) - - [null](#null) - - [map](#map) - - [filter](#filter) - - [loops](#loops) - - [String](#string-1) - - [BigInt](#bigint) - - [Object](#object) - - [Reflect](#reflect) - - [scopes](#scopes) - - [Symbol](#symbol) - - [Boolean](#boolean) - - [currying](#currying) - - [closures](#closures) - - [promise](#promise) - - [A Promise is in one of these states:](#a-promise-is-in-one-of-these-states) - - [API Request](#api-request) - - [call stack](#call-stack) - - [web APIs](#web-apis) - - [undefined](#undefined) - - [deep copy](#deep-copy) - - [data types](#data-types-1) - - [event loop](#event-loop) - - [JavaScript is a](#javascript-is-a) - - [Execution Context](#execution-context) - - [Blocking Code](#blocking-code) - - [Non Blocking Code](#non-blocking-code) - - [statements](#statements) - - [asynchrony](#asynchrony) - - [async - await](#async---await) - - [conditionals](#conditionals) - - [map method](#map-method) - - [shallow copy](#shallow-copy) - - [destructuring](#destructuring) - - [Object Destructuring](#object-destructuring) - - [Array Destructuring](#array-destructuring) - - [Rest Operator](#rest-operator) - - [Spread Operator](#spread-operator) - - [pure function](#pure-function) - - [lexical scoping](#lexical-scoping) - - [arrow function](#arrow-function-1) - - [Check weather passed String is numeric or not](#check-weather-passed-string-is-numeric-or-not) - - [string methods](#string-methods) - - [named imports](#named-imports) - - [default imports](#default-imports) - - [reduce method](#reduce-method) - - [handling events or event listener and event bubbling and event capturing](#handling-events-or-event-listener-and-event-bubbling-and-event-capturing) - - [setTimeout and setInterval](#settimeout-and-setinterval) - - [forEach method](#foreach-method) - - [template literals](#template-literals) - - [normal functions](#normal-functions) - - [spread operators](#spread-operators) - - [promise chaining](#promise-chaining) - - [optional chaining](#optional-chaining) - - [conditional operator](#conditional-operator) - - [function expressions](#function-expressions) - - [Random Number](#random-number) - - [Math.random()](#mathrandom) - - [Enum](#enum) - - [nodemailer](#nodemailer) - - [Send email through outlook using nodemailer](#send-email-through-outlook-using-nodemailer) - - [Send email through gmail using nodemailer](#send-email-through-gmail-using-nodemailer) - - [Send Email From Your App Without a Backend](#send-email-from-your-app-without-a-backend) - - [Database Connection](#database-connection) - - [PostGresSQLConnection](#postgressqlconnection) - - [Install following package](#install-following-package) - - [Create a JS file like queries.js and Add following import statement](#create-a-js-file-like-queriesjs-and-add-following-import-statement) - - [Create Connection With PostGresSQL DB](#create-connection-with-postgressql-db) - - [Get Data from postgres table](#get-data-from-postgres-table) - - [Export above created function, so that you could import in other JS file](#export-above-created-function-so-that-you-could-import-in-other-js-file) - - [Using Object Literals Instead of Switch Case](#using-object-literals-instead-of-switch-case) - - [function to getMarkRange() using switch case](#function-to-getmarkrange-using-switch-case) - - [function to getMarkRange() using Object literal](#function-to-getmarkrange-using-object-literal) - - [rest syntax](#rest-syntax) - - [Array Destructuring using rest syntax](#array-destructuring-using-rest-syntax) - - [Receiving Data using rest syntax](#receiving-data-using-rest-syntax) - - [Object Destructuring using rest syntax](#object-destructuring-using-rest-syntax) - - [Spreading data](#spreading-data) - - [Spreading into a function call turns Array elements into function call arguments](#spreading-into-a-function-call-turns-array-elements-into-function-call-arguments) - - [Remote command execution via SSH using NodeJS](#remote-command-execution-via-ssh-using-nodejs) - - [Create a Unique ID](#create-a-unique-id) - - [Switch Case Statement Simplify using Object Literals](#switch-case-statement-simplify-using-object-literals) - - [We can use an "Object Lookup Map" instead of a "switch" statement for a cleaner syntax. Above switch statement re-written in Object Lookup map format.](#we-can-use-an-object-lookup-map-instead-of-a-switch-statement-for-a-cleaner-syntax-above-switch-statement-re-written-in-object-lookup-map-format) - > - [Mean ing of ^ and ~ symbols mentioned in the package.json file for the package version](#meaning-of--and--symbols-mentioned-in-the-packagejson-file-for-the-package-version) - - [How To Create Express Server](#how-to-create-express-server) - - [How To Create Server Using Express/NodeJS](#how-to-create-server-using-expressnodejs) - - [Install following package](#install-following-package-1) - - [Add following at start of file (create a JS file like index.js)](#add-following-at-start-of-file-create-a-js-file-like-indexjs) - - [Open CMD prompt](#open-cmd-prompt) - - [Fetch Data from API](#fetch-data-from-api) - - [Different ways to fetch data from API](#different-ways-to-fetch-data-from-api) - - [Create ENUM in JavaScript](#create-enum-in-javascript) - - [Array method()](#array-method) - - [Mutating Array methods](#mutating-array-methods) - - [Mutating Array Methods list](#mutating-array-methods-list) -- [Array -> Filter() method](#array---filter-method) - - [variable scope->Understanding](#variable-scope-understanding-1) - - [Array -> map() method](#array---map-method) - - [Array -> reduce() method](#array---reduce-method) - - [Array -> Remove Duplicate Values](#array---remove-duplicate-values) - - [remove duplicate Using Set](#remove-duplicate-using-set) - - [remove duplicate Using Array reduce() method](#remove-duplicate-using-array-reduce-method) - - [remove duplicate Using Array filter() method](#remove-duplicate-using-array-filter-method) - - [Remove duplicates from an array of objects by one property](#remove-duplicates-from-an-array-of-objects-by-one-property) - - [Remove duplicates from an array of objects by multiple properties](#remove-duplicates-from-an-array-of-objects-by-multiple-properties) - - [How to make arrays mutable](#how-to-make-arrays-mutable) - - [Array](#array-1) - - [JavaScript Interview Question](#javascript-interview-question) - - [What is JavaScript and what are its key features?](#what-is-javascript-and-what-are-its-key-features) - - [What is the difference between null and undefined in JavaScript?](#what-is-the-difference-between-null-and-undefined-in-javascript) - - [Explain the concept of closures in JavaScript and provide an example.](#explain-the-concept-of-closures-in-javascript-and-provide-an-example) - - [What is the difference between let, const, and var in JavaScript for declaring variables?](#what-is-the-difference-between-let-const-and-var-in-javascript-for-declaring-variables) - - [What is the Event Loop in JavaScript and how does it work?](#what-is-the-event-loop-in-javascript-and-how-does-it-work) - - [How does prototypal inheritance work in JavaScript?](#how-does-prototypal-inheritance-work-in-javascript) - - [Explain the concept of hoisting in JavaScript.](#explain-the-concept-of-hoisting-in-javascript) - - [What are arrow functions in JavaScript? How do they differ from regular functions?](#what-are-arrow-functions-in-javascript-how-do-they-differ-from-regular-functions) - - [What are Promises in JavaScript and how do they handle asynchronous operations?](#what-are-promises-in-javascript-and-how-do-they-handle-asynchronous-operations) - - [How does the this keyword work in JavaScript? Provide examples of different contexts where this can be used.](#how-does-the-this-keyword-work-in-javascript-provide-examples-of-different-contexts-where-this-can-be-used) - - [Explain the concept of event delegation in JavaScript.](#explain-the-concept-of-event-delegation-in-javascript) - - [What is the purpose of using the bind, call, and apply methods in JavaScript?](#what-is-the-purpose-of-using-the-bind-call-and-apply-methods-in-javascript) - - [What is the difference between synchronous and asynchronous JavaScript?](#what-is-the-difference-between-synchronous-and-asynchronous-javascript) - - [How to explain Event loop and async js](#how-to-explain-event-loop-and-async-js) - - [How to explain Hoisting and temporal dead zone](#how-to-explain-hoisting-and-temporal-dead-zone) - - [How to explain scope and scope chain](#how-to-explain-scope-and-scope-chain) - - [How to explain prototypal inheritance and chaining](#how-to-explain-prototypal-inheritance-and-chaining) - - [How to explain promises and queues](#how-to-explain-promises-and-queues) - - [How to explain async await in interviews](#how-to-explain-async-await-in-interviews) - - [How to answer closure and lexical scoping](#how-to-answer-closure-and-lexical-scoping) - - [How to answer THIS in interviews](#how-to-answer-this-in-interviews) - - [How to explain call bind and apply in interviews](#how-to-explain-call-bind-and-apply-in-interviews) - - [Coding Problem Using JavaScript](#coding-problem-using-javascript) - - [Reverse a String](#reverse-a-string) - - [Sum of array elements](#sum-of-array-elements) - - [Largest/Smallest number in array](#largestsmallest-number-in-array) - - [Remove duplicates from an array](#remove-duplicates-from-an-array) - - [Remove All Whitespace from a String in JavaScript](#remove-all-whitespace-from-a-string-in-javascript) - - [If you want to get the text that a user selects or highlights on a web page, there is a useful one-liner for that](#if-you-want-to-get-the-text-that-a-user-selects-or-highlights-on-a-web-page-there-is-a-useful-one-liner-for-that) - - [There is a method called scrollTo(x,y), it allows you to scroll to a particular set of used coordinates](#there-is-a-method-called-scrolltoxy-it-allows-you-to-scroll-to-a-particular-set-of-used-coordinates) - - [If you want to have a smooth scrolling animation](#if-you-want-to-have-a-smooth-scrolling-animation) - - [If you want to redirect the user to a specified location, you can do something like this](#if-you-want-to-redirect-the-user-to-a-specified-location-you-can-do-something-like-this) - - [JS Common Interview Questions](#js-common-interview-questions) - > - [Read JSON File in JavaScript](#read-json-file-in-javascript) - - [Data Structure Introduction](#data-structure-introduction) - - [map](#map-1) - - [set](#set-1) - - [Stack](#stack) - - [Queue](#queue) - - [Linked List](#linked-list) - - [Binary Trees](#binary-trees) - - [Recursion](#recursion) - - [Graph](#graph) - - [Dynamic Programming](#dynamic-programming) - - [Amortized space time complexity practice](#amortized-space-time-complexity-practice) - - [Sorting Algorithm](#sorting-algorithm) - - [Bubble sort](#bubble-sort) - - [Insertion sort](#insertion-sort) - - [Merge Sort](#merge-sort) - - [Quick Sort](#quick-sort) - - [Selection Sort](#selection-sort) - - [class and OOPs](#class-and-oops) - - [OOPs](#oops) - - [Object](#object-1) - - [Why use OOP](#why-use-oop) - - [parts of OOP](#parts-of-oop) - - [Object literal](#object-literal) - - [Prototype](#prototype) - - [4 pillars](#4-pillars) - - [DOM](#dom) - - -# JavaScript - -## How JavaScript works - -Everything in JS happens inside an Execution context. it is a synchronous single-threaded language. - -#### Execution Context : Component where JS is executed. It has - -##### Memory or variable Env - - - Here variables are stored as`key:value` pair - -##### Code Env or Thread of Execution - - - This is the place where code is executed one line at a time - -## Variables - -### Things to Keep in mind when naming a variable - -- `Names should be self descriptive with enough context so we don't have to comment out code` -- `Descriptive names are better than comments` -- `Avoid single letter names` -- `prefer explicit over implicit names` -- `Use descriptive loop indexes instead of i, j, k` -- `Avoid double negatives` -- `Use verb as a prefix for the function name` -- `No magic number or magic values, use a variable` -- `Don't use abbreviations or acronyms without sufficient contexts` -- `Make variable name as long as necessary if needed but no longer` -- `A prefix like is, are , or has helps to distinguish a boolean from another variable` - -#### JavaScript datatype - -"use strict" //treat all JS code as newer version in whole file - -// alert(3+3) // cant use in nodejs, can be used browser. Currently, we are running in nodejs let name = "Abhay" //String data types let age =18 // number data types let isLoggedIn = false //boolean data types -- true/false let ab = null // it is a standalone value, its a type. repretensation of empty value let abc = undefined // when value is not defined or assigned // symbol - used to uniquely define a component - -// object - -console.log(typeof undefined); //undefined reason value not assigned console.log(typeof null); //is a type - -## Use proper variable names - -- Use the specific naming convention, can use camel case naming convention - -### variable scope->Understanding - -/_ Declaring a variable in the global scope. its life span is whole program _/ - -``` -var globalScopeVariable = 7; - -function test() { - /* Declaring a variable in the function scope. It's life span is in function only*/ - var functionScopeVariable = 10; - - /* Declaring a variable in the local scope, inside a for loop. It's life span is inside for loop only */ - for (let index = 0; index < functionScopeVariable; index++) { - console.log(index); - } -} - -test(); - - - `console.log(functionScopeVariable); //will throw error - ReferenceError: functionScopeVariable is not defined. Reason we are trying to use this outside of function scope` -``` - -``` -const accountId = 14456; -let accountEmail = "abhay@gmail.com" -var accountPassword = "12345" -accountCity = "Bangalore" -// accountId =2; //not allowed -accountEmail ="hc@gmail.com" -accountPassword = "212121" -accountCity = "Delhi" -console.log(accountId); - -let accountState; - -console.table([accountId,accountEmail,accountPassword,accountCity,accountState])` -``` - -** Prefer not to use var because of issue in block scope and functional scope** - -`console.log('accountState',accountState);` - -### Data Conversion - -``` -let score = true; - -let valueInNumber = Number (score); -console.log(score); -console.log(typeof valueInNumber); -console.log(valueInNumber);` -``` - -**Outcome**: - -1. if score = 33, output will be number & 33 -2. if score= "33" output will be number & 33 -3. if score = "33abc" output will be number & NaN -4. if score = null output will be number & 0 -5. if score = undefined output will be number & NaN -6. if score = true output will be number & 1 - -**Boolean conversion** Boolean(score); 1 => true; 0 => false "" => false "abhay" => true - -`To Do` : All possible Data Type Conversion - -### Data Types - -**"use strict"** //treat all JS code as newer version in whole file - -``` -// alert(3+3) // cant use in nodejs, can be used browser. Currently, we are running in nodejs -//JavaScript : 7 Primitive Data types -// 1. String -let name = "Abhay" //String data types - -// 2. number -let age =18 // number data types - -// 3. BigInt - -// 4. Boolean -let isLoggedIn = false //boolean data types -- true/false - -// 5. undefined -let abc = undefined // when value is not defined or assigned - -// 6. null -let ab = null // it is a standalone value, its a type. repretensation of empty value -// 7. symbol -``` - -//Object Data Type // 1. An Object // 2. An Array // 3. A date - -// symbol - used to uniquley define a component - -### Conversion Operator - -let score = "abh"; console.log(typeof score); console.log(typeof(score)); let valueInNumber = Number(score) // console.log(typeof valueInNumber); // console.log(typeof(valueInNumber)); // console.log(valueInNumber); - -//"33" => 33 can be converted easily //"33abc" => NaN (Not a number), typeof returns number for this //true => 1; false =>0 - -let isLoggedIn = "Abhay"; let booleanIsLoggedIn = Boolean(isLoggedIn) // console.log(booleanIsLoggedIn); // console.log(typeof booleanIsLoggedIn); - -//1 in Boolean is => true //0 in Boolean is => false //"Abhay" in Boolean is => true - -let someNumber = 33; let stringNumber = String(someNumber) // console.log(stringNumber); // console.log(typeof stringNumber); - -//**\*\*\*\***Operations \***\*\*\*\*\*\*\*** let value =3; let negValue = -value; // console.log(negValue); - -let str1 ="1" let str2 = 2 console.log("1"+2); console.log(1+"2"); console.log("1"+2+2); console.log(1+2+"2"); console.log(+true); //senseless code console.log(+""); //senseless code - -let num1, num2, num3; num1 = num2=num3 = 2+2; //not a good way to write code, foremost focus should be on readability - -let gameCounter = 100; ++gameCounter; console.log(++gameCounter); //prefix operator, increases value then print console.log(gameCounter++); //postfix operation, prints and then increases values // object - -`typeof variable //will show type of variable console.log(typeof undefined); //undefined reason value not assigned, is a datatype console.log(typeof null); //object, null is an object` - -### Comparision - -//comparision of same data type is straight forward console.log(2>1); console.log(2 >=1); - -//problem arises when you compare two different data types console.log("2">1); console.log("02">1); console.log("02">2); // always convert data into same data type - -console.log("=====null comparision -- should avoid this type of conversion ======"); console.log(null >0); console.log(null === 0); console.log(null >=0); // The reason is that an equality check == and comparisions >< >= <= works differently. Comparisions convert null to a number, treating it as 0. Thats why null >=0 is true and null > 0 is false - -console.log("=====undefined comparision -- should avoid this type of conversion ======"); console.log(undefined >0); console.log(undefined == 0); console.log(undefined >=0); // always returns false - -//Query -> Comparision & Equality works differently // === checks strict comparision - -### String - -const name = "Abhay" const repoCount = 50; console.log(`Hello my name is ${name} and my repo count is ${repoCount}`); //this is called string interpolation, it allows to add methods like ${name.ToUppercase()} - -const gameName = new String('Abhay Name'); //another way to declare string console.log(gameName); console.log(gameName[1]); console.log(gameName.**proto**); console.log(gameName.length); // get length of string value console.log(gameName.toUpperCase()); console.log(gameName.charAt(1)); console.log(gameName.indexOf('A')); console.log(gameName.substring(0,4)); console.log(gameName.slice(-3)); console.log(gameName.trim()); console.log(gameName.replace('A','T')); console.log(gameName.includes("Abhay")); console.log(gameName.split(" ")); - -//To Do - write a blog about string operation method - -### Num and Math - -const score = 400 const balance = new Number(100.05); // console.log(typeof score); // console.log(typeof balance); // console.log(score); // console.log(balance.toFixed(2)); const otherNumber = 1123.8966; // console.log(otherNumber.toPrecision(4)); const hundreds = 10000000 // console.log(hundreds.toLocaleString('en-IN')); //+++++++++++++++++ Maths ++++++++++++++++++ console.log(Math.abs(-4)); // minus value get converted to 4 (positive value) console.log(Math.round(4.6)); console.log(Math.ceil(4.2)); //take upper value console.log(Math.floor(4.9)); // take lower value - -let ab =[9,3,7,8,4] console.log(Math.min(...ab)); // find lowest value console.log(ab.reduce((a,b)=>Math.min(a,b))); //find lowest value console.log(Math.random()); //return value between 0 & 1 console.log(Math.floor((Math.random()\*10)+1)); - -const min = 10; const max = 20; console.log(Math.floor(Math.random()\*(max-min+1))+10) // to get random value between min & max range - -### Date - -/\*JavaScript Date objects represent a single moment in time in a platform-independent format. - -A JavaScript date is fundamentally specified as the time in milliseconds that has elapsed since the epoch, which is defined as the midnight at the beginning of January 1, 1970, UTC (equivalent to the UNIX epoch). This timestamp is timezone-agnostic and uniquely defines an instant in history.\*/ - -let myDate = new Date(); // console.log(myDate); // console.log(typeof myDate); // console.log(myDate.toString()); // console.log(myDate.toLocaleDateString()); - -let myCreatedDate = new Date(2023,0,23,5,3); console.log(myCreatedDate); - -let myCreatedDate1 = new Date("2023-01-14"); //YYYY-MM-DD console.log(myCreatedDate1.toLocaleDateString()); - -let myTimeStamp = Date.now(); console.log(myTimeStamp); - -let newDate = new Date(); console.log(newDate.getMonth()); console.log(newDate.getDay()); console.log(newDate.getFullYear()); - -console.log(newDate.toLocaleDateString("default",{weekday:"long",timezone:"Asia/Kolkata"})); - -### Data Type Summary - -//1. primitive (when passed, it is passed as value, no reference is provided) // 7 types //1.1 String //1.2 Number //1.3 Boolean //1.4 null //1.5 undefined //1.6 Symbol //1.7 BigInt (to handle scientific number value, const bigNumber = 12345677777788n) - -//2. non-primitive or reference type (can direclty refer memory address) //2.1 Array const heroes = ["Shaktiman","naagraj"] //2.2 Objects (can have mixed data types) let myObj = { name:"Abhay", age:22, } //2.3 Functions const myFunc = function(){ console.log("hello world"); } console.log(typeof heroes); - -//JavaScript is a dynamically typed language which means that data types of variable are determined by the value they hold at runtime and can change throughout the program as we assign different values to them. - -//How to define Symbol const id = Symbol('123') const anotherId =Symbol('123') - -console.log(id); console.log(id === anotherId); //value is same but returns false console.log(typeof id); //typeof results /\*1. undefined : "undefined" - -2. Null : "object" -3. Boolean : "boolean" -4. Number : "number" -5. String : "string" -6. Object (native - and does implement [[calll]]) : "object" -7. Object (native - or host and does implement [[calll]]) :"object" -8. Object (or host - and does implement [[calll]]) : implementation defined except may not be "undefined", "boolean", - "number" or "String" \*/ - -//++++++++++++++++++Memory Types+++++++++++++++++++++++++ //1. Stack Memory // all primitive type uses, provides only value //2. Heap Memory // Non-Primitive types, provides referece - -let ytName = "abhay" - -## Array - -The Array object, as with arrays in other programming languages, enables storing a collection of multiple items under a single variable name, and has members for performing common array operations. - -arrays aren't primitives but are instead Array objects: - -1. arrays are resizable and can contain a mix of different data types. (When those characteristics are undesirable, use typed arrays instead.) -2. arrays are not associative arrays and so, array elements cannot be accessed using arbitrary strings as indexes, but must be accessed using non-negative integers (or their respective string form) as indexes. -3. arrays are zero-indexed: the first element of an array is at index 0, the second is at index 1, and so on — and the last element is at the value of the array's length property minus 1. -4. array-copy operations create shallow copies. (All standard built-in copy operations with any JavaScript objects create shallow copies, rather than deep copies). - -``` - //Declare an array - const myArray = [1,2,3,4,true,"ABhay"]; - console.log(myArray); - - myArray[1] = 10 //valid operation although array is decalrad as const - myArray = [2,3,4] //Invalid operation reason myArray is declared as const - - const myHeroes = new Array("C","A","B","D"); - console.log(myHeroes); - - let ab= [1,2,3,"B"]; - ab[1] = 5; - ab = [4,5,7] //valid operation reason array is declareda let - console.log(ab); -``` - -### Array Methods - -#### push - -This method adds element at the end of current array. It modifies the original array. - -``` - ab.push("Dhruva"); - console.log(ab); - //output : [ 1, 2, 'Dhurva' ] -``` - -#### pop() - -This method removes last element from original array and returns value. It modifies the original array. - -``` - ab.pop(); - let temp = ab.pop() - console.log(ab); // [1,2] - console.log(temo); //Dhruva -``` - -#### unshift - -This method adds new element at the beginning of array - -``` - ab.unshift("Start"); - console.log(ab); // [ 'A', 1, 2 ] -``` - -#### shift - -This method removes first element from original array and returns value. It modifies the original array. - -``` -let temp = ab.shift(); -console.log(ab); // [1,2] -console.log(ab); // A -``` - -#### includes - -It checks for given value in array and returns true if element is found else false. - -``` -console.log(myHeroes.includes("A")); //returns true if element is found else false -marks.includes(120) //check if this value is in array -``` - -#### indexOf - -It checks for given value in array and returns element index from array else -1 if element is not found. - -``` -let ab = ['B',1,2]; -console.log(myHeroes.indexOf("B")); //index : 0 -console.log(myHeroes.indexOf("3")); //index : -1 - -``` - -#### sort - -This method sorts array values. - -``` -console.log('Sort array values : ',myHeroes.sort()); //sort array values -``` - -`Sort String Array` - -``` -let fruits = ["Banana","Apple"] -fruits.sort() //return sorted array -``` - -`Sort Number Array` - -``` -let fruits = [1,2,6,9,3,100,40] //return sorted array -``` - -> ![CAUTION] Sorting does not give correct result when array has number as well as string values. - -#### toString - -It is a generic method applicable to all objects and convert an object's value to string. The values are separated by commas. - -``` -let ab = ["ab","bc","da",10,5]; -console.log('Convert array to String : ',myHeroes.toString()); //10,5, ab,bc,dc -``` - -#### join - -join() method can only be used on array. It joins the array elements and returns a string. The values are seperated by the commas (by default), using `join()` method. We can also specify separator. - -``` -const newArra = ab.join(); -console.log(newArra ); //10,5,ab,ca,da - -const newArra = ab.join(|); //replace the default separator -console.log(newArra ); //10|5|ab|ca|da : converts array to pipe operarot seperator value, typeOf new Array is `string` -``` - -#### slice - -slice() method returns selected elements in an array, as a new array. It selects from a given startNum, up to a(not inclusive) given end. It does not change the original method. We can use slice() method to create a new array from existing array and without impacting original array. - -``` -const myArray = [0,1,2,3,4,5,6]; -const b = myArray.slice(1,3); -console.log("Orignal Array after slice : ",myArray); //original array after slice : [0,1,2,3,4,5,6] : no impact on original array -console.log('newArray' , b); // [1,3] : start from index : 1 and ends at 2 (not including index: 3) -``` - -#### splice - -splice fetches elements from array, includes last range, also modifies original array. This can be used to cut number of elements from original array. We can use splice() method to create a new array from existing array and also remove the element in original array. - -``` -const myArray = [0,1,2,3,4,5,6]; -const c = myArray.splice(1,3); //extract elements from index:1 to index:3 -console.log("original array after splice : ",myArray); //[0,4,5,6] : left with rest of element -console.log('new Array : ',c); //new array : [1,2,3] from existing - -`Break the array` -marks.slice(2,5) -``` - -#### push and concat operation on array - -`Problem Description`: You have two arrays - -``` -const marvelHeroes = ["Thor", "IronMan"]; -const marvelHeroes2 = ["Thor", "Zorawar"]; -const DCHeroes = ["Spiderman","Batman"]; -const DCHeroes2 = ["Spiderman","Batman"]; -``` - -`Use Case 1 : ` Merge two arrays, no impact on original array - -``` -marvelHeroes.push(DCHeroes); // adds second array as child array, does not merge two array. modifies original array -console.log(marvelHeroes); //output : ['Thor', 'IronMan',['Spiderman','Batman']] -``` - -`Use Case 2 : ` Merge two arrays, no impact on original array - -``` -marvelHeroes.push(DCHeroes); // merge two array. modifies original array -console.log(marvelHeroes); //output : ['Thor', 'IronMan','Spiderman','Batman'] -``` - -> [!CAUTION] concat() method is not much used, a better approach is using spread operator - -``` -const newArrayUsingSpread = [...marvelHeroes2,...DCHeroes2]; -console.log("Merge Array Using Spread Operator : ",newArrayUsingSpread); //output : ['Thor', 'IronMan','Spiderman','Batman'] -``` - -#### How to flat an array using flat() - -Flattening an array is the process of taking nested array elements and basically putting them all into one "flat" array. - -`Use Case 1` : flat() method flattens upto one level deep - -``` -const anArray = [1,2,3,[4,5,6],7,[6,7,[4,5]]]; -const flatArray =anArray.flat(); // [1,2,3,4,5,6,7,6,7,[4,5]] : 2nd level nested array is not flatten -array -console.log("Flatten the array : ",flatArray); -``` - -`Use Case 2` : flat() method flattens upto any level of deep nesting using `infinity` keyword - -``` -const anArray = [1,2,3,[4,5,6],7,[6,7,[4,5]]]; -const flatArray =anArray.flat(Infinity); // flatten the array till inifinite hierarchy or flatten the arrays into single -array -console.log("Flatten the array : ",flatArray); // [1,2,3,4,5,6,7,6,7,4,5] -``` - -#### How to check if array isArray() - -`isArray()` method returns true if an object is an array otherwise false. - -``` -console.log("isArray : ",Array.isArray("AB")); -console.log("isArray : ",Array.isArray(flatArray)); -``` - -#### Converts String to array using Array.from() - -Array.from() method returns an array from an object with length property. - -> [!CAUTION] If you use Array.from() on an array, will return `undefined` - -``` -console.log("Converts String to array : ",Array.from("ABC")); //Converts String to Array : ['A','B','C'] -``` - -#### Converts variables to array - -``` -let s1 = 300; -let s2 = 400; -let s3 = 500; -console.log("Converts varaible to array : ",Array.of(s1,s2,s3)); -``` - -### Mutating Array methods - -Mutating array methods are one who mutate (Mutation is basically changing the array itself instead of returning a new array with the new changes) the original array right away, when executed. - -It helps in following - - -- `Avoid accidentally mutating : ` The original array should not be mutated right away -- `Do Easier mind map : ` -- `These mutating methods need to be executed first` - -#### Mutating Array Methods list - -- `.copywithin() : ` use this to copy elements from within the array. It then replaces the pre-existing elements accordingly. -- .splice() -- .fill() -- .pop() - removes the last element from the array. This run on O(1) time . -- .push() - Adds elements to the end of array. This run on O(1) time . -- .reverse() - -- .sort() -- .unshift() - Adds element to the beginning of an array. This runs in O(n) time reason have to duplicate/move the entire array. -- .shift() - removes first element from the array. This runs in O(n) time reason have to duplicate/move the entire array. - -``` -//How to filter below array which has 'world' in it - -/* Creating an array of strings. */ -var wordsArray = [ - "hello-world", - "hello1-world", - "hello-we-world", - "hello-hello", - "jello-bello", -]; - - -/* Filtering the array and returning the array which has the text "world" in it. */ -var newArray = wordsArray.filter((wordHavingTextAsWorld) => - wordHavingTextAsWorld.includes("world") -); - -//or with return statement -newArray = wordsArray.filter((wordHavingTextAsWorld) => { - return wordHavingTextAsWorld.includes("world"); -}); - -/* Printing the array which has the text "world" in it. */ -console.log(newArray); - - -//Output -> - //[ 'hello-world', 'hello1-world', 'hello-we-world' ] - -``` - -### filter() - -The `filter()` method is an iterative method. It calls a provided callbackFn function once for each element in an array, and constructs a new array of all the values for which callbackFn returns a truthy value. Array elements which do not pass the callbackFn test are not included in the new array. - -``` -const myNums = [1,2,3,4,5,6,7,8,9,10]; -let newMyNums = myNums.filter((num)=>num<4) //you can write condition here. If condition is wrapped inside {}, return keyword needs to be provided -console.log(newMyNums); - -newMyNumsTwo = myNums.filter((num)=>{return num<4}) -console.log(newMyNumsTwo); -``` - -### Objects - -//singleton -> constructor will create singleton object. - -//Object literals -> when we create object using literals it will not be singleton const jsUser = { name:"Abhay", age: 18, "full name":"A B" } - -console.log(jsUser.name); console.log(jsUser["name"]); console.log(jsUser["full name"]); - -//Update value jsUser.name="Pari"; console.log(jsUser["name"]); - -Object.freeze(jsUser); //You can freeze an object, once freezed, value can't be changed - -jsUser["name"]="Shanvi"; console.log(jsUser["name"]); - -//How to assign and access Symbol const mySymbol1 = Symbol("key1"); const jsUserWithSymbol = { name:"Abhay", [mySymbol1]:"key1", age: 18, "full name":"A B" -} console.log(jsUserWithSymbol); - -jsUserWithSymbol.greeting = function(){ console.log("Hello AB"); } console.log(jsUserWithSymbol.greeting()); - -jsUserWithSymbol.greeting2 = function(){ console.log(`Hello JS User , ${this.name}`); } - -console.log(jsUserWithSymbol.greeting2()); - -const td = new Object(); //This is a singleton, object is same as created in 03_Objects.js file. Only difference is singleton console.log(td); - -const regulatedUser = { email:"abc@hotmail.com", fullname:{ userfullName:{ "firstname":"Abhay", "secondname":"Bharti" } } } - -// console.log(regulatedUser); - -// console.log(regulatedUser.fullname.userfullName.firstname); - -//Optional chaining -- The optional chaining (?.) operator accesses an object's property or calls a function. If the object accessed or function called using this operator is undefined or null, the expression short circuits and evaluates to undefined instead of throwing an error. - -// console.log(regulatedUser?.fullname?.userfullName?.firstname); - -const o1 = {1:"a",2:"b"}; const o2 = {3:"c",4:"d"}; - -const o3 = {o1,o2}; //This creates object inside object // console.log(o3); - -//Object.Assign const o4 = Object.assign(o1,o2); //will merge two object and return a new object // console.log("Using Object.assign Operator : ",o4); - -//Better way to do merge two object is spread opertor const o5 = {...o1,...o2}; // console.log("Using Spread Operator : ",o5); - -// console.log(Object.keys(o1)); //returns key of object // console.log(Object.values(o1)); //retuns value of object // console.log(Object.entries(o1)); //retuns array of key/value pair - -//hasOwnProperty method returns true if key exists else false // console.log(o1.hasOwnProperty('1')); //return true // console.log(o1.hasOwnProperty('A')); //return false - -//Destructuring Of Objects - -const course = { name:"Java", price: 400 } - -//access value of an Object property using object name.property name console.log(course.price); const {price} = course; console.log("price : ",price); //access value after object destructuring const {name:n}=course; //can assign a new name at the time of destructuring console.log(n); - -//Object desctructuring is useful when passing props to React component - -//To Do How to Destrucutre An Array - -## Functions - -function hello(){ console.log("A"); } - -// hello; //This return reference of a function, useful in React component // hello() //This statement executes a function - -//check for undefined value using if operator function userName(name){ //Check for null and undefined if (name === undefined){ console.log("Enter a username"); return; } return `${name} just logged in` } - -console.log(userName("Abhay")); console.log(userName()); - -// We can use logical Not (!) operator to check for null or undefined value function userName2(name){ //Check for null and undefined if (!name ){ console.log("Enter a username"); return; } return `${name} just logged in` } - -console.log(userName2("Abhay")); console.log(userName2()); - -//To Do - Rest Operator function calculateCartPrice(...num){ return num; } console.log(calculateCartPrice(100,200,300)); //return an array as [100,200,300] - -//Passing Object as a parameter in function - -const aObject = { name:"Abhay", price: 299 } - -function A(anObject){ console.log(`${anObject.name} and ${anObject.price}`); } - -A(aObject); - -//Passing array to functions function returnsSecondValueFromArray(getArray){ return getArray[1]; -} - -const myArray = [3,4,6,8]; console.log("passing array as function : ",returnsSecondValueFromArray(myArray)); //pass array as parameters console.log("passing array directly as function : ",returnsSecondValueFromArray([8,9,10])); //passing arrays as directly as params - -console.log(addOne(6)); - -//This approach of function declaration, you can call function execution statement before definition is written. This is called Hoisting. function addOne(num){ return num+1; } - -console.log(addOne(5)); - -//In this approach, function execution statement should be after definition. Otherwise, will throw `Cannot access 'addTwo' before initialization` errror const addTwo = function (num){ return num+2; } console.log(addTwo(10)); - -### Arrow function - -const user = { name:"AB", price:999, welcomeMessage:function(){ console.log(`${this.name}, welcome to Website`); //this contains all variable of object. } } - -//Note : This context works only inside object, does not work in function. console.log(user.welcomeMessage()); user.name ="Ajay" //change value of name field console.log(user.welcomeMessage()); //print updated value - -console.log("this in node : ",this); // {} - in node, this prints {}. If you print console.log(this) in chrome browser console, it will prints windows context - -function hello(){ let name = "Abhay"; console.log("name : ",this.name); //prints undefined (behavior is same in arrow function) } hello() - -//To Do - Why we need arrow function - -//If function scope is added in arrow function like {}, means if curly braces is used, you need to use return keyword to return value from function. Otherwise function will not return any value const addTwo = (n1,n2) =>{ return n1+n2; } console.log("Explicit return ", addTwo(5,7)); - -//if written like below or like const addThree = (n1,n2,n3) => n1+n2+n3;, will automatically return value. No need to use return keyword. This is called implict arrow function. This is used a lot in ReactJS. const addThree = (n1,n2,n3) => (n1+n2+n3); console.log("Implicit return",addThree(5,7,2)); - -//Return Object from Arrow function const returnObjectFromArrowFunction = (n1,n2) => ({name:n1,age:n2}) //to return object, need to wrap object in () braces - -console.log(returnObjectFromArrowFunction("AB",23)); - -//Immediately Invoked Function Expression (IIFE) - -//name IIFE function (function chai(){ console.log('DB Connected'); })(); //This will get executed - -// Notes : // 1. function definition should be wrapper in () // 2. () Should be appended at the end of first braces // 3. Should add ; at the end, to end context - -//To Do - Why we need IIFE, practical need //This helps to avoid pollution due to global scope. - -//unname IIFE function ( ()=>{ console.log('DB Connected using arrow function'); })(); //IIFE with arrow function - -//unname IIFE function with params ( (name)=>{ console.log(`${name} DB Connected using arrow function`); })("AB"); //IIFE with arrow function - -### JS Execution - -//How code execute in JS (Execution Context) //Call Stack /_ Global Execution Context Function Execution Context Eval Execution Context _/ - -//Function code to be shown in execution context let v1 = 10; let v2 = 20; function add(v1,v2){ let total = v1+v2; return total; } - -let result = add(v1,v2); let resultTwo = add(10,15); - -/\* --- How JS Execution Happends --- - -1. Global Execution or Environment -> this - -2. Memory Phase -> all variables re put at a place v1 = undefined v2 = undefined add -> definition result = undefined resultTwo = undefined - -3. Execution Phase v1 = 10 v2 = 20 add -> new Enviornment + new Execution Context/thread created (Step 1 t 3 will be repeated as many times function is called) \*/ - -//How to write code in Chrome browser // Sources -> Snippeets -> New Snippet -> file name -> write code in right side pane -> Crtl + S to save file - -## Control Flow - -### if - -#### Multiple ways to write if conditions - -**Classical approach** - -``` -const status = 'online' - -if (status ==='online' || status === 'away' || status ==='busy'){ -console.log('Do Something') -} -``` - -**A better approach** - -`if (['online','away', 'busy'].indexOf(status)!== -1){ console.log('Do Something') }` - -`Check IndexOf with `~` operator` - -``` - -if (~['online','away', 'busy'].indexOf(status)){ - console.log('Do Something') -} -``` - -`Even better, using includes method` - -``` -if (['online','away', 'busy'].includes(status)){ - console.log('Do Something') -} -``` - -### switch - -switch (key) { case value: - - break; - - default: - break; - -} - -/\* #VSCODE tips to copy/paste/delete code using keyboard shortcut - -1. Duplicate a Line/Code Block: place your cursor on a line or select a code block & press [Shift + Alt+ Down Arrow key]. Code will be duplicated. -2. Delete a Line/Code Block: place your cursor on a line or select a code block & press [Crtl + Shift + k]. Code will be removed. -3. Paste from history of all Copy/Cut items: There is no inbuilt feature available in #VSCODE. Here is a workaround, install extension #Clipboard Manager. This extension keeps history of copy/cut operation in VS Code. Press [Crtl + Shift + V], it will show history of values, you can select which one you want to paste. \*/ - -### Truthy - -//Truthy/Falsy value const user = "ABC@ai"; if (user){ console.log(`Found user ${user}`); }else { console.log(`Not Found user `); // this will be printed if user = "" } - -//falsy values List //false,0,-0,BigInt 0n,'', null,undefined, Nan - -//truthy values List //"0",'false',' ',[],{},function() - -//How to check truthy for array const userArray = []; if (userArray.length === 0){ //code to check for truthy value for array, is empty console.log("Array is empty"); } - -//How to check truthy for array const emptyOb ={}; if (Object.keys(emptyOb).length ===0){ //get keys list & check if length is zero console.log("Object is empty"); } - -false == 0 //true false == '' //true 0 == '' //true - -//Nullish Coalescing Operator(??) //:null undefined - It assigns whatever first valid value is found - -let val; val = null ?? 10; console.log(val); val = 5 ?? 10; console.log(val); val = undefined ?? 15; console.log(val); - -val = undefined ?? null??20; console.log(val); - -//Ternary Operator //test condition? true:false const price =100; price >=80?console.log("less than 80"):console.log('More than 80'); - -## Loops in JavaScript - -const arr = [1,2,3,5,6] - -//ForOF to iterate on an array for (const num of arr) { console.log(num); //print all values ofn an array } - -const h = "hello"; for (const char of h) { console.log(char); //print all character of a string } - -//JavaScript Map //To Do - What is Map const myMap = new Map(); myMap.set('A',1); myMap.set('B',3); myMap.set('C',5); console.log(myMap); //prints map -> Map(3) { 'A' => 1, 'B' => 3, 'C' => 5 } - -//Iterater an Map & destructure array returned for each key/value pair, [key,val] is destructuring map key/value to key & val for (const [key,val] of myMap) { console.log(`key : ${key} -:- val : ${val}`); } - -//Note : When we run a forof loop on Map, each element is returned as an array. We need to do it in two step, // 1. iterate through Map key/value pair using forof // 2. Desctructure each array (containing key/value pair) in two key & value // 3. Above approach can't be used on Object, forOf can't be used on Map // 4. for of loop is used on Array/Map - -//How to iterate an Object const myObj = { k:"one", l:"two" } //We need ForIn to iteration over object & access value for (const key in myObj) { console.log(`key : ${key} : value : ${myObj[key]}`); //print all values } - -//Note : We can use ForIn on array, can't use on Map. Map is not an iterable. - -//ForIn on array const anAray = [1,2,3,6]; for (const key in anAray) { console.log(anAray[key]); } - -//ForEach Example const mArray = ["J", "k","L"]; //foreach with normal function mArray.forEach(function(item){ console.log(item); //print all values of array, we can write any logic code within cury{} braces }) - -//foreach with arrow function mArray.forEach((item)=>{ console.log(item); }) //Using external or another function - -console.log("--------------"); function printMe(item){ console.log(item); } - -mArray.forEach(printMe) - -//foreach has access to item, index & full array mArray.forEach((item,index,arr)=>{ console.log(item,index,arr); }) - -//Array Of Objects - -const mCode = [ {name:"JS",file:'.js'}, {name:"Java",file:'.java'}, {name:"python",file:'.py'} ] - -mCode.forEach((item)=>{ console.log(item.name,item.file); }) - -//Notes - foreach does not return any value, better usable methods are filter/map/reduce - -//How to return value using ForEach const myNums = [1,2,3,4,5,6,7,8,9,10]; const newNums = []; myNums.forEach((num)=>{ if (num > 4){ newNums.push(num) } }) console.log(newNums); - -### Different types of Loops supported in JavaScript - -**Here is sample array of objects** - -``` -const carShowRoom = [ - {id:1,name:'Maruti', model:"Swift"}, - {id:2,name:'Tata', model:"Nexon"}, - {id:3,name:'Mahindra', model:"Bolero"}, - {id:4,name:'Benz', model:"car"} -]; -``` - -### Using For Loop - -``` -for (let index=0; index carShowRoom.name); -console.log(car) -``` - -#### Output: - -``` -[ 'Maruti', 'Tata', 'Mahindra', 'Benz' ] -``` - -#### What is console.log - -whatever is given to console.log, should get displayed as output. - -print multiple values in table console.table([accountId,accountEmail,accountPassword,accountCity]) - -## JavaScript Good Practice - -👉Use Strict Mode: Always enable strict mode at the top of your scripts or functions. It helps catch common coding mistakes and prevents the use of potentially problematic features. - -👉Declare Variables Properly: Always use `let`, `const`, or `var` to declare variables. Avoid relying on implicit global variables. - -👉Avoid Global Variables:Minimize the use of global variables to prevent unintended interactions between different parts of your code. - -👉Use Descriptive Variable and Function Names: Choose meaningful names for variables and functions. This improves code readability and makes it easier to understand your code's purpose. - -👉Comment Your Code: Add comments to explain complex sections of your code, especially if it's not immediately obvious what the code does. - -👉Indentation and Formatting: Maintain consistent indentation and formatting. This makes your code easier to read and reduces the risk of syntax errors. - -👉Avoid Magic Numbers and Strings: Replace magic numbers and strings with named constants or variables to make your code more maintainable. - -👉Error Handling: Implement proper error handling using `try...catch` blocks to gracefully handle exceptions and prevent crashes. - -👉Use Functions for Code Reusability: Write functions to encapsulate and reuse code. Avoid duplicating code blocks. - -👉Check Types and Use Type Coercion Wisely: Be aware of JavaScript's type system, and use `typeof`, `instanceof`, or functions like `isNaN()` to validate data types before operations. - -👉Avoid Asynchronous Callback Hell: Use promises, async/await, or libraries like `async.js` to manage asynchronous code and avoid deeply nested callback structures. - -👉Test Your Code: Implement unit tests and automated testing frameworks like Jest to catch bugs early and ensure your code behaves as expected. - -👉Code Reviews: Encourage code reviews within your team. Fresh perspectives can help identify potential issues. - -👉Use a Linter: Employ a JavaScript linter like ESLint to enforce coding standards and catch common mistakes. - -👉Keep Dependencies Updated: Regularly update your project's dependencies to patch security vulnerabilities and ensure compatibility. - -👉Optimize for Performance: Be mindful of performance bottlenecks and optimize critical sections of your code when necessary. - -#### What is block scope and functional scope - -#### Why should not use `var` - -Prefer not to use `var` because of issue in block scope and functional scope - -#### What is undefined in JavaScript - -When you declare a variable & do not assign any value to it, it is undefined. ex. - -``` -let accountState; -console.log(accountState); -``` - -`undefined` is the output of above code - -//TO Read https://www.linkedin.com/posts/saboor-malik-993b03202_75-useful-javascript-code-snippets-activity-7106737879598440448-gEWg?utm_source=share&utm_medium=member_desktop - -### set - -### null - -### map - -//map -- The map() method of Array instances creates a new array populated with the results of calling a provided function on every element in the calling array. - -``` -const myNums = [1,2,3,4,5,6,7,8,9,10]; -let newNums = myNums.map((num)=>num+10) //will iterate all element & add value 10 -console.log(newNums); -``` - -//To Do -- difference between filter and amp - -// Note - map should be preferred instead of foreach if ask is to iterate all element & perform some operation - -//function Chaining - -``` -const m = myNums.map((num)=>num*10).map((num)=>num+1).filter((num)=>num>40); -console.log(m); -``` - -### loops - -### String - -### BigInt - -### Object - -### Reflect - -### scopes - -### Symbol - -### Boolean - -### currying - -### closures - -``` - - - - - - Closure - - - - - - - - - -``` - -## promise - -The Promise object represents the eventual completion (or failure) of an asynchronous operation and its resulting value. - -### A Promise is in one of these states: - -`pending`: initial state, neither fulfilled nor rejected. - -`fulfilled`: meaning that the operation was completed successfully. - -`rejected`: meaning that the operation failed. - -![alt text](./promise.png "Promise Diagram") - -https://www.youtube.com/watch?v=_TjtAyMkiTI promises starts at 5:39 - -### API Request - -``` - - - - - - - Document - - - - -
- - - - -``` - -``` -const promiseOne = new Promise(function (resolve, reject) { -//Do an async task -//DB calls, cryptography, network -setTimeout(function () { -console.log("Async task is completed"); -resolve(); -}, 1000); -}); - -promiseOne.then(function () { -console.log("Promise consumed"); -}); - -//2nd promise -new Promise(function (resolve, reject) { -setTimeout(function () { -console.log("Async task 2"); -resolve(); -}, 1000); -}).then(function () { -console.log("Async 2 resolved"); -}); - -//3rd promise -- pass data through resolve -const promiseThree = new Promise(function (resolve, reject) { -setTimeout(function () { -resolve({ username: "chai", email: "chai@gmail.com" }); -}, 1000); -}); - -promiseThree.then(function (user) { -console.log(user); -}); - -//4th Promise - -const promiseFour = new Promise(function (resolve, reject) { -setTimeout(function () { -let error = true; -if (!error) { -resolve({ username: "hitesh", email: "123" }); -} else { -reject("ERROR: Something went wrong"); -} -}, 1000); -}); - -promiseFour -.then((user) => { -console.log(user); -return user.username; -}) -.then((username) => { -console.log(username); -}) -.catch((error) => { -console.log(error); -}) -.finally(() => { -console.log("Finally block -- THe promise is finally resolved or rejected"); -}); - -//promise 5 -const promiseFive = new Promise((resolve, reject) => { -setTimeout(() => { -let error = true; -if (!error) { -resolve({ username: "javascript", email: "123" }); -} else { -reject("ERROR: JS went wrong"); -} -}, 1000); -}); - -async function consumePromiseFive() { -try { -const response = await promiseFive; -console.log(response); -} catch (error) { -console.log(error); -} -} - -consumePromiseFive(); - -//promise 6 -async function getAllUsers() { -try { -const response = await fetch("https://jsonplaceholder.typicode.com/users"); -//console.log(response); -const data = await response.json(); -console.log(data); -} catch (error) { -console.log("E:", error); -} -} -getAllUsers(); - -console.log("----------------------------------"); -// fetch with then/catch -fetch("https://api.github.com/users/abhaybharti") -.then((response) => { -return response.json(); -}) -.then((data) => { -console.log(data); -}) -.catch((error) => { -console.log(error); -}); - -//To Do - read more about fetch api -// Micro task queue or priority queue contains fetch request. It gets added on top of call stack. - -``` - -### call stack - -### web APIs - -### undefined - -### deep copy - -### data types - -### event loop - -## JavaScript is a - -- synchronous language (every thing happens in sequence) -- Single threaded - -## Execution Context - -- execute one line of code at a Time (each operation waits for the last one to complete before executing next line) -- console.log("hello") -- 1 -- console.log("hello") -- 2 Call Stack Memory Heap - -//Above is behavior of default engine of JavaScript - -## Blocking Code - -- Block the flow of program -- Read file sync - -## Non Blocking Code - -- Does not load block execution -- Read file Async - -This diagram is explained at time stamp 4:10 in video https://www.youtube.com/watch?v=_TjtAyMkiTI - -![alt text](./EventLoop.png "Event Loop") - -JavaScript engine is made up of Call stack & Memory Heap. - -Task Queue in JS Engine in Event loop - -``` - - - - - - HTML Events - - -

Amazing Image

-
- -
- - - - -``` - -``` - - - - - - Document - - -

Chai aur JavaScript

- - - - - - -``` - -``` - - - - - - Document - - -

Chai aur Code

- - - - - -``` - -### statements - -### asynchrony - -### async - await - -### conditionals - -### map method - -### shallow copy - -### destructuring - -#### Object Destructuring - -#### Array Destructuring - -#### Rest Operator - -#### Spread Operator - -### pure function - -### lexical scoping - -### arrow function - -### Check weather passed String is numeric or not - -````function - return /^-?\d*\.?\d+$/.test(value); -}``` - -```function isNumeric(value) { - return !isNaN(Number(value)); -} -```` - -### string methods - -### named imports - -### default imports - -### reduce method - -//reduce -- To Do -- read more on reduce function //reduce is used frequently in react - -``` -const m =[1,3,4]; -let initialVal = 0; -let newM = m.reduce((accumulate,currVal)=>{ -console.log(`accumulate : ${accumulate} : currVal : ${currVal}`); -return accumulate+currVal; -},initialVal) - -console.log(newM); - -//count total price in shoppingCart -const shoppingCart = [ -{ -courese: "JS", -price: 100 -}, -{ -courese: "React", -price: 200 -}, -{ -courese: "Redux", -price: 300 -} -] - -let totalPrice = shoppingCart.reduce((total,item)=>{ -return total+item.price -},0) -console.log(totalPrice); -``` - -### handling events or event listener and event bubbling and event capturing - -### setTimeout and setInterval - -### forEach method - -### template literals - -### normal functions - -### spread operators - -### promise chaining - -### optional chaining - -### conditional operator - -### function expressions - -### Random Number - -`True Random Number`: are generated based on external factors e.g. generating randomness using surroundings noise. It is time consuming to generate. `Pseudo Random Number`: are generated based on an algorithm and seed value. can be used in cryptography e.g. OTP - -#### Math.random() - -returns a double type pseudo-random number, greater than or equal to zero and less than one. - -`let num = Math.random() -- return number between 0 and 1, every execution will generate new number` - -## Enum - -## nodemailer - -### Send email through outlook using nodemailer - -### Send email through gmail using nodemailer - -### Send Email From Your App Without a Backend - -https://www.abstractapi.com/guides/react-send-email-from-your-app-without-a-backend - -## Database Connection - -## PostGresSQLConnection - -### Install following package - -``` - "pg": "^8.8.0", -``` - -### Create a JS file like queries.js and Add following import statement - -``` -const { response, request } = require("express"); -require("log-timestamp"); -const Pool = require("pg").Pool; -var types = require("pg").types; -const ping = require("ping"); -const { deviceDetails } = require("./DeviceList"); -//var Ping = require("ping-lite"); -const momenttimezone = require("moment-timezone"); -``` - -### Create Connection With PostGresSQL DB - -``` -const pool = new Pool({ - user: "testloguser", //login user - host: "localhost", - database: "testlog", //database name - password: "testloguser", // password - port: 5432,//port where postgres is running -}); -``` - -### Get Data from postgres table - -``` -const getDefectList = (request, response) => { - try { - let queryString ="select * from defects"; //make sure defects table exists in your database - pool.query(queryString, (error, results) => { - if (error) { - throw error; - } - response.status(200).json(results.rows); - }); - } catch (error) { - console.log(error); - } -}; -``` - -### Export above created function, so that you could import in other JS file - -``` -module.exports = { - getDefectList -}; -``` - -## Using Object Literals Instead of Switch Case - -#### function to getMarkRange() using switch case - -``` -function getMarkRange(grade) { -let range; -//Checking the value of the grade variable and returning the range of the grade using Switch case -switch (grade) { -case "A": -range = "100-70"; -break; -case "B": -range = "40-69"; -break; -case "C": -range = "0-39"; -break; -} -return `range is ${range}`; -} -console.log(getMarkRange("B")); -``` - -#### function to getMarkRange() using Object literal - -``` -function getMarkRangeWithObjectLiteral(grade) { -let range = { -A: "100-70", -B: "40-69", -C: "0-39", -}[grade]; -return `range is ${range}`; -} - -console.log(getMarkRange("B")); -``` - -## rest syntax - -## Array Destructuring using rest syntax - -Array destructuring is flexible. It uses less space, and even allows you to ignore values. You can even get the remaining elements as a new array. Instead of accessing elements individually, one by one, you can get multiple at once. - -``` -const kidsName = ["Govind","Gopal","Pari","Kanhu","Aayu"] - -//traditional way of accessing array values -const firstValue = kidsName[0]; -const secondValue = kidsName[1]; -console.log(firstValue); -console.log(secondValue); -``` - -``` -const [firstValue, ,thirdValue, ...rest] = kidsName - -console.log(firstValue); -console.log(thirdValue); -console.log(rest); -``` - -`Output:` Govind Pari [ 'Kanhu', 'Aayu' ] - -## Receiving Data using rest syntax - -A rest parameter is a special kind of parameter that receives all remaining arguments of a function call via array. - -``` -function myFunc(first, ...remaining) { - return {first, remaining} -} - -console.log(myFunc(1,2,3)) -``` - -`Output:` { first: 1, remaining: [ 2, 3 ] } - -## Object Destructuring using rest syntax - -``` -const {first:f, ...remaining} = {first:'Kanhu', last:'Pari', age:5} - -console.log(f) -console.log(remaining) -``` - -`Output:` Kanhu { last: 'Pari', age: 5 } - -## Spreading data - -## Spreading into a function call turns Array elements into function call arguments - -``` -function returnArgArray(...args){ - return args -} - -returnArgArray(...[1,2,3]) - -console.log(returnArgArray(...[1,2,3])) -`Output:` -[ 1, 2, 3 ] - -//spread arrays into Array literals -console.log(returnArgArray(...[1,2,3],4)) -`Output:` -[ 1, 2, 3, 4 ] -``` - -## Remote command execution via SSH using NodeJS - -- 1st step, install `npm install --save simple-ssh` - -``` -const SSH = require('simple-ssh'); //load into project - -//create instance of SSH -var ssh = new SSH({ - host: 'IP_ADDRESS', - user: 'USERNAME', - pass: 'PASSWORD' -}); - -//Run any command via exec command -ssh.exec(CMD, { - out: function (stdout) { console.log(stdout); }, - err: function (stderr) { console.log(stderr); }, - exit: function (code) { console.log(code); } -}).start(); -``` - -//Run actual command like this ssh .exec("online", { out: function (stdout) { console.log(stdout); }, err: function (stderr) { console.log(stderr); }, exit: function (code) { console.log(code); }, }) .start(); - -### Create a Unique ID - -``` -const uid = () =>{ - //Get current time and convert to String, String(36) converts large number to base 36 - const head = Date.now().toString(36); - - - //Generate random number and covert to string of base 36 - const tail = Math.random().toString(36).substr(2); - - //concatenate both string value - return head+tail; -} - -//call uid function -uid() -``` - -`Sample Output :` `l2o6trgk3prw6bdui96` - -:::tip Tip - -You can add write uid function in util.js file like export const uid = () =>{ } and add import statement `import {uid} from ../utils;` and call uid() function - -## Switch Case Statement Simplify using Object Literals - -``` -/* - function to getMarkRange() using switch case -*/ -function getMarkRange(grade) { - let range; - //Checking the value of the grade variable and returning the range of the grade using Switch case - switch (grade) { - case "A": - range = "100-70"; - break; - case "B": - range = "40-69"; - break; - case "C": - range = "0-39"; - break; - } - return `range is ${range}`; -} -console.log(getMarkRange("B")); -``` - -`Output :` 40-69 - -#### We can use an "Object Lookup Map" instead of a "switch" statement for a cleaner syntax. Above switch statement re-written in Object Lookup map format. - -``` -/* - function to getMarkRange() using Object literal -*/ -function getMarkRangeWithObjectLiteral(grade) { - let range = { - A: "100-70", - B: "40-69", - C: "0-39", - }[grade]; - return `range is ${range}`; -} - -console.log(getMarkRange("B")); - -``` - -`Output :` 40-69 - -> ## Mean -> -> ing of ^ and ~ symbols mentioned in the package.json file for the package version - -Whenever we install any npm package, a new entry is added in the dependencies or devDependencies section of the >package - -> .json file in the following format: - -``` -"dependencies": { -"axios": "^0.24.0" -} -``` - -The version number 0.24.0 is a combination of 3 digits separated by the dot operator. Let’s say the version is a.b.c - -
    - - - -
- -`^` : This symbol means when we want to update all the packages mentioned in package.json, using npm update, it will update to only patch and minor released version. - -So if your current version is 0.24.0 and there is a minor version released so the package will be updated to 0.25.0. - -If there is only a patch version released then it will be updated to the latest available patch version like 0.24.1. - -`~`: This symbol means the package will be updated to only patch releases when we run the npm update command i.e only the last digit so from 0.24.0 to 0.24.1 or 0.24.2 but not 0.25.0 or 1.24.0 - -If there is no symbol like "axios": "0.24.0" then exact same version will be installed after running the npm update command. - -You can also update the specific npm package by adding the package name after the npm update command gitlike this: npm update axios. - -## How To Create Express Server - -## How To Create Server Using Express/NodeJS - -### Install following package - -``` - "cors": "^2.8.5", - "express": "^4.18.2" -``` - -### Add following at start of file (create a JS file like index.js) - -``` -const express = require("express"); -const bodyParser = require("body-parser"); -const { request } = require("express"); -const db = require("./queries"); -const cors = require("cors"); -var http = require("http"); -var https = require("https"); - -const router = express.Router(); - -const app = express(); -const port = 5000; - -app.use( - cors({ - origin: "*", - }) -); - -app.use(bodyParser.json()); -app.use( - bodyParser.urlencoded({ - extended: true, - }) -); - -app.use(compression()); - -app.get("/", (request, response) => { - response.json({ info: "node.JS, Express and PostGres API" }); -}); - -app.listen(port, () => { - console.log(`App running on port ${port}.`); -}); - -``` - -### Open CMD prompt - -``` -node index.js -``` - -`Output: ` App running on port 5000. - -## Fetch Data from API - -## Different ways to fetch data from API - -- using **fetch** API This method accept URI to the data. To do this, first create a function fetchData(), it will >call fe - - > tch() method with provided URL, then convert the result to JSON Object. - - ``` - const fetchData = () =>{ - return fetch("https://api.agify.io/?name=bella") - .then((response)=>response.json()) - .then((response)=>console.log(response)) - .catch(err => console.error(err)); - } - - fetchData() //call function - ``` - - `Output: ` {name: 'bella', age: 35, count: 40138} - - `Failure response : Failed to fetch at \_app-c265dce31871f367.js:1:752592 at fetchData (:2:10) at :7:1 ` - -:::tip You can specify header info also - -``` -const options = { - method: 'GET', - headers: { - 'X-RapidAPI-Host': 'alpha-vantage.p.rapidapi.com', - 'X-RapidAPI-Key': 'SIGN-UP-FOR-KEY' - } -}; - -const fetchData = () =>{ - return fetch("https://api.agify.io/?name=bella", options) - .then((response)=>response.json()) - .then((response)=>console.log(response)) - .catch(err => console.error(err)); - } -``` - -- using **Async - Await** Syntax Remove **.then()** callback and simply get back asynchronously resolved data. -- using **Axios** library -- using **Custom react hooks** -- using **Use React Query** library -- using **Using GraphQL** API - -### Create ENUM in JavaScript - -``` -const Days = Object.freeze({ - MONDAY:0, - TUESDAY:1, - WEDNESDAY:2, - THURSDAY:3, - FRIDAY:4, - SATURDAY:5, - SUNDAY:6, -}) -``` - -## variable scope->Understanding - -Filter() method creates a new array from existing array with elements that pass a test provided by a function. It does not execute the function for empty elements. It method does not change the original array. - -``` -//How to filter below array which has 'world' in it - -/* Creating an array of strings. */ -var wordsArray = [ - "hello-world", - "hello1-world", - "hello-we-world", - "hello-hello", - "jello-bello", -]; - - -/* Filtering the array and returning the array which has the text "world" in it. */ -var newArray = wordsArray.filter((wordHavingTextAsWorld) => - wordHavingTextAsWorld.includes("world") -); - -//or with return statement -newArray = wordsArray.filter((wordHavingTextAsWorld) => { - return wordHavingTextAsWorld.includes("world"); -}); - -/* Printing the array which has the text "world" in it. */ -console.log(newArray); - - -//Output -> - //[ 'hello-world', 'hello1-world', 'hello-we-world' ] - -``` - -``` -//Filter -> used to filter value from array -function isOdd(x) { - return x % 2; -} - -//function code outside filter -output = arr.filter(isOdd); -console.log(output); - -//function code inside filter -output = arr.filter(function isEven(x) { - return x % 2 === 0; -}); -console.log(output); - -//function code as arrow function -output = arr.filter((x) => x % 2 === 0); -console.log(output); -``` - -## Array -> map() method - -//Map -> it transform an array const arr = [5, 4, 3, 6, 9, 7]; - -function double(x) { return x \* 2; } - -//function is outside let output = arr.map(double); console.log(output); - -//function is inside map output = arr.map(function triple(x) { return x \* 3; }); console.log(output); - -//using arrow function approach output = arr.map((x) => x \* 4); console.log(output); - -//binary value output = arr.map((x) => x.toString(2)); console.log(output); - -## Array -> reduce() method - -//Reduce //traditional way of calculating values function findSum(arr) { let sum = 0; for (let index = 0; index < arr.length; index++) { sum = sum + arr[index]; } return sum; } - -console.log(findSum(arr)); - -//using reduce method output = arr.reduce(function (acc, curr) { acc = acc + curr; return acc; }); console.log(output); - -//find max value using traditional ways function findMax(arr) { let max = 0; for (let index = 0; index < arr.length; index++) { if (arr[index] > max) { max = arr[index]; } } - -return max; } - -console.log(findMax(arr)); - -//finding max value using reduce method output = arr.reduce(function (max, curr) { if (curr > max) { max = curr; } return max; }, 0); //0 is initial value of variable max console.log(output); - -const users = [ { firstName: "Abhay", lastName: "Bharti", age: 34 }, { firstName: "Alok", lastName: "kumar", age: 45 }, { firstName: "Awanish", lastName: "kumar", age: 38 }, { firstName: "Gajju", lastName: "kumar", age: 38 }, ]; - -//print list of fullname output = users.map((x) => x.firstName + " " + x.lastName); console.log(output); - -//count same age person output = users.reduce(function (acc, curr) { if (acc[curr.age]) { acc[curr.age] = ++acc[curr.age]; } else { acc[curr.age] = 1; } return acc; }, {}); //{} assigns acc as {} object - -console.log(output); - -//filter based on value and return as list output = users.filter((x) => x.age > 34).map((x) => x.firstName); console.log(output); - -### Array -> Remove Duplicate Values - -``` -const letters = ['a','b','c','d','d','e','f','f'] -``` - -#### remove duplicate Using Set - -``` -const unique = [... new Set(letter)] -console.log(unique) - -``` - -`Output :` - -- [ 'a', 'b', 'c', 'd', 'e', 'f' ] - -#### remove duplicate Using Array reduce() method - -``` -const unique = letters.reduce((result,letter)=>{ - return result.includes(letters)? result:[...result, letters]; -},[]) -console.log(unique) -``` - -`Output :` - -- [ 'a', 'b', 'c', 'd', 'e', 'f' ] - -#### remove duplicate Using Array filter() method - -``` -const unique = letters.filter((letter,index)=>{ - return letters.indexOf(letter)===index; -}) -console.log(unique) -``` - -`Output :` - -- [ 'a', 'b', 'c', 'd', 'e', 'f' ] - -#### Remove duplicates from an array of objects by one property - -``` -const members = [ - { id: 1, name: 'John' }, - { id: 2, name: 'Jane' }, - { id: 1, name: 'Johnny' }, - { id: 4, name: 'Alice' }, -]; -const unique = [...new Map(members.map((m) => [m.id, m])).values()]; -console.log(unique) -``` - -`Output :` - -- [ { id: 1, name: 'Johnny' }, { id: 2, name: 'Jane' }, { id: 4, name: 'Alice' } ] - -How it works - -- Create a new aray from the original array using map() method `members.map((m) => [m.id, m])` -- It returns an array of arrays. Each nested array contains the value of the id and the corresponding object: - -``` -[ - [ 1, { id: 1, name: 'John' } ], - [ 2, { id: 2, name: 'Jane' } ], - [ 1, { id: 1, name: 'Johnny' } ], - [ 4, { id: 4, name: 'Alice' } ] -] -``` - -- Second, remove the duplicate by creating a new Map() object: - -``` -const newMap = new Map(newArray); -``` - -- Because the keys of a Map object are unique, creating a Map from the array of array removes the duplicate object by key (id in this case). - -```dotnetcli -const iterator = newMap.values(); -console.log(iterator); -[Map Iterator] { - { id: 1, name: 'Johnny' }, - { id: 2, name: 'Jane' }, - { id: 4, name: 'Alice' } -} -``` - -#### Remove duplicates from an array of objects by multiple properties - -https://www.javascripttutorial.net/array/javascript-remove-duplicates-from-array/ - -## How to make arrays mutable - -` const kidsName = ["Govind","Gopal","Pari","Kanhu","Aayu"] - -Object.freeze(kidsName) //Make it immutable, user can not edit/update values & add new element in array - -//If you try to add/update value of array, will throw TypeError kidsName.push("Lal"); kidsName[1] ="AB" ` - -`Output :` `TypeError: Cannot add property 5, object is not extensible at Array.push () at Object. (/home/runner/2wq0fv6bhic/index.js:6:10) at Module._compile (internal/modules/cjs/loader.js:999:30)` - -### Array - -**.length** use of the .length property of an array - this returns the number of elements in the array. - -`arrayName[arrayName.length - 1]` //get last element of an array - -`arrayName[arrayName.length - 1]` //update last element of an array - -A **method** in JavaScript is a function that's associated with certain values or objects. An example **.log()** method, which is part of the console object. - -**.push()** This method allows you to "push" a value to the end of an array. Here is an example to add the number 12 to the end of an array: - -`arrayName.push(12);` - -It returns the new length of the array, after adding the value you give it. If existing length was 2, after above push() operation, it will return value 3 which is new length of array. - -**.pop()** This method removes the last element from an array and returns that element. - -When a method returns a value, you can think of it as giving the value back to you, making it available for use in other parts of your code. - -## JavaScript Interview Question - -### What is JavaScript and what are its key features? - -### What is the difference between null and undefined in JavaScript? - -### Explain the concept of closures in JavaScript and provide an example. - -### What is the difference between let, const, and var in JavaScript for declaring variables? - -### What is the Event Loop in JavaScript and how does it work? - -### How does prototypal inheritance work in JavaScript? - -### Explain the concept of hoisting in JavaScript. - -### What are arrow functions in JavaScript? How do they differ from regular functions? - -### What are Promises in JavaScript and how do they handle asynchronous operations? - -### How does the this keyword work in JavaScript? Provide examples of different contexts where this can be used. - -### Explain the concept of event delegation in JavaScript. - -### What is the purpose of using the bind, call, and apply methods in JavaScript? - -### What is the difference between synchronous and asynchronous JavaScript? - -### How to explain Event loop and async js - -### How to explain Hoisting and temporal dead zone - -### How to explain scope and scope chain - -### How to explain prototypal inheritance and chaining - -### How to explain promises and queues - -### How to explain async await in interviews - -### How to answer closure and lexical scoping - -### How to answer THIS in interviews - -### How to explain call bind and apply in interviews - -## Coding Problem Using JavaScript - -#### Reverse a String - -``` -let str = "abhay"; -const reverseString = str.split("").reverse().join(""); -console.log(reverseString); -``` - -``` -//Reverse words in a sentence - -function reverseWords(value){ -//Step 1 : replace multiple whitespace with a single whitespace -//Step 2 : split string based on single whitespace & store output in array -let strTemp = value.replaceAll(/\s+/g," ").split(" "); -let result = ""; - -//Step 3 : Run a for loop & copy each element to string variable "result" -for (let iLoop = strTemp.length-1;iLoop>=0;iLoop-- ){ -result = result.concat(strTemp[iLoop]," "); -} -//trim spaces and return value -return result.trim(); - -} - -console.log(reverseWords("Shanvi is an engineer")) -console.log(reverseWords("Shanvi can code")) //sentence with multiple whitespace -console.log(reverseWords("Shanvi polyglot programmer")) -``` - -#### Sum of array elements - -``` -const numbers = [1, 3, 4, 5, 6]; -const sum = numbers.reduce((sum, curr) => sum + curr, 0); -console.log(sum); -``` - -#### Largest/Smallest number in array - -``` -console.log(Math.max(...numbers)); -console.log(Math.min(...numbers)); -``` - -#### Remove duplicates from an array - -``` -const duplicateNumbers = [2, 3, 5, 5, 6]; -const uniqueNumbers = [...new Set(duplicateNumbers)]; -console.log(uniqueNumbers); -``` - -#### Remove All Whitespace from a String in JavaScript - -To remove all whitespace from a string in JavaScript, call the replace() method on the string, passing a regular expression that matches any whitespace character, and an empty string as a replacement. For example, str.replace( /\s/g, '') returns a new string with all whitespace removed from str. he \s regex metacharacter matches whitespace characters, such as spaces, tabs, and newlines. - -We use the g regex flag to specify that all whitespace characters in the string should be matched. Without this flag, only the first whitespace will be matched and replaced: - -``` -const str = '1 2 3'; - -const whitespaceRemoved = str.replace(/\s/g, ''); -console.log(whitespaceRemoved); // 123 -``` - -### If you want to get the text that a user selects or highlights on a web page, there is a useful one-liner for that - -``` -const getSelectedText = () => window.getSelection().toString(); -console.log(getSelectedText); -``` - -### There is a method called scrollTo(x,y), it allows you to scroll to a particular set of used coordinates - -``` -const scrollToTop = () => window.scrollTo(0,0); - -``` - -### If you want to have a smooth scrolling animation - -``` -const Top = () => window.scrollTo({top:0, behavior:'smooth'}); - -``` - -### If you want to redirect the user to a specified location, you can do something like this - -``` -const urlRedirect = url => location.href = url; -urlRedirect('https://google.co.in'); - -``` - -### JS Common Interview Questions - -> #### JS -> -> ON File -> -> JSON a lso known as JavaScript Object Notation is a basic or standardized design used for the transportation and storage of data. It is a plain text file with an extension of .json, and a MIME type of application/json. It is a >lightwe ight data-interchange format. JSON is a self-describing format and it is easy to understand. - -`Syntax rules of JSON` - -- The data is in name/value pairs -- The data is separated by commas -- Curly braces hold objects -- Square brackets hold arrays - -`{'name': 'John', age: 31}` - -> ![NOTE] JSON Array - -``` -"users":[ -{"firstName":"John", "lastName":"Abrahm"}, -{"firstName":"Anna", "lastName":"Smith"}, -{"firstName":"Shane", "lastName":"Warn"} -] -``` - -##### Parsing: Converting a string to a native object - -When receiving the data from a web server, the data is always in a string format. You can convert this string value to a javascript object using parse() method. - -``` -var userString = '{"name":"John","age":31}'; -var userJSON = JSON.parse(userString); -console.log(userJSON);// {name: "John", age: 31} -``` - -##### Stringification: converting a native object to a string so it can be transmitted across the network - -When sending data to a web server, the data has to be in a string format. You can achieve this by converting JSON object into a string using stringify() method. - -``` ->var use ->rJSON = {'name': 'John', age: 31} -var userString = JSON.stringify(user); -console.log(userString); //"{"name":"John","age":31}" -``` - -##### Read JSON files in JavaScript - -- **Method 1. Using Required Module** - -``` -const dataJson = require('config.json'); -console.log(typeof dataJson); -console.log(dataJson); -``` - -- **Method 2. Using ES6 Import Module (Web Runtime Environment)** - -```import dataJson from 'config.json'; -document.getElementById('main').innerHTML = JSON.stringify(dataJson); -``` - -``` - -### Data Structure Introduction - -#### map - -``` - -const mapOne = new Map(); //declare a map - -//set value in map mapOne.set('a',1); mapOne.set('b',2); mapOne.set('c',3); - -//access value from map console.log(mapOne.get('a')); console.log(mapOne.get('b')); console.log(mapOne.get('c')); - -//size of map console.log('size : ', mapOne.size); - -//delete key/value from map mapOne.delete('a'); - -//size of map console.log('size after delete : ',mapOne.size); - -//ToDo // difference between map and object - -``` - -#### set - -``` - -//declare set const setOne = new Set([1,2,3]); - -``` - -#### Stack - -#### Queue - -#### Linked List - -#### Binary Trees - -#### Recursion - -#### Graph - -#### Dynamic Programming - -#### Amortized space time complexity practice - -### Sorting Algorithm - -#### Bubble sort - -#### Insertion sort - -#### Merge Sort - -#### Quick Sort - -#### Selection Sort - -## class and OOPs - -### OOPs - -it is a programming paradigm. - -### Object - -``` - -function multiplyBy5(num) { this.num = num; return num \* 5; } multiplyBy5.power = 2; console.log(multiplyBy5(5)); console.log(multiplyBy5.power); console.log(multiplyBy5.prototype); - -function createUser(username, price) { this.username = username; //this sets current context this.price = price; } - -createUser.prototype.increment = function () { this.price++; }; - -createUser.prototype.printMee = function () { console.log(`price is ${this.price}`); }; const chai = new createUser("chai", 25); const tea = new createUser("tea", 250); - -chai.printMee(); chai.increment(); - -/\* Here is what happens behind the scenes when the new keyword is used: - -A new object is created: the new keyword initiates the creation of a new JavaScript object. - -A prototype is linked: The newly created object gets linked to the prototype property of the constructor function. This means that it has access to properties and methods defined on the constructor's prototype. - -The constructor is called: The constructor function is called with the specified arguments and this is bound to the newly created object. If no explicit return value is specified from the constructor. JavaScript assumes this, the newly created object, to be the intended return value. - -The new object is returned: After the constructor function has been called, if it does not return a non-primitive value (object, array, function etc), the newly created object is returned. - -\*/ - -``` - -- collection of properties and methods -- - -### Why use OOP - -### parts of OOP - -### Object literal - -``` - -//what is object literal const user = { username: "hitesh", loginCount: 8, signedIn: true, getUserDetail: function () { //console.log("Got user details from database"); //console.log(`UserName : ${this.username}`); console.log(this); }, }; // console.log(user.loginCount); // console.log(user.getUserDetail()); //console.log(this); // {} - -function User(username, loginCount, isLoggedIn) { this.username = username; this.loginCount = loginCount; this.isLoggedIn = isLoggedIn; this.greetings = function () { console.log(`Welcome ${this.username}`); }; return this; //not mandatory to write this. JavaScript implicitly returns } - -//new keyword generates a new empty object const userOne = new User("Abhay", 12, true); const userTwo = new User("Ajay", 8, true); console.log(userOne.constructor); console.log(userOne instanceof User); //return true // console.log(userTwo); //Prototypal inheritance - -``` - -- Constructor function - -### Prototype - -``` - -let myName = "Abhay "; console.log(myName.length); - -let myHeroes = ["thor", "spiderman"]; - -let heroPower = { thor: "hammer", spiderman: "sling", getSpiderPower: function () { console.log(`Spidy power is ${this.spiderman}`); }, }; - -//added a new property in Object, now this is available in all objects/array Object.prototype.hitesh = function () { console.log(`hitesh is present in all object`); }; heroPower.hitesh(); myHeroes.hitesh(); - -Array.prototype.heyHitesh = function () { console.log(`Hitesh says hello`); }; myHeroes.heyHitesh(); //heroPower.heyHitesh(); heyHitesh is defined at array level, can't be accessed at object level - -//inheritance - -const user = { name: "chai", email: "chai@gmail.com", }; const Teacher = { makeVideo: true, }; - -const TeachingSupport = { isAvailable: false, }; const TASupport = { makeAssignment: "JS Assignment", fullTime: true, **proto**: TeachingSupport, }; - -//Teacher.**proto** = User; //old/outdated approach - -//modern syntax Object.setPrototypeOf(TeachingSupport, Teacher); - -let anotherUserName = "ChaiAutCode "; String.prototype.trueLength = function () { console.log(`${this}`); console.log(`True length is : ${this.trim().length}`); }; anotherUserName.trueLength(); "abhay".trueLength(); - -``` - -- Classes -- Instances (new, this) - -### 4 pillars - -- Abstraction -- Encapsulation -- Inheritance -- Polymorphism - -## DOM - - - - - - - Chai Aur Code - - -
    -
  • JavaScript
  • -
- - - - - - - - - - DOM Learning - - - - -
-

- DOM Learning on Chai aur Code - text text -

-

Lorem ipsum dolor sit amet

-

Lorem ipsum dolor sit amet

-

Lorem ipsum dolor sit amet

-

Lorem ipsum dolor sit amet

-

- Lorem ipsum dolor sit amet consectetur, adipisicing elit. Autem nihil, - maiores suscipit dolor error ad ratione dicta deleniti saepe quidem quia - numquam voluptatum similique quae in soluta reiciendis molestias - expedita! -

- -
    -
  • one
  • -
  • two
  • -
  • three
  • -
  • four
  • -
-
- - - - - - - - - - Chai Aut Code - - - - - - - - - - - Document - - -
- -
Monday
-
Tuesday
-
Wednesday
-
Thursday
-
- - - -``` diff --git a/Notes/playwright_cheatsheet.md b/Notes/playwright_cheatsheet.md deleted file mode 100644 index 2407be6..0000000 --- a/Notes/playwright_cheatsheet.md +++ /dev/null @@ -1,75 +0,0 @@ -# Playwright - -## Setup & Installation - -- NodeJs -- Aqua/IntelliJ/Visual Studio Code -- @playwright/test package (`npm init playwright@latest`) - - - What is installed - - - playwright.config.ts - - package.json - - package-lock.json - - tests/ - - example.spec.ts - - tests-examples/ - - demo-todo-app.spec.ts - -> ![NOTES] The `playwright.config.js/ts` is where you can add configuration for Playwright including modifying which browsers you would like to run Playwright on. - -## Updating Playwright version - -To update Playwright to the latest version run the following command: - -``` -npm install -D @playwright/test@latest - -npx playwright install --with-deps -``` - -Check version of Playwright: - -``` -npx playwright --version -``` - -## How to run Example Test - -`npx playwright test` - -## How to run Example Test in UI mode - -`npx playwright test --ui` - -## How to see report - -`npx playwright show-report` - -## npm vs npx - what's the difference - -## Why playwright - -- supports JS/TS/Java/C#/Python -- Built by Microsoft -- Fast -- Parallel Execution -- Trace Viewer, Inspector, codegen, video - -## npx playwright codegen - -## run playwright test - -## execution command - -`npx playwright test` Runs the end-to-end tests. - -`npx playwright test --ui` Starts the interactive UI mode. - -`npx playwright test --project=chromium` Runs the tests only on Desktop Chrome. - -`npx playwright test example` Runs the tests in a specific file. - -`npx playwright test --debug` Runs the tests in debug mode. - -`npx playwright codegen` Auto generate tests with Codegen. diff --git a/Notes/promise.png b/Notes/promise.png deleted file mode 100644 index 6c3678d..0000000 Binary files a/Notes/promise.png and /dev/null differ diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 034e848..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,21 +0,0 @@ -# Security Policy - -## Supported Versions - -Use this section to tell people about which versions of your project are -currently being supported with security updates. - -| Version | Supported | -| ------- | ------------------ | -| 5.1.x | :white_check_mark: | -| 5.0.x | :x: | -| 4.0.x | :white_check_mark: | -| < 4.0 | :x: | - -## Reporting a Vulnerability - -Use this section to tell people how to report a vulnerability. - -Tell them where to go, how often they can expect to get an update on a -reported vulnerability, what to expect if the vulnerability is accepted or -declined, etc. diff --git a/environments/dev.env b/environments/dev.env new file mode 100644 index 0000000..e69de29 diff --git a/environments/local.env b/environments/local.env new file mode 100644 index 0000000..e69de29 diff --git a/environments/qe.env b/environments/qe.env new file mode 100644 index 0000000..e69de29 diff --git a/notes.txt b/notes.txt deleted file mode 100644 index 01888dd..0000000 --- a/notes.txt +++ /dev/null @@ -1,3 +0,0 @@ -### Further Reading - -https://medium.com/@oroz.askarov/building-a-robust-automation-framework-in-playwright-typescript-version-b13be4e4bf56 https://github.com/alapanme/Playwright-Automation/blob/master/tests/2-checkBox.spec.ts diff --git a/package-lock.json b/package-lock.json index f052061..9c497c6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,15 +24,15 @@ "devDependencies": { "@playwright/test": "^1.44.1", "@types/node": "^20.11.5", - "@typescript-eslint/eslint-plugin": "^6.18.1", - "@typescript-eslint/parser": "^6.18.1", - "eslint": "^8.2.0", + "@typescript-eslint/eslint-plugin": "^6.21.0", + "@typescript-eslint/parser": "^6.21.0", + "eslint": "^8.57.0", "eslint-config-airbnb-base": "^15.0.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-import": "^2.25.2", - "eslint-plugin-prettier": "^5.1.3", - "prettier": "^3.1.1", - "typescript": "^5.3.3" + "eslint-plugin-prettier": "^5.2.1", + "prettier": "^3.3.3", + "typescript": "^5.5.4" } }, "node_modules/@aashutoshrathi/word-wrap": { @@ -689,14 +689,14 @@ } }, "node_modules/@eslint/eslintrc": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-1.4.1.tgz", - "integrity": "sha512-XXrH9Uarn0stsyldqDYq8r++mROmWRI1xKMXa640Bb//SY1+ECYX6VzT6Lcx5frD0V30XieqJ0oX9I2Xj5aoMA==", + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.4.tgz", + "integrity": "sha512-269Z39MS6wVJtsoUl10L60WdkhJVdPG24Q4eZTH3nnF6lpvSShEK3wQjDX9JRWAUPvPh7COouPpU9IrqaZFvtQ==", "dev": true, "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.4.0", + "espree": "^9.6.0", "globals": "^13.19.0", "ignore": "^5.2.0", "import-fresh": "^3.2.1", @@ -755,15 +755,25 @@ "node": "*" } }, + "node_modules/@eslint/js": { + "version": "8.57.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.57.0.tgz", + "integrity": "sha512-Ys+3g2TaW7gADOJzPt83SJtCDhMjndcDMFVQ/Tj9iA1BfJzFKD9mAUXT3OenpuPHbI6P/myECxRJrofUsDx/5g==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + } + }, "node_modules/@humanwhocodes/config-array": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.6.0.tgz", - "integrity": "sha512-JQlEKbcgEUjBFhLIF4iqM7u/9lwgHRBcpHrmUNCALK0Q3amXN6lxdoXLnF0sm11E9VqTmBALR87IlUg1bZ8A9A==", + "version": "0.11.14", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.14.tgz", + "integrity": "sha512-3T8LkOmg45BV5FICb15QQMsyUSWrQ8AygVfC7ZG32zOalnqrilm018ZVCw0eapXux8FtA33q8PSRSstjee3jSg==", + "deprecated": "Use @eslint/config-array instead", "dev": true, "dependencies": { - "@humanwhocodes/object-schema": "^1.2.0", - "debug": "^4.1.1", - "minimatch": "^3.0.4" + "@humanwhocodes/object-schema": "^2.0.2", + "debug": "^4.3.1", + "minimatch": "^3.0.5" }, "engines": { "node": ">=10.10.0" @@ -791,10 +801,24 @@ "node": "*" } }, + "node_modules/@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true, + "engines": { + "node": ">=12.22" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, "node_modules/@humanwhocodes/object-schema": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", - "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.3.tgz", + "integrity": "sha512-93zYdMES/c1D69yZiKDBj0V24vqNzB/koF26KPaagAfd3P/4gUlh3Dys5ogAK+Exi9QyzlD8x/08Zt7wIKcDcA==", + "deprecated": "Use @eslint/object-schema instead", "dev": true }, "node_modules/@img/sharp-darwin-arm64": { @@ -1384,9 +1408,9 @@ } }, "node_modules/@pkgr/core": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.1.0.tgz", - "integrity": "sha512-Zwq5OCzuwJC2jwqmpEQt7Ds1DTi6BWSwoGkbb1n9pO3hzb35BoJELx7c0T23iDkBGkh2e7tvOtjF3tr3OaQHDQ==", + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.1.1.tgz", + "integrity": "sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA==", "dev": true, "engines": { "node": "^12.20.0 || ^14.18.0 || >=16.0.0" @@ -1879,16 +1903,16 @@ } }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "6.18.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.18.1.tgz", - "integrity": "sha512-nISDRYnnIpk7VCFrGcu1rnZfM1Dh9LRHnfgdkjcbi/l7g16VYRri3TjXi9Ir4lOZSw5N/gnV/3H7jIPQ8Q4daA==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.21.0.tgz", + "integrity": "sha512-oy9+hTPCUFpngkEZUSzbf9MxI65wbKFoQYsgPdILTfbUldp5ovUuphZVe4i30emU9M/kP+T64Di0mxl7dSw3MA==", "dev": true, "dependencies": { "@eslint-community/regexpp": "^4.5.1", - "@typescript-eslint/scope-manager": "6.18.1", - "@typescript-eslint/type-utils": "6.18.1", - "@typescript-eslint/utils": "6.18.1", - "@typescript-eslint/visitor-keys": "6.18.1", + "@typescript-eslint/scope-manager": "6.21.0", + "@typescript-eslint/type-utils": "6.21.0", + "@typescript-eslint/utils": "6.21.0", + "@typescript-eslint/visitor-keys": "6.21.0", "debug": "^4.3.4", "graphemer": "^1.4.0", "ignore": "^5.2.4", @@ -1914,15 +1938,15 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "6.18.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.18.1.tgz", - "integrity": "sha512-zct/MdJnVaRRNy9e84XnVtRv9Vf91/qqe+hZJtKanjojud4wAVy/7lXxJmMyX6X6J+xc6c//YEWvpeif8cAhWA==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.21.0.tgz", + "integrity": "sha512-tbsV1jPne5CkFQCgPBcDOt30ItF7aJoZL997JSF7MhGQqOeT3svWRYxiqlfA5RUdlHN6Fi+EI9bxqbdyAUZjYQ==", "dev": true, "dependencies": { - "@typescript-eslint/scope-manager": "6.18.1", - "@typescript-eslint/types": "6.18.1", - "@typescript-eslint/typescript-estree": "6.18.1", - "@typescript-eslint/visitor-keys": "6.18.1", + "@typescript-eslint/scope-manager": "6.21.0", + "@typescript-eslint/types": "6.21.0", + "@typescript-eslint/typescript-estree": "6.21.0", + "@typescript-eslint/visitor-keys": "6.21.0", "debug": "^4.3.4" }, "engines": { @@ -1942,13 +1966,13 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "6.18.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.18.1.tgz", - "integrity": "sha512-BgdBwXPFmZzaZUuw6wKiHKIovms97a7eTImjkXCZE04TGHysG+0hDQPmygyvgtkoB/aOQwSM/nWv3LzrOIQOBw==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.21.0.tgz", + "integrity": "sha512-OwLUIWZJry80O99zvqXVEioyniJMa+d2GrqpUTqi5/v5D5rOrppJVBPa0yKCblcigC0/aYAzxxqQ1B+DS2RYsg==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.18.1", - "@typescript-eslint/visitor-keys": "6.18.1" + "@typescript-eslint/types": "6.21.0", + "@typescript-eslint/visitor-keys": "6.21.0" }, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -1959,13 +1983,13 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "6.18.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.18.1.tgz", - "integrity": "sha512-wyOSKhuzHeU/5pcRDP2G2Ndci+4g653V43gXTpt4nbyoIOAASkGDA9JIAgbQCdCkcr1MvpSYWzxTz0olCn8+/Q==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.21.0.tgz", + "integrity": "sha512-rZQI7wHfao8qMX3Rd3xqeYSMCL3SoiSQLBATSiVKARdFGCYSRvmViieZjqc58jKgs8Y8i9YvVVhRbHSTA4VBag==", "dev": true, "dependencies": { - "@typescript-eslint/typescript-estree": "6.18.1", - "@typescript-eslint/utils": "6.18.1", + "@typescript-eslint/typescript-estree": "6.21.0", + "@typescript-eslint/utils": "6.21.0", "debug": "^4.3.4", "ts-api-utils": "^1.0.1" }, @@ -1986,9 +2010,9 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "6.18.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.18.1.tgz", - "integrity": "sha512-4TuMAe+tc5oA7wwfqMtB0Y5OrREPF1GeJBAjqwgZh1lEMH5PJQgWgHGfYufVB51LtjD+peZylmeyxUXPfENLCw==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.21.0.tgz", + "integrity": "sha512-1kFmZ1rOm5epu9NZEZm1kckCDGj5UJEf7P1kliH4LKu/RkwpsfqqGmY2OOcUs18lSlQBKLDYBOGxRVtrMN5lpg==", "dev": true, "engines": { "node": "^16.0.0 || >=18.0.0" @@ -1999,13 +2023,13 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "6.18.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.18.1.tgz", - "integrity": "sha512-fv9B94UAhywPRhUeeV/v+3SBDvcPiLxRZJw/xZeeGgRLQZ6rLMG+8krrJUyIf6s1ecWTzlsbp0rlw7n9sjufHA==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.21.0.tgz", + "integrity": "sha512-6npJTkZcO+y2/kr+z0hc4HwNfrrP4kNYh57ek7yCNlrBjWQ1Y0OS7jiZTkgumrvkX5HkEKXFZkkdFNkaW2wmUQ==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.18.1", - "@typescript-eslint/visitor-keys": "6.18.1", + "@typescript-eslint/types": "6.21.0", + "@typescript-eslint/visitor-keys": "6.21.0", "debug": "^4.3.4", "globby": "^11.1.0", "is-glob": "^4.0.3", @@ -2027,17 +2051,17 @@ } }, "node_modules/@typescript-eslint/utils": { - "version": "6.18.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.18.1.tgz", - "integrity": "sha512-zZmTuVZvD1wpoceHvoQpOiewmWu3uP9FuTWo8vqpy2ffsmfCE8mklRPi+vmnIYAIk9t/4kOThri2QCDgor+OpQ==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.21.0.tgz", + "integrity": "sha512-NfWVaC8HP9T8cbKQxHcsJBY5YE1O33+jpMwN45qzWWaPDZgLIbo12toGMWnmhvCpd3sIxkpDw3Wv1B3dYrbDQQ==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.4.0", "@types/json-schema": "^7.0.12", "@types/semver": "^7.5.0", - "@typescript-eslint/scope-manager": "6.18.1", - "@typescript-eslint/types": "6.18.1", - "@typescript-eslint/typescript-estree": "6.18.1", + "@typescript-eslint/scope-manager": "6.21.0", + "@typescript-eslint/types": "6.21.0", + "@typescript-eslint/typescript-estree": "6.21.0", "semver": "^7.5.4" }, "engines": { @@ -2052,12 +2076,12 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "6.18.1", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.18.1.tgz", - "integrity": "sha512-/kvt0C5lRqGoCfsbmm7/CwMqoSkY3zzHLIjdhHZQW3VFrnz7ATecOHR7nb7V+xn4286MBxfnQfQhAmCI0u+bJA==", + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.21.0.tgz", + "integrity": "sha512-JJtkDduxLi9bivAB+cYOVMtbkqdPOhZ+ZI5LC47MIRrDV4Yn2o+ZnW10Nkmr28xRpSpdJ6Sm42Hjf2+REYXm0A==", "dev": true, "dependencies": { - "@typescript-eslint/types": "6.18.1", + "@typescript-eslint/types": "6.21.0", "eslint-visitor-keys": "^3.4.1" }, "engines": { @@ -2068,6 +2092,12 @@ "url": "https://opencollective.com/typescript-eslint" } }, + "node_modules/@ungap/structured-clone": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz", + "integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==", + "dev": true + }, "node_modules/@wdio/config": { "version": "8.28.0", "resolved": "https://registry.npmjs.org/@wdio/config/-/config-8.28.0.tgz", @@ -2296,15 +2326,6 @@ } } }, - "node_modules/ansi-colors": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.3.tgz", - "integrity": "sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==", - "dev": true, - "engines": { - "node": ">=6" - } - }, "node_modules/ansi-regex": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", @@ -2842,11 +2863,11 @@ } }, "node_modules/braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dependencies": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" }, "engines": { "node": ">=8" @@ -3730,19 +3751,6 @@ "once": "^1.4.0" } }, - "node_modules/enquirer": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.4.1.tgz", - "integrity": "sha512-rRqJg/6gd538VHvR3PSrdRBb/1Vy2YfzHqzvbhGIQpDRKIa4FgV/54b5Q1xYSxOOwKvjXweS26E0Q+nAMwp2pQ==", - "dev": true, - "dependencies": { - "ansi-colors": "^4.1.1", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8.6" - } - }, "node_modules/error-ex": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", @@ -3894,49 +3902,49 @@ } }, "node_modules/eslint": { - "version": "8.2.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.2.0.tgz", - "integrity": "sha512-erw7XmM+CLxTOickrimJ1SiF55jiNlVSp2qqm0NuBWPtHYQCegD5ZMaW0c3i5ytPqL+SSLaCxdvQXFPLJn+ABw==", - "dev": true, - "dependencies": { - "@eslint/eslintrc": "^1.0.4", - "@humanwhocodes/config-array": "^0.6.0", - "ajv": "^6.10.0", + "version": "8.57.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.0.tgz", + "integrity": "sha512-dZ6+mexnaTIbSBZWgou51U6OmzIhYM2VcNdtiTtI7qPNZm35Akpr0f6vtw3w1Kmn5PYo+tZVfh13WrhpS6oLqQ==", + "dev": true, + "dependencies": { + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.6.1", + "@eslint/eslintrc": "^2.1.4", + "@eslint/js": "8.57.0", + "@humanwhocodes/config-array": "^0.11.14", + "@humanwhocodes/module-importer": "^1.0.1", + "@nodelib/fs.walk": "^1.2.8", + "@ungap/structured-clone": "^1.2.0", + "ajv": "^6.12.4", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", "debug": "^4.3.2", "doctrine": "^3.0.0", - "enquirer": "^2.3.5", "escape-string-regexp": "^4.0.0", - "eslint-scope": "^6.0.0", - "eslint-utils": "^3.0.0", - "eslint-visitor-keys": "^3.0.0", - "espree": "^9.0.0", - "esquery": "^1.4.0", + "eslint-scope": "^7.2.2", + "eslint-visitor-keys": "^3.4.3", + "espree": "^9.6.1", + "esquery": "^1.4.2", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", "file-entry-cache": "^6.0.1", - "functional-red-black-tree": "^1.0.1", - "glob-parent": "^6.0.1", - "globals": "^13.6.0", - "ignore": "^4.0.6", - "import-fresh": "^3.0.0", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "globals": "^13.19.0", + "graphemer": "^1.4.0", + "ignore": "^5.2.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", + "is-path-inside": "^3.0.3", "js-yaml": "^4.1.0", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.4.1", "lodash.merge": "^4.6.2", - "minimatch": "^3.0.4", + "minimatch": "^3.1.2", "natural-compare": "^1.4.0", - "optionator": "^0.9.1", - "progress": "^2.0.0", - "regexpp": "^3.2.0", - "semver": "^7.2.1", + "optionator": "^0.9.3", "strip-ansi": "^6.0.1", - "strip-json-comments": "^3.1.0", - "text-table": "^0.2.0", - "v8-compile-cache": "^2.0.3" + "text-table": "^0.2.0" }, "bin": { "eslint": "bin/eslint.js" @@ -4111,13 +4119,13 @@ "dev": true }, "node_modules/eslint-plugin-prettier": { - "version": "5.1.3", - "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.1.3.tgz", - "integrity": "sha512-C9GCVAs4Eq7ZC/XFQHITLiHJxQngdtraXaM+LoUFoFp/lHNl2Zn8f3WQbe9HvTBBQ9YnKFB0/2Ajdqwo5D1EAw==", + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.2.1.tgz", + "integrity": "sha512-gH3iR3g4JfF+yYPaJYkN7jEl9QbweL/YfkoRlNnuIEHEz1vHVlCmWOS+eGGiRuzHQXdJFCOTxRgvju9b8VUmrw==", "dev": true, "dependencies": { "prettier-linter-helpers": "^1.0.0", - "synckit": "^0.8.6" + "synckit": "^0.9.1" }, "engines": { "node": "^14.18.0 || >=16.0.0" @@ -4141,9 +4149,9 @@ } }, "node_modules/eslint-scope": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-6.0.0.tgz", - "integrity": "sha512-uRDL9MWmQCkaFus8RF5K9/L/2fn+80yoW3jkD53l4shjCh26fCtvJGasxjUqP5OT87SYTxCVA3BwTUzuELx9kA==", + "version": "7.2.2", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", + "integrity": "sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==", "dev": true, "dependencies": { "esrecurse": "^4.3.0", @@ -4151,33 +4159,9 @@ }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - } - }, - "node_modules/eslint-utils": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz", - "integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==", - "dev": true, - "dependencies": { - "eslint-visitor-keys": "^2.0.0" - }, - "engines": { - "node": "^10.0.0 || ^12.0.0 || >= 14.0.0" }, "funding": { - "url": "https://github.com/sponsors/mysticatea" - }, - "peerDependencies": { - "eslint": ">=5" - } - }, - "node_modules/eslint-utils/node_modules/eslint-visitor-keys": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", - "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", - "dev": true, - "engines": { - "node": ">=10" + "url": "https://opencollective.com/eslint" } }, "node_modules/eslint-visitor-keys": { @@ -4218,15 +4202,6 @@ "concat-map": "0.0.1" } }, - "node_modules/eslint/node_modules/ignore": { - "version": "4.0.6", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-4.0.6.tgz", - "integrity": "sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg==", - "dev": true, - "engines": { - "node": ">= 4" - } - }, "node_modules/eslint/node_modules/json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", @@ -4494,9 +4469,9 @@ "dev": true }, "node_modules/fastq": { - "version": "1.16.0", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.16.0.tgz", - "integrity": "sha512-ifCoaXsDrsdkWTtiNJX5uzHDsrck5TzfKKDcuFFTIrrc/BS076qgEIfoIy1VeZqViznfKiysPYTh/QeHtnIsYA==", + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.17.1.tgz", + "integrity": "sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==", "dev": true, "dependencies": { "reusify": "^1.0.4" @@ -4572,9 +4547,9 @@ } }, "node_modules/fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "dependencies": { "to-regex-range": "^5.0.1" }, @@ -4865,12 +4840,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/functional-red-black-tree": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz", - "integrity": "sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g==", - "dev": true - }, "node_modules/functions-have-names": { "version": "1.2.3", "resolved": "https://registry.npmjs.org/functions-have-names/-/functions-have-names-1.2.3.tgz", @@ -5694,6 +5663,15 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-path-inside": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", + "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/is-plain-obj": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-4.1.0.tgz", @@ -6239,12 +6217,12 @@ } }, "node_modules/micromatch": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", - "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.7.tgz", + "integrity": "sha512-LPP/3KorzCwBxfeUuZmaR6bG2kdeHSbe0P2tY3FLRU4vYrjYz5hI4QZwV0njUx3jeuKe67YukQ1LSPZBKDqO/Q==", "dev": true, "dependencies": { - "braces": "^3.0.2", + "braces": "^3.0.3", "picomatch": "^2.3.1" }, "engines": { @@ -7183,9 +7161,9 @@ } }, "node_modules/prettier": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.1.1.tgz", - "integrity": "sha512-22UbSzg8luF4UuZtzgiUOfcGM8s4tjBv6dJRT7j275NXsy2jb4aJa4NNveul5x4eqlF1wuhuR2RElK71RvmVaw==", + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.3.tgz", + "integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==", "dev": true, "bin": { "prettier": "bin/prettier.cjs" @@ -7570,18 +7548,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/regexpp": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", - "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", - "dev": true, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/mysticatea" - } - }, "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -8405,9 +8371,9 @@ } }, "node_modules/synckit": { - "version": "0.8.8", - "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.8.8.tgz", - "integrity": "sha512-HwOKAP7Wc5aRGYdKH+dw0PRRpbO841v2DENBtjnR5HFWoiNByAl7vrx3p0G/rCyYXQsrxqtX48TImFtPcIHSpQ==", + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.9.1.tgz", + "integrity": "sha512-7gr8p9TQP6RAHusBOSLs46F4564ZrjV8xFmw5zCmgmhGUcw2hxsShhJ6CEiHQMgPDwAQ1fWHPM0ypc4RMAig4A==", "dev": true, "dependencies": { "@pkgr/core": "^0.1.0", @@ -8705,9 +8671,9 @@ } }, "node_modules/typescript": { - "version": "5.3.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.3.tgz", - "integrity": "sha512-pXWcraxM0uxAS+tN0AG/BF2TyqmHO014Z070UsJ+pFvYuRSq8KH8DmWpnbXe0pEPDHXZV3FcAbJkijJ5oNEnWw==", + "version": "5.5.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz", + "integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==", "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -8864,12 +8830,6 @@ "uuid": "dist/bin/uuid" } }, - "node_modules/v8-compile-cache": { - "version": "2.4.0", - "resolved": "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.4.0.tgz", - "integrity": "sha512-ocyWc3bAHBB/guyqJQVI5o4BZkPhznPYUG2ea80Gond/BgNWpap8TOmLSeeQG7bnh2KMISxskdADG59j7zruhw==", - "dev": true - }, "node_modules/v8-compile-cache-lib": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", diff --git a/package.json b/package.json index 733ec35..ba1fb75 100644 --- a/package.json +++ b/package.json @@ -15,15 +15,15 @@ "devDependencies": { "@playwright/test": "^1.44.1", "@types/node": "^20.11.5", - "@typescript-eslint/eslint-plugin": "^6.18.1", - "@typescript-eslint/parser": "^6.18.1", - "eslint": "^8.2.0", + "@typescript-eslint/eslint-plugin": "^6.21.0", + "@typescript-eslint/parser": "^6.21.0", + "eslint": "^8.57.0", "eslint-config-airbnb-base": "^15.0.0", "eslint-config-prettier": "^9.1.0", "eslint-plugin-import": "^2.25.2", - "eslint-plugin-prettier": "^5.1.3", - "prettier": "^3.1.1", - "typescript": "^5.3.3" + "eslint-plugin-prettier": "^5.2.1", + "prettier": "^3.3.3", + "typescript": "^5.5.4" }, "dependencies": { "@types/mocha": "^10.0.6", diff --git a/src/globals/global-setup.ts b/src/globals/global-setup.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/globals/global-teardown.ts b/src/globals/global-teardown.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/globals/healthcheck.setup.ts b/src/globals/healthcheck.setup.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/utils/constants.ts b/src/utils/constants.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/utils/dbUtils.ts b/src/utils/dbUtils.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/utils/utils.ts b/src/utils/utils.ts new file mode 100644 index 0000000..e69de29