Add every.

This commit is contained in:
David Braun 2017-10-11 04:46:12 -04:00
parent 8da51305eb
commit 17a2688291
No known key found for this signature in database
GPG key ID: 5694EEC4D129BDCF
3 changed files with 36 additions and 0 deletions

View file

@ -103,6 +103,20 @@ const Channel = function (bufferLength = 0) {
}
const readOnly = Object.freeze({
every: async (callbackfn, thisArg) => {
for (;;) {
const value = await readOnly.shift()
if (value === undefined) {
return true
} else {
if (!callbackfn.call(thisArg, value)) {
return false
}
}
}
},
filter: (callbackfn, thisArg) => {
const output = Channel()