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 retry(myPromise: Promise<unknown>, maxRetries = 1) { | |
if (!maxRetries) return | |
let count = 0 | |
let result | |
while (count < maxRetries) { | |
if (count === maxRetries) { | |
break | |
} |
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 retry(myPromise: Promise<unknown>, maxRetries = 1) { | |
if (!maxRetries) return | |
let count = 0 | |
let result | |
while (count < maxRetries) { | |
try { | |
result = myPromise() | |
break |
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
// https://github.com/reactwg/react-18/discussions/9 | |
// https://github.com/reactjs/rfcs/blob/master/text/0147-use-mutable-source.md | |
import { | |
unstable_createMutableSource as createMutableSource, | |
unstable_useMutableSource as useMutableSource, | |
} from "react" | |
const heightSource = createMutableSource( | |
window, |
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
type DatabaseHelper interface { | |
Collection(name string) CollectionHelper | |
Client() ClientHelper | |
} | |
type CollectionHelper interface { | |
FindOne(context.Context, interface{}) SingleResultHelper | |
InsertOne(context.Context, interface{}) (interface{}, error) | |
DeleteOne(ctx context.Context, filter interface{}) (int64, error) | |
} |
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
// in series | |
async load() { | |
const users = await api.getUsers(); | |
const posts = await api.getPosts(); | |
return arrangeData(users, posts); | |
} | |
// in parallel |
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 Car { | |
constructor() { | |
this.firstName = 'Joe'; | |
this.lastName = 'Cocker'; | |
} | |
get fullName() { | |
return `${this.firstName} ${this.lastName}`; | |
} |
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
let regex = `import | |
(?: | |
["'\s]* | |
([\w*{}\n, ]+) | |
from\s* | |
)? | |
["'\s]* | |
([@\w/_-]+) | |
["'\s]* | |
;? |
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 movies = { | |
horror: [ | |
'Get Out', | |
'The Cabinet of Dr. Caligari', | |
'Psycho', | |
'Nosferatu, a Symphony of Horror', | |
'King Kong', | |
'Repulsion', | |
'The Bride of Frankenstein', | |
'The Babadook', |
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
"use strict"; | |
const del = require('del'); | |
const glob = require("glob"); | |
module.exports = (includes, excludes, destination) => { | |
String.prototype.replaceMultiple = function (obj) { | |
let replace_string = this; | |
for (let x in obj) { |
NewerOlder