This file contains hidden or 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
| const request1 = () => new Promise((resolve, reject) => { | |
| console.log('request1') | |
| setTimeout(() => { | |
| console.log('request1-resolved') | |
| resolve(true) | |
| }, 1000) | |
| }) | |
| const request2 = () => new Promise((resolve, reject) => { | |
| console.log('request2') |
This file contains hidden or 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
| class App extends React.Component { | |
| shouldComponentUpdate(nextProps, nextState) { | |
| const nextPropsKeys = Object.keys(nextProps); | |
| const nextStateKeys = Object.keys(nextState); | |
| for (let i = 0; i < nextPropsKeys.length; i++) { | |
| const key = nextPropsKeys[i]; | |
| if (nextProps[key] !== this.props[key]) { |
This file contains hidden or 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 RGBAtoRGB(r, g, b, a, r2,g2,b2){ | |
| var r3 = Math.round(((1 - a) * r2) + (a * r)) | |
| var g3 = Math.round(((1 - a) * g2) + (a * g)) | |
| var b3 = Math.round(((1 - a) * b2) + (a * b)) | |
| return "rgb("+r3+","+g3+","+b3+")"; | |
| } | |
| $("#result").html(RGBAtoRGB(225,110,0,0.5,255,255,255)); | |
| |
This file contains hidden or 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
| class MyComponent extends React.Component<IProps> { | |
| shouldComponentUpdate(nextProps, nextState) { | |
| const nextPropsKeys = Object.keys(nextProps) | |
| const propsKeys = Object.keys(this.props) | |
| if (nextPropsKeys.length !== propsKeys.length) { | |
| console.warn(`[MyComponent]: Mismatch in prop's keys`) | |
| return true; | |
| } |
This file contains hidden or 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 freezeApp(duration) { | |
| var now = new Date().getTime(); | |
| var endTime = now + duration; | |
| console.log('start freeze time', new Date().toISOString(), 'window is focused:', document.hasFocus()); | |
| while(new Date().getTime() < endTime) document.querySelector('this.is > [very] > *[heavy] > .css[selector]'); | |
| console.log('end freeze time', new Date().toISOString(), 'window is focused:', document.hasFocus()); | |
| } | |
| /** | |
| * Freeze app for 5000ms with 2000ms delay |
This file contains hidden or 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
| [{ | |
| name: "Dwight Schrute", | |
| email: "d.schrute@dunder-mifflin.com", | |
| avatar: "https://i.ibb.co/PYzBDTy/dwight.png" | |
| }, { | |
| name: "Kevin Malone", | |
| email: "k.malone@dunder-mifflin.com", | |
| avatar: "https://i.ibb.co/0n7D37f/kevin.png" | |
| }, { | |
| name: "Pam Beesly", |
OlderNewer