Skip to content

Instantly share code, notes, and snippets.

View N8python's full-sized avatar

n8programs N8python

View GitHub Profile
@N8python
N8python / keybindr.js
Created August 1, 2019 20:21
Keybindr - A small and easy way to bind callbacks to keys.
window.keybindr = (() => {
// Declare set of keys that are pressed
const keys = new Set();
// Declare "associative array" of bindings to callback
const bindings = [];
function tokenizeKeys(keys){
// Get array of different keys from string
return keys.split("+");
}
window.addEventListener("keydown", ({key}) => {
@N8python
N8python / Fmait.js
Created June 23, 2019 11:01
An asynchronous, concurrent function for creating efficient, easy-to-understand promise pipelines.
async function fmait(callbacks, array) {
for (const callback of callbacks) {
array = await Promise.all(array.map(item => Promise.resolve(callback(item))));
}
return array;
}