mapString
优质
小牛编辑
138浏览
2023-12-01
Maps the characters of this sequence onto a new StringLikeSequence.
Signature
StringLikeSequence.mapString = function(mapFn) { /*...*/ }
StringLikeSequence.mapString = function mapString(mapFn) { return new MappedStringLikeSequence(this, mapFn); }
Name | Type(s) | Description |
---|---|---|
mapFn | Function | The function used to map characters from this sequence onto the new sequence. |
returns | StringLikeSequence | The new sequence. |
Examples
function upcase(char) { return char.toUpperCase(); } Lazy("foo").mapString(upcase) // sequence: "FOO" Lazy("foo").mapString(upcase).charAt(0) // => "F" Lazy("foo").mapString(upcase).charCodeAt(0) // => 70 Lazy("foo").mapString(upcase).substring(1) // sequence: "OO"