Created
September 18, 2017 13:38
-
-
Save BirkhoffLee/3da8bf144893c9e93a7ac2869c8a67f3 to your computer and use it in GitHub Desktop.
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
let a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] | |
const unflatten = (arrayToUnflatten, unflattenLength) => { | |
return Promise.all(new Array(Math.ceil(arrayToUnflatten.length / unflattenLength)).fill('').map((_, index) => new Promise(resolve => { | |
resolve(arrayToUnflatten.slice(index * unflattenLength, index * unflattenLength + unflattenLength)) | |
}))) | |
} | |
unflatten(a, 2).then(result => console.log(result)) |
Author
BirkhoffLee
commented
Sep 18, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment