Skip to content

Commit cab041a

Browse files
Jest added
1 parent ede8c4b commit cab041a

File tree

3,596 files changed

+414897
-84
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,596 files changed

+414897
-84
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
./node_modules
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// Example - https://www.dofactory.com/javascript/design-patterns/observer#:~:text=The%20Observer%20pattern%20offers%20a,design%20and%20promotes%20loose%20coupling
2+
// Generators - They don't compute values all at the same time
3+
4+
// Using Normal function -- You don't have enoug memory to allocated all the memory's
5+
// function range(upperbound) {
6+
// const result = [];
7+
// for(let i = 0; i < upperbound; i++) {
8+
// result.push(i);
9+
// }
10+
// return result;
11+
// }
12+
13+
// console.log(range(1000000000))
14+
15+
16+
// Using generator using In memory using i
17+
// next() also the part of generators
18+
// function* range(upperbound) {
19+
// for(let i = 0; i < upperbound; i++) {
20+
// yield i;
21+
// }
22+
// }
23+
24+
// for(const e1 of range(1000000000)) {
25+
// console.log(e1);
26+
// }
27+
28+
29+
// Observer using next
30+
// function* gen() {
31+
// console.log('Started');
32+
// try {
33+
// let str = `1. ${yield}`;
34+
// console.log(str);
35+
// } catch(e) {
36+
// console.log('Caught Error');
37+
// }
38+
// console.log(`1. ${yield}`); // yield told me to pause or suspand
39+
// console.log(`2. ${yield}`); // yield told me to pause or suspand
40+
// console.log(`3. ${yield}`); // yield told me to pause or suspand
41+
// return 'result';
42+
// }
43+
44+
// const genObj = gen();
45+
46+
// Normal way without error
47+
// genObj.next();
48+
// genObj.next('Atique');
49+
// genObj.next('sunny');
50+
// genObj.next('atique');
51+
// genObj.next('sonu');
52+
// genObj.next('sonu111');
53+
54+
55+
// Caught Error --
56+
57+
// console.log(genObj.next());
58+
// console.log(genObj.throw(new Error('error')));
59+
60+
61+
// console.log(genObj.next('sunny1'))
62+
// console.log(genObj.next('sunny2'))
63+
// console.log(genObj.next('sunny3'))
64+
// console.log(genObj.next('sunny4'))
65+
// console.log(genObj.return('sunny4'))

Javascript/AdvancedLevel/index.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const obj = {};
2+
3+
const memorizeFunction = (key) => {
4+
if(obj[key]) {
5+
console.log('Return from Cache', obj[key]);
6+
return obj[key];
7+
} else {
8+
let value = key.split('-');
9+
obj[key] = parseInt(value[0]) + parseInt(value[1]);
10+
return obj[key];
11+
}
12+
}
13+
14+
const sum = (a, b) => {
15+
let keyPair = a+"-"+b;
16+
let result = memorizeFunction(keyPair);
17+
return result;
18+
}
19+
20+
21+
22+
console.log("Sum:", sum(5, 6));
23+
console.log("Sum:", sum(5, 6));
24+
console.log("Sum:", sum(6, 6));
25+

Javascript/AdvancedLevel/map.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// Javascript Map
2+
const chalk = require('chalk');
3+
4+
const map = new Map();
5+
6+
map.set('foo', 123);
7+
// console.log(chalk.gray("Map values:"), map.get('foo'));
8+
9+
// console.log(chalk.green("Map has:"), map.has('foo')); // True
10+
11+
// console.log(chalk.red("Map Delete:"), map.delete('foo')); // True
12+
13+
// console.log(chalk.blue("Map has:"), map.has('foo')); // False
14+
15+
// Javascipt Map vs Object
16+
17+
// Object Concept --
18+
19+
// let obj = {};
20+
21+
// adding properties to a object
22+
// obj.prop1 = 1;
23+
// obj[2] = 2;
24+
25+
// getting nr of properties of the object
26+
// console.log(Object.keys(obj).length)
27+
28+
// deleting a property
29+
// delete obj[2]
30+
31+
// console.log(obj)
32+
33+
// Map Concept --
34+
35+
const myMap = new Map();
36+
37+
const keyString = 'a string',
38+
keyObj = {},
39+
keyFunc = function() {};
40+
41+
// setting the values
42+
myMap.set(keyString, "value associated with 'a string'");
43+
myMap.set(keyObj, 'value associated with keyObj');
44+
myMap.set(keyFunc, 'value associated with keyFunc');
45+
46+
// console.log(myMap.size); // 3
47+
48+
// getting the values
49+
console.log("--->", myMap.get(keyString)); // "value associated with 'a string'"
50+
console.log(myMap.get(keyObj)); // "value associated with keyObj"
51+
console.log(myMap.get(keyFunc)); // "value associated with keyFunc"
52+
53+
console.log(myMap.get('a string')); // "value associated with 'a string'"
54+
// because keyString === 'a string'
55+
console.log(myMap.get({})); // undefined, because keyObj !== {}
56+
console.log(myMap.get(function() {})) // undefined, because keyFunc !== function () {}
57+
58+
59+
60+
// Main diffrence Accidental Keys --- Like in the Object --
61+
// If we do obj['foo'] = '123'
62+
// Again obj['foo'] = '1234' // this will replace the previous record

Javascript/AdvancedLevel/proxy.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Using Number
2+
3+
// const abc = 11;
4+
// let abcHandler;
5+
6+
// const proxyNumber = new Proxy(abc, abcHandler);
7+
// console.log(proxyNumber);
8+
9+
// Using object
10+
// const target = {
11+
// name: 'Atique'
12+
// }
13+
14+
// const handler = {};
15+
// const proxy = new Proxy(target, handler);
16+
17+
// console.log(proxy.name)

Javascript/AdvancedLevel/set.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Javascipt Set
2+
3+
// In ES5 Array lot of things are not possible which solved the Set concept, has been introduce in set
4+
// You can store Arbitary Value inside set
5+
6+
// const arr = [NaN];
7+
8+
// console.log(arr.indexOf('NaN'))
9+
10+
11+
// const set = new Set();
12+
13+
// set.add('red');
14+
// set.add('blue');
15+
// set.add('yellow');
16+
// set.add('yellow');
17+
18+
// console.log(set.has('red'));
19+
// console.log(set);
20+
21+
// const setEntries = new Set(['apple', 'bowl', 'cat']);
22+
// const mapEntries = new Map(setEntries.entries());
23+
// console.log(mapEntries)

node_modules/.bin/browserslist

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/esparse

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/esvalidate

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/.bin/import-local-fixture

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)