当前位置: 首页 > 文档资料 > Lazy.js 英文文档 >

mapString

优质
小牛编辑
137浏览
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);
}
NameType(s)Description
mapFnFunction

The function used to map characters from this sequence onto the new sequence.

returnsStringLikeSequence

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"