1.2.1 • Published 4 years ago

@tmplx/promisify v1.2.1

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

@tmplx/promisify

Turn function into a promise.

// Imports
import { promisify } from "@tmplx/promisify";
import Axios from "axios";

const getMSIn = (ms: number) => new Promise<number>(async resolve => {
	const id = setInterval(() => {
		resolve(Date.now());
		clearInterval(id);
	}, ms);
});

const getNum = promisify(async () => {
	let init = Math.floor(Math.min(0, Math.max(1000, Math.random() * 1000)));
	const ms = await getMSIn(init);
	return ms;
});

getNum().then(console.log).catch(console.error);
1.1.1

4 years ago

1.2.1

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago

0.4.0

4 years ago