ping-utils
v0.0.7
Published
``` import { createPromise } from 'ping-utils'
Downloads
2
Readme
createPromise
import { createPromise } from 'ping-utils'
const promiseObject = createPromise()
const [promise, resolve, reject] = createPromise(true)
createSetTimeoutPromise
import { createSetTimeoutPromise } from 'ping-utils'
createSetTimeoutPromise(2000).promise.then(()=>{
//2000ms...
})
ultimatelyPromise
import { ultimatelyPromise, createSetTimeoutPromise } from 'ping-utils'
const result = ultimatelyPromise((ms, res) => createSetTimeoutPromise(ms).promise.then(() => res))
result(50, 1) // rejected 1
result(20, 2) // rejected 2
result(100, 3) // fulfilled 3
arrayToMap
arrayToMap([{a:1},{a:2}],'a') //{1: {…}, 2: {…}}
arrayToMap([{a:1},{a:2}],'a','Map') //Map(2) {1 => {…}, 2 => {…}}
createFormData
createFormData() //FormData {}