Skip to content

Instantly share code, notes, and snippets.

View dreamer01's full-sized avatar
💻
Learning and Developing

Pushpendra Singh dreamer01

💻
Learning and Developing
View GitHub Profile
const CODE_APP = `
// This is the root component in
// the React application.
import Header from '../Header';
import Widget from '../Widget';
function App() {
return (
<>
<Header title="My Application" />
window.addEventListener( "load", function () {
function sendData() {
const XHR = new XMLHttpRequest();
// Bind the FormData object and the form element
const FD = new FormData( form );
// Define what happens on successful data submission
XHR.addEventListener( "load", function(event) {
alert( event.target.responseText );
@dreamer01
dreamer01 / TaskRunner.js
Created September 4, 2020 13:39
A simple priority based task runner with a given cuncurrency for asynchronous tasks.
// Task Runner
// Implement Asynchronous Task Runner
// tasks execute in an order of priority
// If the task runner have bandwidth it will pick immediately
// A "TaskRunner" Constructor takes one argument, "concurrency", and exposes one method "push" on its prototype.
// The "push" method takes two arguments. First one is task which is a "function" & second argument priority number
class TaskRunner {
"use strict";
module.exports = [
{
urlPattern: /^https:\/\/fonts\.(?:googleapis|gstatic)\.com\/.*/i,
handler: "CacheFirst",
options: {
cacheName: "google-fonts",
expiration: {
maxEntries: 4,