Skip to content

Instantly share code, notes, and snippets.

@HamidReazaNikoonia
Last active February 11, 2023 06:49
Show Gist options
  • Save HamidReazaNikoonia/d66a63131db1e755d3500c8188b55317 to your computer and use it in GitHub Desktop.
Save HamidReazaNikoonia/d66a63131db1e755d3500c8188b55317 to your computer and use it in GitHub Desktop.
function testCall(a) {
fakeFetch(a)
.then((response) => {
if (a === 'works' && typeof response.data !== 'object') {
setState(fallbackRes)
return
}
if (typeof response.data === 'object') {
setState(response.data)
return
}
testCall('works')
})
}
/**
* Unzip Tuple
* [ [1,a], [2,b] ] ==> [1, a, 2, b]
* @param {array} zipped tuple
* @returns {array} flated array
*/
function unzip(tuple: Array<[number, string]>) {
if (!tuple || Array.isArray(tuple)) {
return false
}
return [].concat(...tuple)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment