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
// Make sure we have a input field with id "inputData" in our DOM. | |
const inputData = document.getElementById("inputData"); | |
const getDataFromServer = (name) => { | |
console.log(`${name} :: getting Data from Server...........`); | |
}; | |
const throttle = (callback, delay) => { | |
delay = delay || 2000; |
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
// Make sure we have a input field with id "inputData" in our DOM. | |
const inputData = document.getElementById("inputData"); | |
const getDataFromServer = (name) => { | |
console.log(`${name} :: getting Data from Server...........`); | |
}; | |
const debounce = (callback, delay) => { | |
delay = delay || 2000; |
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 memoize = (func) => { | |
const cache = {}; | |
return (...args) => { | |
const key = args.toString(); | |
if (cache[key]) { | |
console.log(`Getting from the cache for ${key}`); | |
return cache[key]; | |
} else { |
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 MyAsyncIterator { | |
constructor() { | |
this.queue = []; // To hold actual values | |
this.waitlist = []; // To hold the callbacks | |
} | |
/** | |
* If the waitlist contains an item, remove it and execute it. | |
* Otherwise, add the value to the queue. | |
*/ |
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 Stock { | |
constructor(symbol) { | |
this.symbol = symbol; | |
this.price = 0; | |
this.observers = []; | |
} | |
// Subscribe to stock price changes | |
subscribe(observer) { | |
this.observers.push(observer); |
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
body { | |
background-color: skyblue; | |
margin: 20px; | |
height: 90%; | |
} | |
.flex_center { | |
display: flex; | |
align-items: center; | |
justify-content: center; |
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
// Make these changes in the ~/Library/Application Support/Code/User/snippets/html.json | |
// Place your snippets for html here. Each snippet is defined under a snippet name and has a prefix, body and | |
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are: | |
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the | |
// same ids are connected. | |
// Example: | |
// "Print to console": { | |
// "prefix": "log", | |
// "body": [ | |
// "console.log('$1');", |
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 PubSub { | |
constructor() { | |
this.events = {}; | |
} | |
subscribe(eventName, callback) { | |
if (!this.events[eventName]) { | |
this.events[eventName] = []; | |
} | |
this.events[eventName].push(callback); |
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
import { Provider } from "react-redux"; | |
import thunk, { ThunkMiddleware } from "redux-thunk"; | |
import { render, RenderAPI } from "react-test-renderer"; | |
import configureMockStore from "redux-mock-store"; | |
import TestComponent from "./TestComponent"; | |
import { describe } from "node:test"; | |
const middlewares: Array<ThunkMiddleware> = [thunk]; | |
const createMockStore = configureMockStore(middlewares); |
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
import Notifee from "@notifee/react-native"; | |
jest.spyOn(Notifee, "requestpermission"); | |
Notifee.requestPermission.mockImplementation(() => { | |
throw new Error(); | |
}); |
NewerOlder