Last active
February 11, 2023 06:49
-
-
Save HamidReazaNikoonia/d66a63131db1e755d3500c8188b55317 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | |
}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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