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
type PromiseFunc<T, K extends unknown = undefined[]> = ( | |
...args: K | |
) => Promise<T>; | |
interface Config { | |
initialDelay?: number; | |
attempts?: number; | |
} | |
function waitFn<T>(fn: PromiseFunc<T>, time: number): Promise<T> { |
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
const collection = [ | |
{ id: 1, name: “Han Solo”, title: “Scruffy Looking Nerf Herder”, allegiance: “rebellion” }, | |
{ id: 2, name: “Darth Vader”, title: “Sith Lord”, allegiance: “empire” }, | |
{ id: 3, name: “K-2SO”, title: “Sass-bot”, allegiance: “rebellion” }, | |
{ id: 4, name: “Wilhuff Tarkin”, title: “Grand Moff”, allegiance: “empire” }, | |
]; | |
var sortedCollection = collection.sort(function(a,b){ | |
return a.name.localeCompare(b.name); | |
}); |