Last active
March 22, 2019 11:24
-
-
Save indatawetrust/1eb9960308a382a1bd301f51abda8dbc 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
Array.prototype.uniq = function(key) { | |
return key | |
? this.map(e => e[key]) | |
.map((e, i, final) => final.indexOf(e) === i && i) | |
.filter(e => this[e]) | |
.map(e => this[e]) | |
: [...new Set(this)]; | |
} | |
Array.prototype.asyncMap = async function(func) { | |
const data = [] | |
for (let item of this) { | |
data.push(await func(item)) | |
} | |
return data | |
} | |
Array.prototype._concat = function() { | |
return this.reduce((prev, next) => prev.concat(next), []) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment