Add toString
.
This commit is contained in:
parent
e1b638bef7
commit
f07e849662
3 changed files with 12 additions and 1 deletions
|
@ -24,6 +24,7 @@
|
||||||
- [shift() -> async](#shift---async)
|
- [shift() -> async](#shift---async)
|
||||||
- [slice(start[, end]) -> Channel](#slicestart-end---channel)
|
- [slice(start[, end]) -> Channel](#slicestart-end---channel)
|
||||||
- [some(callbackfn[, thisArg])](#somecallbackfn-thisarg)
|
- [some(callbackfn[, thisArg])](#somecallbackfn-thisarg)
|
||||||
|
- [toString()](#tostring)
|
||||||
- [Functional API](#functional-api)
|
- [Functional API](#functional-api)
|
||||||
|
|
||||||
<!-- /TOC -->
|
<!-- /TOC -->
|
||||||
|
@ -305,6 +306,10 @@ Unlike in `Array`'s method, `callbackfn` is called with only one argument.
|
||||||
`some` acts like the "exists" quantifier in mathematics. In particular, for an
|
`some` acts like the "exists" quantifier in mathematics. In particular, for an
|
||||||
empty channel, it returns `false`.
|
empty channel, it returns `false`.
|
||||||
|
|
||||||
|
### toString() -> String
|
||||||
|
|
||||||
|
Return `"Channel(n)"` where `n` is the length of the buffer.
|
||||||
|
|
||||||
# Functional API
|
# Functional API
|
||||||
|
|
||||||
There is a parallel API to support functional-style programming. Every channel
|
There is a parallel API to support functional-style programming. Every channel
|
||||||
|
|
|
@ -239,7 +239,9 @@ const Channel = function(bufferLength = 0) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
|
||||||
|
toString: () => `Channel(${bufferLength})`
|
||||||
});
|
});
|
||||||
|
|
||||||
Object.defineProperty(readOnly, `value`, { get: () => lastValue });
|
Object.defineProperty(readOnly, `value`, { get: () => lastValue });
|
||||||
|
|
|
@ -356,6 +356,10 @@ describe(`Channel object`, function() {
|
||||||
assert(!await Channel.of(1, 3, 5).some(even));
|
assert(!await Channel.of(1, 3, 5).some(even));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it(`toString`, function() {
|
||||||
|
assert.equal(Channel(10).toString(), `Channel(10)`);
|
||||||
|
});
|
||||||
|
|
||||||
it(`value`, async function() {
|
it(`value`, async function() {
|
||||||
const channel = Channel();
|
const channel = Channel();
|
||||||
(async () => {
|
(async () => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue