# HG changeset patch # User Claus Gittinger # Date 1499941949 -7200 # Node ID 1a4affe1e22c4c569a6ba78522b9e7b2eafca2e6 # Parent a56e43b3b432fc3545935f74426adcfa7625da9d #FEATURE by cg class: PositionableStream added: #peek: diff -r a56e43b3b432 -r 1a4affe1e22c PositionableStream.st --- a/PositionableStream.st Thu Jul 13 12:19:01 2017 +0200 +++ b/PositionableStream.st Thu Jul 13 12:32:29 2017 +0200 @@ -836,6 +836,28 @@ ^ peekObject ! +peek:n + "look ahead n elements and return them after positioning pack to the + position we had before" + + |posBefore peekObjects| + + posBefore := self position. + peekObjects := self next:n. + self position:posBefore. + ^ peekObjects + + " + |s| + + s := '1234567890' readStream. + s peek:4. + s next:5. + " + + "Created: / 13-07-2017 / 12:32:03 / cg" +! + upToAll:aCollection "read until a subcollection consisisting of the elements in aCollection is encountered. Return everything read excluding the elements in aCollection.