This file contains hidden or 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
/** | |
* Flattens the multidimensional array | |
* @param {Array} array - some multidimensional array | |
* @returns {Array} flattened array | |
*/ | |
function flatten(array) { | |
return array.reduce(function(acc, curr) { | |
var items = Array.isArray(curr)? flatten(curr) : [curr]; | |
return acc.concat(items); | |
}, []); |
This file contains hidden or 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
// ES6 program to for Knight's tour problem using | |
// Warnsdorff's algorithm | |
const N = 8; | |
let gx; | |
let gy; | |
const a = []; | |
function print(a) { | |
for (let i = 0; i < N; i += 1) { | |
let s = ''; |
This file contains hidden or 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 transitionEndPromise(element) { | |
return new Promise(resolve => { | |
element.addEventListener('transitionend', function f() { | |
element.removeEventListener('transitionend', f); | |
resolve(); | |
}); | |
}); | |
} | |
function animateOut(oldView) { |
This file contains hidden or 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
async function asyncCall() { | |
let response = await fetch("https://httpstat.us/500") | |
if (response.ok) return await response.text() | |
throw new Error(response) | |
} | |
async function callFetch() { | |
try { | |
let const = await asyncCall() | |
console.log(text) |
This file contains hidden or 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
declare var __DEV__: boolean; | |
declare module 'react-native' { | |
declare type Color = string | number; | |
declare type Transform = | |
{ perspective: number } | | |
{ scale: number } | | |
{ scaleX: number } | |