This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
/** | |
* Hypertext Transfer Protocol (HTTP) response status codes. | |
* @see {@link https://en.wikipedia.org/wiki/List_of_HTTP_status_codes} | |
*/ | |
enum HttpStatusCode { | |
/** | |
* The server has received the request headers and the client should proceed to send the request body |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
class AsyncComponent extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
isLoading: true, | |
component: null, | |
error: null | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Source: https://stackoverflow.com/questions/42921220/is-any-solution-to-do-localstorage-setitem-in-asynchronous-way-in-javascript | |
// localStorage is a synchronous API. You could defer the setItem method execution with the Promise object, giving them an asynchronous behaviour: | |
const asyncLocalStorage = { | |
setItem: function (key, value) { | |
return Promise.resolve().then(function () { | |
localStorage.setItem(key, value); | |
}); | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://twitter.com/wesbos/status/1063515277911052290/photo/1 | |
async function soFetch(input, settings = {}) { | |
const response = await fetch(input, { | |
headers: { | |
Accept: 'application/json, text/plain, */*', | |
'Content-Type': 'application/json' | |
}, | |
...settings | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"date": "2020-01-01", | |
"events": [ | |
{ | |
"name": "Meeting with Ivan", | |
"time": "2020-01-01 09:28:13 +0530", | |
"duration_minutes": 15, | |
"accepted": false | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default { | |
pageTitle: 'iPhone 12', | |
results: [ | |
{ | |
id: Date.now(), | |
imageSrc: 'https://rukminim1.flixcart.com/image/300/350/kg8avm80/mobile/y/7/n/apple-iphone-12-dummyapplefsn-original-imafwg8dqq7z8cgh.jpeg?q=90', | |
title: 'Apple iPhone 12 (White, 128 GB)', | |
rating: { | |
value: 4.7, | |
count: 545 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default { | |
pageTitle: 'iPhone 12 64 GB', | |
product: { | |
id: Date.now(), | |
imageSrc: 'https://rukminim1.flixcart.com/image/300/350/kg8avm80/mobile/y/7/n/apple-iphone-12-dummyapplefsn-original-imafwg8dqq7z8cgh.jpeg?q=90', | |
title: 'Apple iPhone 12 (White, 128 GB)', | |
rating: { | |
value: 4.7, | |
count: 545 | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://codepen.io/bradtraversy/pen/Bwapow | |
var form = document.getElementById('addForm'); | |
var itemList = document.getElementById('items'); | |
var filter = document.getElementById('filter'); | |
// Form submit event | |
form.addEventListener('submit', addItem); | |
// Delete event | |
itemList.addEventListener('click', removeItem); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Traversy Media | |
// Original Video link https://www.youtube.com/watch?v=mPd2aJXCZ2g | |
// EXAMINE THE DOCUMENT OBJECT // | |
// console.dir(document); | |
// console.log(document.domain); | |
// console.log(document.URL); | |
// console.log(document.title); | |
// //document.title = 123; | |
// console.log(document.doctype); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function deepClone(object){ | |
var newObject = {}; | |
for(var key in object){ | |
if(typeof object[key] === 'object' && object[key] !== null ){ | |
newObject[key] = deepClone(object[key]); | |
}else{ | |
newObject[key] = object[key]; | |
} | |
} | |
return newObject; |
NewerOlder