Skip to content

Instantly share code, notes, and snippets.

Avatar

Kirill Konshin kirill-konshin

View GitHub Profile
@kirill-konshin
kirill-konshin / index.ts
Created May 7, 2020
Sequential promise-based batches for JavaScript or TypeScript
View index.ts
/**
* Task is just an async function that accepts no arguments and returns a promise with result
* Example: `async () => new Promise(...)`
*/
export const sequentialBatches = async <T>(tasks: (() => Promise<T>)[], maxConcurrency = 100): Promise<T[]> => {
const batches = tasks.reduce((res, task, index) => {
const batchIndex = Math.floor(index / maxConcurrency);
res[batchIndex] = res[batchIndex] || [];
res[batchIndex].push(task);
return res;
View MouseWheelDrag.js
/**
* @author Jacky Nguyen
* @author Kirill Konshin (patched version for Sencha Touch 2.2.x)
* @class Common.MouseWheelDrag
*
* Ext.Loader.setPath('Common', '/path/to/your/app/common');
*
* Ext.application({
* // ...
* eventPublishers: {