0.1.6 • Published 3 years ago

get-async v0.1.6

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

get-async

get something asynchronously without repetition

usage

import getAsync from 'get-async';

let called = 0;

function getTimer() {
  called++;
  return new Promise<number>(resolve => {
    setTimeout(() => {
      resolve(called);
    }, 100);
  });
}

const call1 = getAsync<number>('timer', getTimer);

const call2 = getAsync<number>('timer', getTimer);

const ret = await Promise.all([call1, call2]);

expect(ret).toMatchInlineSnapshot(`
  Array [
    1,
    1,
  ]
`);
expect(called).toBe(1);
0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago