diff --git a/assets/highlight.css b/assets/highlight.css index f02152d1..4442e776 100644 --- a/assets/highlight.css +++ b/assets/highlight.css @@ -7,24 +7,30 @@ --dark-hl-2: #9CDCFE; --light-hl-3: #A31515; --dark-hl-3: #CE9178; - --light-hl-4: #008000; - --dark-hl-4: #6A9955; - --light-hl-5: #0000FF; - --dark-hl-5: #569CD6; - --light-hl-6: #0070C1; - --dark-hl-6: #4FC1FF; - --light-hl-7: #795E26; - --dark-hl-7: #DCDCAA; - --light-hl-8: #800000; - --dark-hl-8: #808080; + --light-hl-4: #0000FF; + --dark-hl-4: #569CD6; + --light-hl-5: #0070C1; + --dark-hl-5: #4FC1FF; + --light-hl-6: #795E26; + --dark-hl-6: #DCDCAA; + --light-hl-7: #098658; + --dark-hl-7: #B5CEA8; + --light-hl-8: #008000; + --dark-hl-8: #6A9955; --light-hl-9: #800000; - --dark-hl-9: #569CD6; - --light-hl-10: #000000FF; - --dark-hl-10: #D4D4D4; - --light-hl-11: #E50000; - --dark-hl-11: #9CDCFE; - --light-hl-12: #0000FF; - --dark-hl-12: #CE9178; + --dark-hl-9: #808080; + --light-hl-10: #800000; + --dark-hl-10: #569CD6; + --light-hl-11: #000000FF; + --dark-hl-11: #D4D4D4; + --light-hl-12: #E50000; + --dark-hl-12: #9CDCFE; + --light-hl-13: #0000FF; + --dark-hl-13: #CE9178; + --light-hl-14: #267F99; + --dark-hl-14: #4EC9B0; + --light-hl-15: #EE0000; + --dark-hl-15: #D7BA7D; --light-code-background: #FFFFFF; --dark-code-background: #1E1E1E; } @@ -43,6 +49,9 @@ --hl-10: var(--light-hl-10); --hl-11: var(--light-hl-11); --hl-12: var(--light-hl-12); + --hl-13: var(--light-hl-13); + --hl-14: var(--light-hl-14); + --hl-15: var(--light-hl-15); --code-background: var(--light-code-background); } } @@ -60,6 +69,9 @@ --hl-10: var(--dark-hl-10); --hl-11: var(--dark-hl-11); --hl-12: var(--dark-hl-12); + --hl-13: var(--dark-hl-13); + --hl-14: var(--dark-hl-14); + --hl-15: var(--dark-hl-15); --code-background: var(--dark-code-background); } } @@ -77,6 +89,9 @@ --hl-10: var(--light-hl-10); --hl-11: var(--light-hl-11); --hl-12: var(--light-hl-12); + --hl-13: var(--light-hl-13); + --hl-14: var(--light-hl-14); + --hl-15: var(--light-hl-15); --code-background: var(--light-code-background); } @@ -94,6 +109,9 @@ --hl-10: var(--dark-hl-10); --hl-11: var(--dark-hl-11); --hl-12: var(--dark-hl-12); + --hl-13: var(--dark-hl-13); + --hl-14: var(--dark-hl-14); + --hl-15: var(--dark-hl-15); --code-background: var(--dark-code-background); } @@ -110,4 +128,7 @@ .hl-10 { color: var(--hl-10); } .hl-11 { color: var(--hl-11); } .hl-12 { color: var(--hl-12); } +.hl-13 { color: var(--hl-13); } +.hl-14 { color: var(--hl-14); } +.hl-15 { color: var(--hl-15); } pre, code { background: var(--code-background); } diff --git a/assets/navigation.js b/assets/navigation.js index c5942166..ba07b734 100644 --- a/assets/navigation.js +++ b/assets/navigation.js @@ -1 +1 @@ -window.navigationData = "data:application/octet-stream;base64,H4sIAAAAAAAAA42RQQsCIRBG/8ucpYWoPXgL6hgbdIwO6o6t1KroLASx/z2ILbJMOn/vPQY93IDwSsBhJV2gxpNxNgIDL6gDDsYSBi0UxuodmHXUX4DB2dgW+HxZj+wVWqNyLYZsY9pK+sb+1qetpG8xRnHCPQUUfTaSEKXULjhyctCFVor8H2s85R/5GytFvfy8TQ9WPX6oem6pXy/G4x0EzLHP9AEAAA==" \ No newline at end of file +window.navigationData = "data:application/octet-stream;base64,H4sIAAAAAAAAA62Z3W7cNhCF30XXVloHTdr6LnZSwEALC07RmyAQKGm0yyxXZEmq9aLIuxek/iWKHHl1PWc+HpIjciR9+S/S8KKjuyhjPIs1j6mObiJB9DG6i868qBmoH0ws1Tyl+s1Rn1l0E51oVUR3b2+i/EhZIaGK7r70qAJKUrMRp6yrXFNeTUitakp8/9P3r99vBlOS/6tAxhJIQTIGSksg51WbjTqdqjcYv28Az23+Z5v/J3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drUgPTWhL5Gyny8BdLdaLuFzYT2KGoLQZZ0oqvvB6ZAK6o+VkQCaGatryZ9vXdtaVhpyiY6weyoZgIapKfjTJwWje0sfKK+VkWcoKanNzHpAnsUE8Wg/XCY/d/fLdBnrr/bu/hepW9YSr2D9eqdRvdyWrDWrf29X/B5WM0viEAAA==" \ No newline at end of file diff --git a/assets/search.js b/assets/search.js index fd1f1238..f6ace46e 100644 --- a/assets/search.js +++ b/assets/search.js @@ -1 +1 @@ -window.searchData = "data:application/octet-stream;base64,H4sIAAAAAAAAA7VXW2+bMBT+LyevbsoxBBLeNnUPkzZ10qS+oGhygtOiEUDgXqYo/33iFtvBZqTpXio1/i7n5gsHKPPXCsLoAL+TLIbQ9whkbM8hhGLzU5Sc7YHAc5lCCLvnbCuSPKtu+6X5k9inQGCbsqriFYQAR9JL0YV/0vq0yUtxXzTsk16SCV7u2JZXt+r6qCg6VEZYJY8ZSyfpzU5YRZZAwUqeifMAzTnc8W0e89Jk1y1NLseXzCrVLU2W+lHmIt887856pSjqiHFhx1uelEvO4ol6sw5rru1ZiBa71zIRfKpfD77a8OEix4crLYvNVLsGeY3Vc/ZasmKq3Ql9qaUyid95VbFHbh9EDXD9HA7lxsdQj+/SKTS4jQ/hdDvjDNr87CM4ydA+FgbDf0yF1dB6PN0Xwnj8D1HTxyPl2aN4GjlRLeKzc6K0ElV8k1Q3SfbE65LH9q3QJDQa2MitMR6YJH5AYNq1uWdv3xqL9u8loQ2p/yG4OybYu0LTiB8d2J+Ep/HnP4JfMsEzjfX+kNYEkizmbxAe4IWXVZJnEAKdu/MVENjVJvUrro2VwDbf72uxdbf2wLciL2tEC7l1gEQOocHcXa9J1OObn5sfGhACiXAIQg1EgUR0CKIayAUSuUOQq4E8IJE3BHkaaAEkWgxBCw3kA4l8QukcV1SD+RosABIFJligwZZAoqUJttRgKyDRahjZSi9pXWF0TGp4Vvym+qby6/VHaksW9R6ga0sX9T6gZ0sY9V7gwp6M3hCsC4+GMUG9I1hXHg2TgnpLsC49GoYF9Z5gXX00zAvqbaFNW3zDGOtNoU1TAgOubUqzTV94KXj8td2uUQSs/rTI+2+fA/zqdjL2R8sBEMLD8Sj3bf1fLR/3d4BkuZLlWlg8G7A8yfIsrPbWMTiiQsblKNvgjErAGFjYe/YWM8HS7uxW2L5kU8fObpkG/kJxX9n47Tum6h6uClttka1H9UtdUlaSYbMrNkMnR9JsWRbdtTAkKzkuJpHz5hmm5EmVPH2LRPu2liSlMw2FAFILtf/2lmTF0EbqH59KmEqV0Ok8bRl3j3PJDiQ56Li2DdRwX1TyUpKXHdm2j5obf9Pe+Ersij01jtKaQJEUPE0yDmG0Ph7/ApH0BE+cEQAA"; \ No newline at end of file +window.searchData = "data:application/octet-stream;base64,H4sIAAAAAAAAA81dXY/bSK79L/ar2iuWvvM2k90FBtiLCWYW89IIGmpbnXjjtr2yOpO+Qf77RZVKElkmpZLt3r3AAPG0i+RhHZJVRX34+6I+/HlavLv/vviy3W8W71Sw2JfP1eLd4nF3eLxrDnfbZhEsXurd4t3i+bB52VWnv+ivHprDw7ZZfW6ed4tgsd6Vp1N1WrxbLH4Ena407pVtqqfyZTdoenrZr5vtYU902UGMzmBxLOtq31BYgyWEWvtT1Xd1VW7Kx111auqqfJb8aAc/0MEenqkk7S3+3Cr5zer43ej45+GX5tej8bC3ut03Vf1UrqcMTymcmJ+xCRg8gFAN7Bzr6mu1b96X+3W1exu8S9fGfPSThmaH3phXfsHoN9lDeG6bu3K3OwvEbfNQ7nbXJ5PV44XdQhFQPpbN+jOH03xxE6StJl+sLaAxtNXm7vG1qU4i6mrzYAZ4p/ZPp9f9+udW9GctOZLSZ0YkYT9Pe2eElD1t/7e6HsbSqhmwNKfN3fZ0t91/ruptU23GsIm6JdCv22q3+empqeobQCfK/CbTB7DE/6+P/6rWzcURQMX/izHAALlhFDizdPs44OALkXB7J1QY58PsV/W23N2MAqTtTV3AO5cLK9t/v6j517PRGfOvBJcXgf8P+f9mqf+GCTM7V64COmvP0mOctXdh2K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8tHZvI0ZZgDyPu/Njd3KETqF4RcS4sW7fKIN9wQGRSOVvEKbhFOJoTPoToBRX9lXGyCdUGGIbRn33qs9JMRmNvq9kk4EmuT9/Qn/okkqEeS1s+eR2vUhfqHNuTMXZdYwIhUrcNRB7rlhdH4PFcXusdtt9tXh3//HHj/8DRn3CHBOXAAA="; \ No newline at end of file diff --git a/classes/it_byte_stream.AbortError.html b/classes/it_byte_stream.AbortError.html new file mode 100644 index 00000000..58b80aeb --- /dev/null +++ b/classes/it_byte_stream.AbortError.html @@ -0,0 +1,14 @@ +
Optional
causeReadonly
codeOptional
stackReadonly
typeStatic
Optional
prepareStatic
stackStatic
captureCreate .stack property on a target object
+Optional
constructorOpt: FunctionOptional
causeReadonly
codeOptional
stackStatic
Optional
prepareOptional override for formatting stack traces
+Static
stackStatic
captureCreate .stack property on a target object
+Optional
constructorOpt: FunctionTurns a browser readable stream into an async iterable. Async iteration over
+returned iterable will lock give stream, preventing any other consumer from
+acquiring a reader. The lock will be released if iteration loop is broken. To
+prevent stream cancelling optional { preventCancel: true }
could be passed
+as a second argument.
Takes an (async) iterable that emits things and returns an async iterable that +emits those things in fixed-sized batches
+Takes a stream of Uint8Arrays and/or Uint8ArrayLists and store them in +an internal buffer. Either once the buffer reaches the requested size +or the next event loop tick occurs, yield any bytes from the buffer.
+Optional
options: BatchedBytesOptionsOptional
options: AsyncBatchedBytesOptionsOptional
options: BatchedObjectsOptions<T>Optional
options: AsyncBatchedObjectsOptions<T>An async iterable that emits buffers containing bytes up to a certain length
+Optional
opts: ByteStreamOptsFilters the passed (async) iterable by using the filter function
+Takes an (async) iterable that emits variable length arrays of things and +returns an async iterable that emits those things in fixed-size batches
+Invokes the passed function for each item in an iterable
+Async iterable filename pattern matcher
+Takes an (async) iterable and returns one with each item mapped by the passed +function
+Treat one or more iterables as a single iterable.
+Nb. sources are iterated over in parallel so the +order of emitted items is not guaranteed.
+Streaming multipart HTTP message parser
+Takes an (async) iterator that emits promise-returning functions, +invokes them in parallel and emits the results as they become available but +in the same order as the input
+Takes an (async) iterator that emits promise-returning functions, +invokes them in parallel and emits the results as they become available but +in the same order as the input
+Optional
opts: Partial<ProtobufStreamOpts>Skip items from an iterable
+Collects all values from an async iterator, sorts them +using the passed function and yields them
+Splits Uint8Arrays emitted by an (async) iterable by a delimiter
+Optional
options: SplitOptionsOptional
options: SplitOptionsStop iteration after n items have been received
+Converts an (async) iterator into a WHATWG ReadableStream
+Takes an (async) iterable that yields buffer-like-objects and concats them +into one buffer
+Optional
opts: Partial<ProtobufStreamOpts>--Read and write protobuf messages over a duplex stream
+A collection of utilities for making working with iterables more bearable
This module makes it easy to send and receive length-prefixed Protobuf encoded -messages over streams.
-import { pbStream } from 'it-protobuf-stream'
import { MessageType } from './src/my-message-type.js'
// RequestType and ResponseType have been generate from `.proto` files and have
// `.encode` and `.decode` methods for serialization/deserialization
const stream = pbStream(duplex)
// write a message to the stream
stream.write({
foo: 'bar'
}, MessageType)
// read a message from the stream
const res = await stream.read(MessageType)
-
-$ npm i it-protobuf-stream
-
-<script>
tagLoading this module through a script tag will make it's exports available as ItProtobufStream
in the global namespace.
<script src="https://unpkg.com/it-protobuf-stream/dist/index.min.js"></script>
-
+packages/blob-to-it
Turns a blob into an async iteratorpackages/browser-readablestream-to-it
Turns a browser readble stream into an async iteratorpackages/it-all
Collects all values from an (async) iterable and returns them as an arraypackages/it-batch
Takes an async iterator that emits things and emits them as fixed size batchespackages/it-batched-bytes
Takes an async iterator that emits byte arrays and emits them as fixed size batchespackages/it-buffer-stream
An async iterator that emits buffers containing bytes up to a certain lengthpackages/it-byte-stream
Read and write arbitrary bytes over a duplex streampackages/it-drain
Empties an async iteratorpackages/it-filter
Filters the passed iterable by using the filter functionpackages/it-first
Returns the first result from an async iteratorpackages/it-flat-batch
Takes an async iterator that emits variable length arrays and emits them as fixed size batchespackages/it-foreach
Invokes the passed function for each item in an iterablepackages/it-glob
Async iterable filename pattern matcherpackages/it-last
Returns the last result from an async iteratorpackages/it-length
Counts the number of items in an async iterablepackages/it-length-prefixed-stream
Read and write length-prefixed byte arrays over a duplex streampackages/it-map
Maps the values yielded by an async iteratorpackages/it-merge
Treat one or more iterables as a single iterablepackages/it-multipart
Async iterable http multipart message parserpackages/it-ndjson
Parse iterators as ndjson and transform iterators to ndjsonpackages/it-parallel
Process incoming async(iterable) functions in parallelpackages/it-parallel-batch
Process (async)iterable values as functions with concurrency controlpackages/it-peekable
Allows peeking/pushing an iterablepackages/it-protobuf-stream
Read and write protobuf messages over a duplex streampackages/it-queueless-pushable
A pushable queue that waits until a value is consumed before accepting anotherpackages/it-reduce
Reduces the values yielded from an async iteratorpackages/it-rpc
Schema-free RPC over async iterablespackages/it-skip
Skip items from an iterablepackages/it-sort
Collects all values from an async iterator, sorts them using the passed function and yields thempackages/it-split
Splits Uint8Arrays emitted by an (async) iterable by a delimiterpackages/it-take
Stop iteration after n items have been receivedpackages/it-to-browser-readablestream
Takes an async iterator and turns it into a browser readable streampackages/it-to-buffer
Takes an async iterator that yields buffers and concatenates them all togetherLicensed under either of
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
-A protobuf decoder - takes a byte array and returns an object
-A protobuf encoder - takes an object and returns a byte array
-A message reader/writer that only uses one type of message
-Read a message from the stream
-Optional
options: AbortOptionsUnwrap the underlying protobuf stream
-Write a message to the stream
-Optional
options: AbortOptionsWrite several messages to the stream
-Optional
options: AbortOptionsConvenience methods for working with protobuf streams
-Optional
yieldAfter the stream is unwrapped, any bytes that have been read from the
-incoming stream will be yielded in-order as Uint8Array
(s).
To yield a single Uint8ArrayList
with all unread bytes instead, pass
-false
here.
Optional
sizeThe minimum number of bytes that should be in a batch (default: 1MB)
+Optional
yieldIf this amount of time passes, yield all the bytes in the batch even
+if they are below size
(default: 0 - e.g. on every tick)
Optional
sizeThe minimum number of bytes that should be in a batch (default: 1MB)
+Optional
yieldIf this amount of time passes, yield all the bytes in the batch even
+if they are below size
(default: 0 - e.g. on every tick)
This function should serialize the object and append the +result to the passed list
+Optional
sizeThe minimum number of bytes that should be in a batch (default: 1MB)
+This function should serialize the object and append the +result to the passed list
+Optional
chunkOptional
collectorOptional
generatorRead a set number of bytes from the stream
+Optional
bytes: numberOptional
options: AbortOptionsWrite the passed bytes to the stream
+Optional
options: AbortOptionsOptional
yieldAfter the stream is unwrapped, any bytes that have been read from the
+incoming stream will be yielded in-order as Uint8Array
(s).
To yield a single Uint8ArrayList
with all unread bytes instead, pass
+false
here.
Read the next length-prefixed number of bytes from the stream
+Optional
options: AbortOptionsWrite the passed bytes to the stream prefixed by their length
+Optional
options: AbortOptionsWrite passed list of bytes, prefix by their individual lengths to the stream as a single write
+Optional
options: AbortOptionsOptional
yieldAfter the stream is unwrapped, any bytes that have been read from the
+incoming stream will be yielded in-order as Uint8Array
(s).
To yield a single Uint8ArrayList
with all unread bytes instead, pass
+false
here.
A protobuf decoder - takes a byte array and returns an object
+A protobuf encoder - takes an object and returns a byte array
+A message reader/writer that only uses one type of message
+Read a message from the stream
+Optional
options: AbortOptionsUnwrap the underlying protobuf stream
+Write a message to the stream
+Optional
options: AbortOptionsWrite several messages to the stream
+Optional
options: AbortOptionsConvenience methods for working with protobuf streams
+Optional
yieldAfter the stream is unwrapped, any bytes that have been read from the
+incoming stream will be yielded in-order as Uint8Array
(s).
To yield a single Uint8ArrayList
with all unread bytes instead, pass
+false
here.
End the iterable after all values in the buffer (if any) have been yielded. If an +error is passed the buffer is cleared immediately and the next iteration will +throw the passed error
+Optional
err: ErrorOptional
options: AbortOptions & RaceSignalOptionsPush a value into the iterable. Values are yielded from the iterable in the order +they are pushed. Values not yet consumed from the iterable are buffered.
+Optional
options: AbortOptions & RaceSignalOptionsUsed on the server side to hold abort controllers that will be aborted +if the client sends an abort message
+Used on the client side to store abort signals that will cause an abort +message to be sent
+Holds references to any callback functions passed as arguments
+Any ongoing invocations of callbacks during the main method execution
+Scopes of parent invocations
+The result of the execution
+The scope of this invocation
+it-rpc
uses a binary representation of values on the wire. By default it
+uses CBOR though it is not a requirement.
Custom ValueCodec
s can be used to extend the supported value types
+with application-specific types.
A unique number for the value type. It's recommended that user defined +types use numbers greater than 1000 to avoid conflicting with built in +value transformers
+Decode the passed CBOR to recreate the value.
+Optional
encodeEncode the passed value to CBOR, if necessary. The codec should be able +to recreate the value from the decoded form of the returned CBOR.
+Optional
context: anyOptional
invocation: InvocationOptional
context: anyOptional
invocation: InvocationThis module makes it easy to send and receive length-prefixed Protobuf encoded -messages over streams.
-import { pbStream } from 'it-protobuf-stream'
import { MessageType } from './src/my-message-type.js'
// RequestType and ResponseType have been generate from `.proto` files and have
// `.encode` and `.decode` methods for serialization/deserialization
const stream = pbStream(duplex)
// write a message to the stream
stream.write({
foo: 'bar'
}, MessageType)
// read a message from the stream
const res = await stream.read(MessageType)
-
-Allows reading Blob contents as an async iterator.
+import toIt from 'blob-to-it'
import all from 'it-all'
const content = [ Uint8Array.from([0, 1, 2, 3, 4]) ]
const blob = new Blob(content)
const arr = await all(toIt(blob))
console.info(arr) // [ [ 0, 1, 2, 3, 4 ] ]
+
+++Turns a blob into an async iterator
+
Allows reading Blob contents as an async iterator.
+import toIt from 'blob-to-it'
import all from 'it-all'
const content = [ Uint8Array.from([0, 1, 2, 3, 4]) ]
const blob = new Blob(content)
const arr = await all(toIt(blob))
console.info(arr) // [ [ 0, 1, 2, 3, 4 ] ]
+
+$ npm i blob-to-it
+
+<script>
tagLoading this module through a script tag will make it's exports available as BlobToIt
in the global namespace.
<script src="https://unpkg.com/blob-to-it/dist/index.min.js"></script>
+
+Licensed under either of
+Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
+Allows treating a browser readable stream as an async iterator.
+import toIt from 'browser-readablestream-to-it'
import all from 'it-all'
const content = [0, 1, 2, 3, 4]
const stream = new ReadableStream({
start(controller) {
for (let i = 0; i < content.length; i++) {
controller.enqueue(content[i])
}
controller.close()
}
})
const arr = await all(toIt(stream))
console.info(arr) // 0, 1, 2, 3, 4
+
+By default a readable stream will have .cancel called on it once it has ended or +reading has stopped prematurely.
+To prevent this behaviour, pass preventCancel: true
as an option:
const arr = await all(toIt(stream, { preventCancel: true }))
console.info(arr) // 0, 1, 2, 3, 4
+
+++Turns a browser readble stream into an async iterator
+
Allows treating a browser readable stream as an async iterator.
+import toIt from 'browser-readablestream-to-it'
import all from 'it-all'
const content = [0, 1, 2, 3, 4]
const stream = new ReadableStream({
start(controller) {
for (let i = 0; i < content.length; i++) {
controller.enqueue(content[i])
}
controller.close()
}
})
const arr = await all(toIt(stream))
console.info(arr) // 0, 1, 2, 3, 4
+
+By default a readable stream will have .cancel called on it once it has ended or +reading has stopped prematurely.
+To prevent this behaviour, pass preventCancel: true
as an option:
const arr = await all(toIt(stream, { preventCancel: true }))
console.info(arr) // 0, 1, 2, 3, 4
+
+$ npm i browser-readablestream-to-it
+
+<script>
tagLoading this module through a script tag will make it's exports available as BrowserReadablestreamToIt
in the global namespace.
<script src="https://unpkg.com/browser-readablestream-to-it/dist/index.min.js"></script>
+
+Licensed under either of
+Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
+For when you need a one-liner to collect iterable values.
+import all from 'it-all'
// This can also be an iterator, etc
const values = function * () {
yield * [0, 1, 2, 3, 4]
}
const arr = all(values)
console.info(arr) // 0, 1, 2, 3, 4
+
+Async sources must be awaited:
+const values = async function * () {
yield * [0, 1, 2, 3, 4]
}
const arr = await all(values())
console.info(arr) // 0, 1, 2, 3, 4
+
+++Collects all values from an (async) iterable and returns them as an array
+
For when you need a one-liner to collect iterable values.
+import all from 'it-all'
// This can also be an iterator, etc
const values = function * () {
yield * [0, 1, 2, 3, 4]
}
const arr = all(values)
console.info(arr) // 0, 1, 2, 3, 4
+
+Async sources must be awaited:
+const values = async function * () {
yield * [0, 1, 2, 3, 4]
}
const arr = await all(values())
console.info(arr) // 0, 1, 2, 3, 4
+
+$ npm i it-all
+
+<script>
tagLoading this module through a script tag will make it's exports available as ItAll
in the global namespace.
<script src="https://unpkg.com/it-all/dist/index.min.js"></script>
+
+Licensed under either of
+Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
+The final batch may be smaller than the max.
+import batch from 'it-batch'
import all from 'it-all'
// This can also be an iterator, generator, etc
const values = [0, 1, 2, 3, 4]
const batchSize = 2
const result = all(batch(values, batchSize))
console.info(result) // [0, 1], [2, 3], [4]
+
+Async sources must be awaited:
+import batch from 'it-batch'
import all from 'it-all'
const values = async function * () {
yield * [0, 1, 2, 3, 4]
}
const batchSize = 2
const result = await all(batch(values(), batchSize))
console.info(result) // [0, 1], [2, 3], [4]
+
+++Takes an async iterator that emits things and emits them as fixed size batches
+
The final batch may be smaller than the max.
+import batch from 'it-batch'
import all from 'it-all'
// This can also be an iterator, generator, etc
const values = [0, 1, 2, 3, 4]
const batchSize = 2
const result = all(batch(values, batchSize))
console.info(result) // [0, 1], [2, 3], [4]
+
+Async sources must be awaited:
+import batch from 'it-batch'
import all from 'it-all'
const values = async function * () {
yield * [0, 1, 2, 3, 4]
}
const batchSize = 2
const result = await all(batch(values(), batchSize))
console.info(result) // [0, 1], [2, 3], [4]
+
+$ npm i it-batch
+
+<script>
tagLoading this module through a script tag will make it's exports available as ItBatch
in the global namespace.
<script src="https://unpkg.com/it-batch/dist/index.min.js"></script>
+
+Licensed under either of
+Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
+The final batch may be smaller than the max.
+import batch from 'it-batched-bytes'
import all from 'it-all'
// This can also be an iterator, generator, etc
const values = [
Uint8Array.from([0]),
Uint8Array.from([1]),
Uint8Array.from([2]),
Uint8Array.from([3]),
Uint8Array.from([4])
]
const batchSize = 2
const result = all(batch(values, { size: batchSize }))
console.info(result) // [0, 1], [2, 3], [4]
+
+Async sources must be awaited:
+import batch from 'it-batched-bytes'
import all from 'it-all'
const values = async function * () {
yield Uint8Array.from([0])
yield Uint8Array.from([1])
yield Uint8Array.from([2])
yield Uint8Array.from([3])
yield Uint8Array.from([4])
}
const batchSize = 2
const result = await all(batch(values, { size: batchSize }))
console.info(result) // [0, 1], [2, 3], [4]
+
+++Takes an async iterator that emits byte arrays and emits them as fixed size batches
+
The final batch may be smaller than the max.
+import batch from 'it-batched-bytes'
import all from 'it-all'
// This can also be an iterator, generator, etc
const values = [
Uint8Array.from([0]),
Uint8Array.from([1]),
Uint8Array.from([2]),
Uint8Array.from([3]),
Uint8Array.from([4])
]
const batchSize = 2
const result = all(batch(values, { size: batchSize }))
console.info(result) // [0, 1], [2, 3], [4]
+
+Async sources must be awaited:
+import batch from 'it-batched-bytes'
import all from 'it-all'
const values = async function * () {
yield Uint8Array.from([0])
yield Uint8Array.from([1])
yield Uint8Array.from([2])
yield Uint8Array.from([3])
yield Uint8Array.from([4])
}
const batchSize = 2
const result = await all(batch(values, { size: batchSize }))
console.info(result) // [0, 1], [2, 3], [4]
+
+$ npm i it-batched-bytes
+
+<script>
tagLoading this module through a script tag will make it's exports available as ItBatchedBytes
in the global namespace.
<script src="https://unpkg.com/it-batched-bytes/dist/index.min.js"></script>
+
+Licensed under either of
+Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
+Generate a stream of buffers, useful for testing purposes.
+import bufferStream from 'it-buffer-stream'
const totalLength = //... a big number
// all options are optional, defaults are shown
const options = {
chunkSize: 4096, // how many bytes will be in each buffer
collector: (buffer) => {
// will be called as each buffer is generated. the final buffer
// may be smaller than `chunkSize`
},
generator: async (size) => {
// return a promise that resolves to a buffer of length `size`
//
// if omitted, `Promise.resolve(crypto.randomBytes(size))` will be used
}
}
let buffers = []
for await (buf of bufferStream(totalLength, options)) {
buffers.push(buf)
}
// `buffers` is an array of Buffers the combined length of which === totalLength
+
+++An async iterator that emits buffers containing bytes up to a certain length
+
Generate a stream of buffers, useful for testing purposes.
+import bufferStream from 'it-buffer-stream'
const totalLength = //... a big number
// all options are optional, defaults are shown
const options = {
chunkSize: 4096, // how many bytes will be in each buffer
collector: (buffer) => {
// will be called as each buffer is generated. the final buffer
// may be smaller than `chunkSize`
},
generator: async (size) => {
// return a promise that resolves to a buffer of length `size`
//
// if omitted, `Promise.resolve(crypto.randomBytes(size))` will be used
}
}
let buffers = []
for await (buf of bufferStream(totalLength, options)) {
buffers.push(buf)
}
// `buffers` is an array of Buffers the combined length of which === totalLength
+
+$ npm i it-buffer-stream
+
+<script>
tagLoading this module through a script tag will make it's exports available as ItBufferStream
in the global namespace.
<script src="https://unpkg.com/it-buffer-stream/dist/index.min.js"></script>
+
+Licensed under either of
+Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
+This module makes it easy to send and receive bytes over streams.
+import { byteStream } from 'it-byte-stream'
const stream = byteStream(duplex)
// read the next chunk
const bytes = await stream.read()
// read the next five bytes
const fiveBytes = await stream.read(5)
// write bytes into the stream
await stream.write(Uint8Array.from([0, 1, 2, 3, 4]))
+
+++Read and write arbitrary bytes over a duplex stream
+
This module makes it easy to send and receive bytes over streams.
+import { byteStream } from 'it-byte-stream'
const stream = byteStream(duplex)
// read the next chunk
const bytes = await stream.read()
// read the next five bytes
const fiveBytes = await stream.read(5)
// write bytes into the stream
await stream.write(Uint8Array.from([0, 1, 2, 3, 4]))
+
+$ npm i it-byte-stream
+
+<script>
tagLoading this module through a script tag will make it's exports available as ItByteStream
in the global namespace.
<script src="https://unpkg.com/it-byte-stream/dist/index.min.js"></script>
+
+Licensed under either of
+Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
+Mostly useful for tests or when you want to be explicit about consuming an iterable without doing anything with any yielded values.
+import drain from 'it-drain'
// This can also be an iterator, generator, etc
const values = [0, 1, 2, 3, 4]
drain(values)
+
+Async sources must be awaited:
+import drain from 'it-drain'
const values = async function * {
yield * [0, 1, 2, 3, 4]
}
await drain(values())
+
+++Empties an async iterator
+
Mostly useful for tests or when you want to be explicit about consuming an iterable without doing anything with any yielded values.
+import drain from 'it-drain'
// This can also be an iterator, generator, etc
const values = [0, 1, 2, 3, 4]
drain(values)
+
+Async sources must be awaited:
+import drain from 'it-drain'
const values = async function * {
yield * [0, 1, 2, 3, 4]
}
await drain(values())
+
+$ npm i it-drain
+
+<script>
tagLoading this module through a script tag will make it's exports available as ItDrain
in the global namespace.
<script src="https://unpkg.com/it-drain/dist/index.min.js"></script>
+
+Licensed under either of
+Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
+Filter values out of an (async)iterable
+import all from 'it-all'
import filter from 'it-filter'
// This can also be an iterator, generator, etc
const values = [0, 1, 2, 3, 4]
const fn = (val, index) => val > 2 // Return boolean to keep item
const arr = all(filter(values, fn))
console.info(arr) // 3, 4
+
+Async sources and filter functions must be awaited:
+import all from 'it-all'
import filter from 'it-filter'
const values = async function * () {
yield * [0, 1, 2, 3, 4]
}
const fn = async val => (val, index) > 2 // Return boolean or promise of boolean to keep item
const arr = await all(filter(values, fn))
console.info(arr) // 3, 4
+
+++Filters the passed iterable by using the filter function
+
Filter values out of an (async)iterable
+import all from 'it-all'
import filter from 'it-filter'
// This can also be an iterator, generator, etc
const values = [0, 1, 2, 3, 4]
const fn = (val, index) => val > 2 // Return boolean to keep item
const arr = all(filter(values, fn))
console.info(arr) // 3, 4
+
+Async sources and filter functions must be awaited:
+import all from 'it-all'
import filter from 'it-filter'
const values = async function * () {
yield * [0, 1, 2, 3, 4]
}
const fn = async val => (val, index) > 2 // Return boolean or promise of boolean to keep item
const arr = await all(filter(values, fn))
console.info(arr) // 3, 4
+
+$ npm i it-filter
+
+<script>
tagLoading this module through a script tag will make it's exports available as ItFilter
in the global namespace.
<script src="https://unpkg.com/it-filter/dist/index.min.js"></script>
+
+Licensed under either of
+Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
+Return the first value in an (async)iterable
+import first from 'it-first'
// This can also be an iterator, generator, etc
const values = [0, 1, 2, 3, 4]
const res = first(values)
console.info(res) // 0
+
+Async sources must be awaited:
+import first from 'it-first'
const values = async function * () {
yield * [0, 1, 2, 3, 4]
}
const res = await first(values())
console.info(res) // 0
+
+++Returns the first result from an async iterator
+
Return the first value in an (async)iterable
+import first from 'it-first'
// This can also be an iterator, generator, etc
const values = [0, 1, 2, 3, 4]
const res = first(values)
console.info(res) // 0
+
+Async sources must be awaited:
+import first from 'it-first'
const values = async function * () {
yield * [0, 1, 2, 3, 4]
}
const res = await first(values())
console.info(res) // 0
+
+$ npm i it-first
+
+<script>
tagLoading this module through a script tag will make it's exports available as ItFirst
in the global namespace.
<script src="https://unpkg.com/it-first/dist/index.min.js"></script>
+
+Licensed under either of
+Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
+The final batch may be smaller than requested batch size.
+import batch from 'it-flat-batch'
import all from 'it-all'
// This can also be an iterator, async iterator, generator, etc
const values = [[0, 1, 2], [3], [4]]
const batchSize = 2
const result = all(batch(values, batchSize))
console.info(result) // [0, 1], [2, 3], [4]
+
+Async sources must be awaited:
+import batch from 'it-flat-batch'
import all from 'it-all'
const values = async function * () {
yield * [[0, 1, 2], [3], [4]]
}
const batchSize = 2
const result = await all(batch(values(), batchSize))
console.info(result) // [0, 1], [2, 3], [4]
+
+++Takes an async iterator that emits variable length arrays and emits them as fixed size batches
+
The final batch may be smaller than requested batch size.
+import batch from 'it-flat-batch'
import all from 'it-all'
// This can also be an iterator, async iterator, generator, etc
const values = [[0, 1, 2], [3], [4]]
const batchSize = 2
const result = all(batch(values, batchSize))
console.info(result) // [0, 1], [2, 3], [4]
+
+Async sources must be awaited:
+import batch from 'it-flat-batch'
import all from 'it-all'
const values = async function * () {
yield * [[0, 1, 2], [3], [4]]
}
const batchSize = 2
const result = await all(batch(values(), batchSize))
console.info(result) // [0, 1], [2, 3], [4]
+
+$ npm i it-flat-batch
+
+<script>
tagLoading this module through a script tag will make it's exports available as ItFlatBatch
in the global namespace.
<script src="https://unpkg.com/it-flat-batch/dist/index.min.js"></script>
+
+Licensed under either of
+Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
+Calls a function for each value in an (async)iterable.
+The function can be sync or async.
+Async functions can be awaited on so may slow down processing of the (async)iterable.
+import each from 'it-foreach'
import drain from 'it-drain'
// This can also be an iterator, generator, etc
const values = [0, 1, 2, 3, 4]
// prints [0, 0], [1, 1], [2, 2], [3, 3], [4, 4]
const arr = drain(
each(values, console.info)
)
+
+Async sources and callbacks must be awaited:
+import each from 'it-foreach'
import drain from 'it-drain'
const values = async function * () {
yield * [0, 1, 2, 3, 4]
}
// prints [0, 0], [1, 1], [2, 2], [3, 3], [4, 4]
const arr = await drain(
each(values(), console.info)
)
+
+++Invokes the passed function for each item in an iterable
+
Calls a function for each value in an (async)iterable.
+The function can be sync or async.
+Async functions can be awaited on so may slow down processing of the (async)iterable.
+import each from 'it-foreach'
import drain from 'it-drain'
// This can also be an iterator, generator, etc
const values = [0, 1, 2, 3, 4]
// prints [0, 0], [1, 1], [2, 2], [3, 3], [4, 4]
const arr = drain(
each(values, console.info)
)
+
+Async sources and callbacks must be awaited:
+import each from 'it-foreach'
import drain from 'it-drain'
const values = async function * () {
yield * [0, 1, 2, 3, 4]
}
// prints [0, 0], [1, 1], [2, 2], [3, 3], [4, 4]
const arr = await drain(
each(values(), console.info)
)
+
+$ npm i it-foreach
+
+<script>
tagLoading this module through a script tag will make it's exports available as ItForeach
in the global namespace.
<script src="https://unpkg.com/it-foreach/dist/index.min.js"></script>
+
+Licensed under either of
+Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
+Like glob
but async iterable.
File separators on Windows will be yielded as /
and not ``.
import glob from 'it-glob'
// All options are passed through to fast-glob
const options = {}
for await (const path of glob('/path/to/file', '**/*', options)) {
console.info(path)
}
+
+See the fast-glob docs for the full list of options.
+++Async iterable filename pattern matcher
+
Like glob
but async iterable.
File separators on Windows will be yielded as /
and not ``.
import glob from 'it-glob'
// All options are passed through to fast-glob
const options = {}
for await (const path of glob('/path/to/file', '**/*', options)) {
console.info(path)
}
+
+See the fast-glob docs for the full list of options.
+$ npm i it-glob
+
+Licensed under either of
+Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
+Return the last value from an (async)iterable.
+import last from 'it-last'
// This can also be an iterator, generator, etc
const values = [0, 1, 2, 3, 4]
const res = last(values)
console.info(res) // 4
+
+Async sources must be awaited:
+import last from 'it-last'
const values = async function * () {
yield * [0, 1, 2, 3, 4]
}
const res = await last(values())
console.info(res) // 4
+
+++Returns the last result from an async iterator
+
Return the last value from an (async)iterable.
+import last from 'it-last'
// This can also be an iterator, generator, etc
const values = [0, 1, 2, 3, 4]
const res = last(values)
console.info(res) // 4
+
+Async sources must be awaited:
+import last from 'it-last'
const values = async function * () {
yield * [0, 1, 2, 3, 4]
}
const res = await last(values())
console.info(res) // 4
+
+$ npm i it-last
+
+<script>
tagLoading this module through a script tag will make it's exports available as ItLast
in the global namespace.
<script src="https://unpkg.com/it-last/dist/index.min.js"></script>
+
+Licensed under either of
+Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
+Counts the number of items in an (async)iterable.
+N.b. will consume the iterable
+import length from 'it-length'
// This can also be an iterator, generator, etc
const values = [0, 1, 2, 3, 4]
const res = length(values)
console.info(res) // 5
+
+Async sources must be awaited:
+import length from 'it-length'
const values = async function * () {
yield * [0, 1, 2, 3, 4]
}
const res = await length(values())
console.info(res) // 5
+
+++Counts the number of items in an async iterable
+
Counts the number of items in an (async)iterable.
+N.b. will consume the iterable
+import length from 'it-length'
// This can also be an iterator, generator, etc
const values = [0, 1, 2, 3, 4]
const res = length(values)
console.info(res) // 5
+
+Async sources must be awaited:
+import length from 'it-length'
const values = async function * () {
yield * [0, 1, 2, 3, 4]
}
const res = await length(values())
console.info(res) // 5
+
+$ npm i it-length
+
+<script>
tagLoading this module through a script tag will make it's exports available as ItLength
in the global namespace.
<script src="https://unpkg.com/it-length/dist/index.min.js"></script>
+
+Licensed under either of
+Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
+This module makes it easy to send and receive length-prefixed byte arrays over streams.
+import { lpStream } from 'it-length-prefixed-stream'
const stream = lpStream(duplex)
// read the next length-prefixed chunk
const bytes = await stream.read()
// write a length-prefixed chunk
await stream.write(Uint8Array.from([0, 1, 2, 3, 4]))
// write several chunks, all individually length-prefixed
await stream.writeV([
Uint8Array.from([0, 1, 2, 3, 4]),
Uint8Array.from([5, 6, 7, 8, 9])
])
+
+++Read and write length-prefixed byte arrays over a duplex stream
+
This module makes it easy to send and receive length-prefixed byte arrays over streams.
+import { lpStream } from 'it-length-prefixed-stream'
const stream = lpStream(duplex)
// read the next length-prefixed chunk
const bytes = await stream.read()
// write a length-prefixed chunk
await stream.write(Uint8Array.from([0, 1, 2, 3, 4]))
// write several chunks, all individually length-prefixed
await stream.writeV([
Uint8Array.from([0, 1, 2, 3, 4]),
Uint8Array.from([5, 6, 7, 8, 9])
])
+
+$ npm i it-length-prefixed-stream
+
+<script>
tagLoading this module through a script tag will make it's exports available as ItLengthPrefixedStream
in the global namespace.
<script src="https://unpkg.com/it-length-prefixed-stream/dist/index.min.js"></script>
+
+Licensed under either of
+Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
+Convert one value from an (async)iterator into another.
+import map from 'it-map'
// This can also be an iterator, generator, etc
const values = [0, 1, 2, 3, 4]
const result = map(values, (val, index) => val++)
console.info(result) // [1, 2, 3, 4, 5]
+
+Async sources and transforms must be awaited:
+import map from 'it-map'
const values = async function * () {
yield * [0, 1, 2, 3, 4]
}
const result = await map(values(), async (val, index) => val++)
console.info(result) // [1, 2, 3, 4, 5]
+
+++Maps the values yielded by an async iterator
+
Convert one value from an (async)iterator into another.
+import map from 'it-map'
// This can also be an iterator, generator, etc
const values = [0, 1, 2, 3, 4]
const result = map(values, (val, index) => val++)
console.info(result) // [1, 2, 3, 4, 5]
+
+Async sources and transforms must be awaited:
+import map from 'it-map'
const values = async function * () {
yield * [0, 1, 2, 3, 4]
}
const result = await map(values(), async (val, index) => val++)
console.info(result) // [1, 2, 3, 4, 5]
+
+$ npm i it-map
+
+<script>
tagLoading this module through a script tag will make it's exports available as ItMap
in the global namespace.
<script src="https://unpkg.com/it-map/dist/index.min.js"></script>
+
+Licensed under either of
+Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
+Merge several (async)iterables into one, yield values as they arrive.
+Nb. sources are iterated over in parallel so the order of emitted items is not guaranteed.
+import merge from 'it-merge'
import all from 'it-all'
// This can also be an iterator, generator, etc
const values1 = [0, 1, 2, 3, 4]
const values2 = [5, 6, 7, 8, 9]
const arr = all(merge(values1, values2))
console.info(arr) // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
+
+Async sources must be awaited:
+import merge from 'it-merge'
import all from 'it-all'
// This can also be an iterator, async iterator, generator, etc
const values1 = async function * () {
yield * [0, 1, 2, 3, 4]
}
const values2 = async function * () {
yield * [5, 6, 7, 8, 9]
}
const arr = await all(merge(values1(), values2()))
console.info(arr) // 0, 1, 5, 6, 2, 3, 4, 7, 8, 9 <- nb. order is not guaranteed
+
+++Treat one or more iterables as a single iterable
+
Merge several (async)iterables into one, yield values as they arrive.
+Nb. sources are iterated over in parallel so the order of emitted items is not guaranteed.
+import merge from 'it-merge'
import all from 'it-all'
// This can also be an iterator, generator, etc
const values1 = [0, 1, 2, 3, 4]
const values2 = [5, 6, 7, 8, 9]
const arr = all(merge(values1, values2))
console.info(arr) // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
+
+Async sources must be awaited:
+import merge from 'it-merge'
import all from 'it-all'
// This can also be an iterator, async iterator, generator, etc
const values1 = async function * () {
yield * [0, 1, 2, 3, 4]
}
const values2 = async function * () {
yield * [5, 6, 7, 8, 9]
}
const arr = await all(merge(values1(), values2()))
console.info(arr) // 0, 1, 5, 6, 2, 3, 4, 7, 8, 9 <- nb. order is not guaranteed
+
+$ npm i it-merge
+
+<script>
tagLoading this module through a script tag will make it's exports available as ItMerge
in the global namespace.
<script src="https://unpkg.com/it-merge/dist/index.min.js"></script>
+
+Licensed under either of
+Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
+Allows iterating over multipart messages found in a HTTP request/
+import http from 'http'
import multipart from 'it-multipart'
http.createServer(async (req, res) => {
if (req.method === 'POST' && req.headers['content-type']) {
for await (const part of multipart(req)) {
console.log(`part with HTTP headers ${part.headers}`)
// nb. part.body must be consumed before the next part is emitted
for await (const chunk of part.body) {
console.log(`part with content ${part.name} contents:`, chunk.toString())
}
}
console.log('finished parsing')
res.writeHead(200)
res.end()
}
res.writeHead(404)
res.end()
}).listen(5001, () => {
console.log('server listening on port 5001')
})
+
+++Async iterable http multipart message parser
+
Allows iterating over multipart messages found in a HTTP request/
+import http from 'http'
import multipart from 'it-multipart'
http.createServer(async (req, res) => {
if (req.method === 'POST' && req.headers['content-type']) {
for await (const part of multipart(req)) {
console.log(`part with HTTP headers ${part.headers}`)
// nb. part.body must be consumed before the next part is emitted
for await (const chunk of part.body) {
console.log(`part with content ${part.name} contents:`, chunk.toString())
}
}
console.log('finished parsing')
res.writeHead(200)
res.end()
}
res.writeHead(404)
res.end()
}).listen(5001, () => {
console.log('server listening on port 5001')
})
+
+$ npm i it-multipart
+
+Licensed under either of
+Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
+Turn (async)iterable values into JSON and back again.
+import ndjson from 'it-ndjson'
import all from 'it-all'
// This can also be an iterator, async iterator, generator, etc
const values = [0, 1, 2, 3, 4]
const arr = await all(ndjson.stringify(values))
console.info(arr) // '0\n', '1\n', '2\n', '3\n', '4\n'
const res = await all(ndjson.parse(arr))
console.info(res) // [0, 1, 2, 3, 4]
+
+++Parse iterators as ndjson and transform iterators to ndjson
+
Turn (async)iterable values into JSON and back again.
+import ndjson from 'it-ndjson'
import all from 'it-all'
// This can also be an iterator, async iterator, generator, etc
const values = [0, 1, 2, 3, 4]
const arr = await all(ndjson.stringify(values))
console.info(arr) // '0\n', '1\n', '2\n', '3\n', '4\n'
const res = await all(ndjson.parse(arr))
console.info(res) // [0, 1, 2, 3, 4]
+
+$ npm i it-ndjson
+
+<script>
tagLoading this module through a script tag will make it's exports available as ItNdjson
in the global namespace.
<script src="https://unpkg.com/it-ndjson/dist/index.min.js"></script>
+
+Licensed under either of
+Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
+Takes an (async) iterable that emits promise-returning functions, invokes them in parallel up to the concurrency limit and emits the results as they become available, optionally in the same order as the input
+import parallel from 'it-parallel'
import all from 'it-all'
import delay from 'delay'
// This can also be an iterator, async iterator, generator, etc
const input = [
async () => {
console.info('start 1')
await delay(500)
console.info('end 1')
return 1
},
async () => {
console.info('start 2')
await delay(200)
console.info('end 2')
return 2
},
async () => {
console.info('start 3')
await delay(100)
console.info('end 3')
return 3
}
]
const result = await all(parallel(input, {
concurrency: 2
}))
// output:
// start 1
// start 2
// end 2
// start 3
// end 3
// end 1
console.info(result) // [2, 3, 1]
+
+If order is important, pass ordered: true
as an option:
const result = await all(parallel(input, {
concurrency: 2,
ordered: true
}))
// output:
// start 1
// start 2
// end 2
// start 3
// end 3
// end 1
console.info(result) // [1, 2, 3]
+
+++Process incoming async(iterable) functions in parallel
+
Takes an (async) iterable that emits promise-returning functions, invokes them in parallel up to the concurrency limit and emits the results as they become available, optionally in the same order as the input
+import parallel from 'it-parallel'
import all from 'it-all'
import delay from 'delay'
// This can also be an iterator, async iterator, generator, etc
const input = [
async () => {
console.info('start 1')
await delay(500)
console.info('end 1')
return 1
},
async () => {
console.info('start 2')
await delay(200)
console.info('end 2')
return 2
},
async () => {
console.info('start 3')
await delay(100)
console.info('end 3')
return 3
}
]
const result = await all(parallel(input, {
concurrency: 2
}))
// output:
// start 1
// start 2
// end 2
// start 3
// end 3
// end 1
console.info(result) // [2, 3, 1]
+
+If order is important, pass ordered: true
as an option:
const result = await all(parallel(input, {
concurrency: 2,
ordered: true
}))
// output:
// start 1
// start 2
// end 2
// start 3
// end 3
// end 1
console.info(result) // [1, 2, 3]
+
+$ npm i it-parallel
+
+<script>
tagLoading this module through a script tag will make it's exports available as ItParallel
in the global namespace.
<script src="https://unpkg.com/it-parallel/dist/index.min.js"></script>
+
+Licensed under either of
+Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
+Takes an async iterator that emits promise-returning functions, invokes them in parallel and emits the results in the same order as the input.
+The final batch may be smaller than the batch size.
+import parallelBatch from 'it-parallel-batch'
import all from 'it-all'
import delay from 'delay'
// This can also be an iterator, async iterator, generator, etc
const input = [
async () => {
await delay(500)
return 1
},
async () => {
await delay(200)
return 2
},
async () => {
await delay(100)
return 3
}
]
const batchSize = 2
const result = await all(parallelBatch(input, batchSize))
console.info(result) // [1, 2, 3]
+
+++Process (async)iterable values as functions with concurrency control
+
Takes an async iterator that emits promise-returning functions, invokes them in parallel and emits the results in the same order as the input.
+The final batch may be smaller than the batch size.
+import parallelBatch from 'it-parallel-batch'
import all from 'it-all'
import delay from 'delay'
// This can also be an iterator, async iterator, generator, etc
const input = [
async () => {
await delay(500)
return 1
},
async () => {
await delay(200)
return 2
},
async () => {
await delay(100)
return 3
}
]
const batchSize = 2
const result = await all(parallelBatch(input, batchSize))
console.info(result) // [1, 2, 3]
+
+$ npm i it-parallel-batch
+
+<script>
tagLoading this module through a script tag will make it's exports available as ItParallelBatch
in the global namespace.
<script src="https://unpkg.com/it-parallel-batch/dist/index.min.js"></script>
+
+Licensed under either of
+Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
+Lets you look at the contents of an async iterator and decide what to do
+import peekable from 'it-peekable'
// This can also be an iterator, generator, etc
const values = [0, 1, 2, 3, 4]
const it = peekable(value)
const first = it.peek()
console.info(first) // 0
it.push(first)
console.info([...it])
// [ 0, 1, 2, 3, 4 ]
+
+Async sources must be awaited:
+import peekable from 'it-peekable'
const values = async function * () {
yield * [0, 1, 2, 3, 4]
}
const it = peekable(values())
const first = await it.peek()
console.info(first) // 0
it.push(first)
console.info(await all(it))
// [ 0, 1, 2, 3, 4 ]
+
+++Allows peeking/pushing an iterable
+
Lets you look at the contents of an async iterator and decide what to do
+import peekable from 'it-peekable'
// This can also be an iterator, generator, etc
const values = [0, 1, 2, 3, 4]
const it = peekable(value)
const first = it.peek()
console.info(first) // 0
it.push(first)
console.info([...it])
// [ 0, 1, 2, 3, 4 ]
+
+Async sources must be awaited:
+import peekable from 'it-peekable'
const values = async function * () {
yield * [0, 1, 2, 3, 4]
}
const it = peekable(values())
const first = await it.peek()
console.info(first) // 0
it.push(first)
console.info(await all(it))
// [ 0, 1, 2, 3, 4 ]
+
+$ npm i it-peekable
+
+<script>
tagLoading this module through a script tag will make it's exports available as ItPeekable
in the global namespace.
<script src="https://unpkg.com/it-peekable/dist/index.min.js"></script>
+
+Licensed under either of
+Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
+This module makes it easy to send and receive length-prefixed Protobuf encoded +messages over streams.
+import { pbStream } from 'it-protobuf-stream'
import { MessageType } from './src/my-message-type.js'
// RequestType and ResponseType have been generate from `.proto` files and have
// `.encode` and `.decode` methods for serialization/deserialization
const stream = pbStream(duplex)
// write a message to the stream
stream.write({
foo: 'bar'
}, MessageType)
// read a message from the stream
const res = await stream.read(MessageType)
+
+++Read and write protobuf messages over a duplex stream
+
This module makes it easy to send and receive length-prefixed Protobuf encoded +messages over streams.
+import { pbStream } from 'it-protobuf-stream'
import { MessageType } from './src/my-message-type.js'
// RequestType and ResponseType have been generate from `.proto` files and have
// `.encode` and `.decode` methods for serialization/deserialization
const stream = pbStream(duplex)
// write a message to the stream
stream.write({
foo: 'bar'
}, MessageType)
// read a message from the stream
const res = await stream.read(MessageType)
+
+$ npm i it-protobuf-stream
+
+<script>
tagLoading this module through a script tag will make it's exports available as ItProtobufStream
in the global namespace.
<script src="https://unpkg.com/it-protobuf-stream/dist/index.min.js"></script>
+
+Licensed under either of
+Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
+A pushable async generator that waits until the current value is consumed +before allowing a new value to be pushed.
+Useful for when you don't want to keep memory usage under control and/or +allow a downstream consumer to dictate how fast data flows through a pipe, +but you want to be able to apply a transform to that data.
+import { queuelessPushable } from 'it-queueless-pushable'
const pushable = queuelessPushable<string>()
// run asynchronously
Promise.resolve().then(async () => {
// push a value - the returned promise will not resolve until the value is
// read from the pushable
await pushable.push('hello')
})
// read a value
const result = await pushable.next()
console.info(result) // { done: false, value: 'hello' }
+
+++A pushable queue that waits until a value is consumed before accepting another
+
Collects all Uint8Array
values from an (async)iterable and returns them as a single Uint8Array
.
import toBuffer from 'it-to-buffer'
// This can also be an iterator, generator, etc
const values = [Buffer.from([0, 1]), Buffer.from([2, 3])]
const result = toBuffer(values)
console.info(result) // Buffer[0, 1, 2, 3]
+
+Async sources must be awaited:
+import toBuffer from 'it-to-buffer'
const values = async function * () {
yield Buffer.from([0, 1])
yield Buffer.from([2, 3])
}
const result = await toBuffer(values())
console.info(result) // Buffer[0, 1, 2, 3]
+
+$ npm i it-queueless-pushable
+
+<script>
tagLoading this module through a script tag will make it's exports available as ItQueuelessPushable
in the global namespace.
<script src="https://unpkg.com/it-queueless-pushable/dist/index.min.js"></script>
+
+Licensed under either of
+Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
+Reduce the values of an (async)iterable to a single value.
+import reduce from 'it-reduce'
// This can also be an iterator, generator, etc
const values = [0, 1, 2, 3, 4]
const result = reduce(values, (acc, curr, index) => acc + curr, 0)
console.info(result) // 10
+
+Async sources must be awaited:
+import reduce from 'it-reduce'
const values = async function * () {
yield * [0, 1, 2, 3, 4]
}
const result = await reduce(values(), (acc, curr, index) => acc + curr, 0)
console.info(result) // 10
+
+++Reduces the values yielded from an async iterator
+
Reduce the values of an (async)iterable to a single value.
+import reduce from 'it-reduce'
// This can also be an iterator, generator, etc
const values = [0, 1, 2, 3, 4]
const result = reduce(values, (acc, curr, index) => acc + curr, 0)
console.info(result) // 10
+
+Async sources must be awaited:
+import reduce from 'it-reduce'
const values = async function * () {
yield * [0, 1, 2, 3, 4]
}
const result = await reduce(values(), (acc, curr, index) => acc + curr, 0)
console.info(result) // 10
+
+$ npm i it-reduce
+
+<script>
tagLoading this module through a script tag will make it's exports available as ItReduce
in the global namespace.
<script src="https://unpkg.com/it-reduce/dist/index.min.js"></script>
+
+Licensed under either of
+Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
+Your RPC objects must follow a few rules:
+.return
/.throw
methods invokedvoid
, but if so they must not throwimport { rpc } from 'it-rpc'
// the invocation target interface - used by the client and the server
interface Target {
sayHello(): Promise<string>
}
// the target implementation, lives on the server side
const target: Target = {
async sayHello () {
return 'hello'
}
}
// create client and server
const server = rpc()
const client = rpc()
// pipe the streams together
void server.sink(client.source)
void client.sink(server.source)
// a string that is the same on both the server and the client
const objectName = 'target'
// expose target implementation to RPC calls on the server side
server.createTarget(objectName, target)
// create a client-side version of target
const clientTarget = client.createClient<Target>(objectName)
// invoke a remote method
await clientTarget.sayHello() // 'hello'
+
+import { rpc } from 'it-rpc'
interface Target {
streamingMethod(): AsyncGenerator<Uint8Array>
}
const target: Target = {
async * streamingMethod () {
yield Uint8Array.from([0, 1, 2, 3])
yield Uint8Array.from([4, 5, 6, 7])
}
}
const server = rpc()
const client = rpc()
void server.sink(client.source)
void client.sink(server.source)
const objectName = 'target'
server.createTarget(objectName, target)
const clientTarget = client.createClient<Target>(objectName)
for await (const buf of clientTarget.streamingMethod()) {
console.info(buf)
// Uint8Array([0, 1, 2, 3])
// Uint8Array([4, 5, 6, 7])
}
+
+Any abort signals passed as arguments will have equivalents passed on to the
+remote method invocation and these will fire their abort
event when the
+client side signal fires.
import { rpc } from 'it-rpc'
interface Target {
slowStream(arg: { signal: AbortSignal }): AsyncGenerator<Uint8Array>
}
const target: Target = {
async * slowStream () {
await new Promise<void>((resolve) => {
setTimeout(() => {
resolve()
}, 5000)
})
yield Uint8Array.from([0, 1, 2, 3])
yield Uint8Array.from([4, 5, 6, 7])
}
}
const server = rpc()
const client = rpc()
void server.sink(client.source)
void client.sink(server.source)
const objectName = 'target'
server.createTarget(objectName, target)
const clientTarget = client.createClient<Target>(objectName)
const signal = AbortSignal.timeout(1000)
for await (const buf of clientTarget.slowStream({ signal })) {
console.info(buf)
// explodes after 1s
}
+
+It is possible to extend it-rpc
to support serializing/deserializing custom types by passing ValueCodec
s to the constructor.
Each ValueCodec
needs a unique type
field which identifies the value type on the wire.
it-rpc
uses value types starting at 1024
and has a catch-all 2147483647
type which resolves to plain objects.
You should define your type values higher than the max value it-rpc
uses (2048
is a safe value) but lower than the catch-all type value.
Matching codecs are searched for in type
order so you can override the built-in codecs by specifying a type
field lower than 1024
.
++[!IMPORTANT] +Both the server and the client must be configured with the same set of custom
+ValueCodec
s
import { encode, decode } from 'cborg'
import { rpc } from 'it-rpc'
import type { ValueCodec } from 'it-rpc'
// a custom type we want to encode
class MyClass {
field: string
constructor (val: string) {
this.field = val
}
getField () {
return this.field
}
}
// our custom codec
const codec: ValueCodec<MyClass> = {
type: 2048,
canEncode: (val) => val instanceof MyClass,
encode: (val) => encode({ field: val.getField() }),
decode: (buf) => {
const decoded = decode(buf)
return new MyClass(decoded.field)
}
}
// configure the server/client with the custom codec
const server = rpc({
valueCodecs: [
codec
]
})
const client = rpc({
valueCodecs: [
codec
]
})
void server.sink(client.source)
void client.sink(server.source)
interface Target {
getFieldFromArg(arg: MyClass): Promise<string>
}
const target: Target = {
async getFieldFromArg (arg) {
return arg.getField()
}
}
const objectName = 'target'
server.createTarget(objectName, target)
const clientTarget = client.createClient<Target>(objectName)
const val = new MyClass('hello')
await clientTarget.getFieldFromArg(val) // 'hello'
+
+++Schema-free RPC over async iterables
+
Your RPC objects must follow a few rules:
+.return
/.throw
methods invokedvoid
, but if so they must not throwimport { rpc } from 'it-rpc'
// the invocation target interface - used by the client and the server
interface Target {
sayHello(): Promise<string>
}
// the target implementation, lives on the server side
const target: Target = {
async sayHello () {
return 'hello'
}
}
// create client and server
const server = rpc()
const client = rpc()
// pipe the streams together
void server.sink(client.source)
void client.sink(server.source)
// a string that is the same on both the server and the client
const objectName = 'target'
// expose target implementation to RPC calls on the server side
server.createTarget(objectName, target)
// create a client-side version of target
const clientTarget = client.createClient<Target>(objectName)
// invoke a remote method
await clientTarget.sayHello() // 'hello'
+
+import { rpc } from 'it-rpc'
interface Target {
streamingMethod(): AsyncGenerator<Uint8Array>
}
const target: Target = {
async * streamingMethod () {
yield Uint8Array.from([0, 1, 2, 3])
yield Uint8Array.from([4, 5, 6, 7])
}
}
const server = rpc()
const client = rpc()
void server.sink(client.source)
void client.sink(server.source)
const objectName = 'target'
server.createTarget(objectName, target)
const clientTarget = client.createClient<Target>(objectName)
for await (const buf of clientTarget.streamingMethod()) {
console.info(buf)
// Uint8Array([0, 1, 2, 3])
// Uint8Array([4, 5, 6, 7])
}
+
+Any abort signals passed as arguments will have equivalents passed on to the
+remote method invocation and these will fire their abort
event when the
+client side signal fires.
import { rpc } from 'it-rpc'
interface Target {
slowStream(arg: { signal: AbortSignal }): AsyncGenerator<Uint8Array>
}
const target: Target = {
async * slowStream () {
await new Promise<void>((resolve) => {
setTimeout(() => {
resolve()
}, 5000)
})
yield Uint8Array.from([0, 1, 2, 3])
yield Uint8Array.from([4, 5, 6, 7])
}
}
const server = rpc()
const client = rpc()
void server.sink(client.source)
void client.sink(server.source)
const objectName = 'target'
server.createTarget(objectName, target)
const clientTarget = client.createClient<Target>(objectName)
const signal = AbortSignal.timeout(1000)
for await (const buf of clientTarget.slowStream({ signal })) {
console.info(buf)
// explodes after 1s
}
+
+It is possible to extend it-rpc
to support serializing/deserializing custom types by passing ValueCodec
s to the constructor.
Each ValueCodec
needs a unique type
field which identifies the value type on the wire.
it-rpc
uses value types starting at 1024
and has a catch-all 2147483647
type which resolves to plain objects.
You should define your type values higher than the max value it-rpc
uses (2048
is a safe value) but lower than the catch-all type value.
Matching codecs are searched for in type
order so you can override the built-in codecs by specifying a type
field lower than 1024
.
++[!IMPORTANT] +Both the server and the client must be configured with the same set of custom
+ValueCodec
s
import { encode, decode } from 'cborg'
import { rpc } from 'it-rpc'
import type { ValueCodec } from 'it-rpc'
// a custom type we want to encode
class MyClass {
field: string
constructor (val: string) {
this.field = val
}
getField () {
return this.field
}
}
// our custom codec
const codec: ValueCodec<MyClass> = {
type: 2048,
canEncode: (val) => val instanceof MyClass,
encode: (val) => encode({ field: val.getField() }),
decode: (buf) => {
const decoded = decode(buf)
return new MyClass(decoded.field)
}
}
// configure the server/client with the custom codec
const server = rpc({
valueCodecs: [
codec
]
})
const client = rpc({
valueCodecs: [
codec
]
})
void server.sink(client.source)
void client.sink(server.source)
interface Target {
getFieldFromArg(arg: MyClass): Promise<string>
}
const target: Target = {
async getFieldFromArg (arg) {
return arg.getField()
}
}
const objectName = 'target'
server.createTarget(objectName, target)
const clientTarget = client.createClient<Target>(objectName)
const val = new MyClass('hello')
await clientTarget.getFieldFromArg(val) // 'hello'
+
+$ npm i it-rpc
+
+<script>
tagLoading this module through a script tag will make it's exports available as ItRpc
in the global namespace.
<script src="https://unpkg.com/it-rpc/dist/index.min.js"></script>
+
+Licensed under either of
+Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
+For when you are only interested in later values from an (async)iterable.
+import take from 'it-skip'
import all from 'it-all'
// This can also be an iterator, generator, etc
const values = [0, 1, 2, 3, 4]
const arr = all(skip(values, 2))
console.info(arr) // 2, 3, 4
+
+Async sources must be awaited:
+import take from 'it-skip'
import all from 'it-all'
const values = async function * () {
yield * [0, 1, 2, 3, 4]
}
const arr = await all(skip(values(), 2))
console.info(arr) // 2, 3, 4
+
+++Skip items from an iterable
+
For when you are only interested in later values from an (async)iterable.
+import take from 'it-skip'
import all from 'it-all'
// This can also be an iterator, generator, etc
const values = [0, 1, 2, 3, 4]
const arr = all(skip(values, 2))
console.info(arr) // 2, 3, 4
+
+Async sources must be awaited:
+import take from 'it-skip'
import all from 'it-all'
const values = async function * () {
yield * [0, 1, 2, 3, 4]
}
const arr = await all(skip(values(), 2))
console.info(arr) // 2, 3, 4
+
+$ npm i it-skip
+
+<script>
tagLoading this module through a script tag will make it's exports available as ItSkip
in the global namespace.
<script src="https://unpkg.com/it-skip/dist/index.min.js"></script>
+
+Licensed under either of
+Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
+Consumes all values from an (async)iterable and returns them sorted by the passed sort function.
+import sort from 'it-sort'
import all from 'it-all'
const sorter = (a, b) => {
return a.localeCompare(b)
}
// This can also be an iterator, generator, etc
const values = ['foo', 'bar']
const arr = all(sort(values, sorter))
console.info(arr) // 'bar', 'foo'
+
+Async sources must be awaited:
+import sort from 'it-sort'
import all from 'it-all'
const sorter = (a, b) => {
return a.localeCompare(b)
}
const values = async function * () {
yield * ['foo', 'bar']
}
const arr = await all(sort(values, sorter))
console.info(arr) // 'bar', 'foo'
+
+++Collects all values from an async iterator, sorts them using the passed function and yields them
+
Consumes all values from an (async)iterable and returns them sorted by the passed sort function.
+import sort from 'it-sort'
import all from 'it-all'
const sorter = (a, b) => {
return a.localeCompare(b)
}
// This can also be an iterator, generator, etc
const values = ['foo', 'bar']
const arr = all(sort(values, sorter))
console.info(arr) // 'bar', 'foo'
+
+Async sources must be awaited:
+import sort from 'it-sort'
import all from 'it-all'
const sorter = (a, b) => {
return a.localeCompare(b)
}
const values = async function * () {
yield * ['foo', 'bar']
}
const arr = await all(sort(values, sorter))
console.info(arr) // 'bar', 'foo'
+
+$ npm i it-sort
+
+<script>
tagLoading this module through a script tag will make it's exports available as ItSort
in the global namespace.
<script src="https://unpkg.com/it-sort/dist/index.min.js"></script>
+
+Licensed under either of
+Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
+Searches Uint8Array
s emitted by an (async)iterable for a delimiter and yields chunks split by that delimiter.
import split from 'it-split'
const encoder = new TextEncoder()
// This can also be an iterator, generator, etc
const values = [
encoder.encode('hello\nwor'),
encoder.encode('ld')
]
const arr = all(split(values))
console.info(arr) // [encoder.encode('hello'), encoder.encode('world')]
+
+You can also split by arbitrary delimiters:
+const values = [
Uint8Array.from([0, 1, 2, 3]),
Uint8Array.from([0, 1, 2, 3]),
Uint8Array.from([1, 1, 2])
]
const delimiter = Uint8Array.from([1, 2])
const arr = all(split(values, {
delimiter
}))
console.info(arr) // [ Buffer.from([0]), Buffer.from([3, 0]), Buffer.from([3, 1]) ]
+
+Async sources must be awaited:
+import split from 'it-split'
const encoder = new TextEncoder()
const values = async function * () {
yield * [
encoder.encode('hello\nwor'),
encoder.encode('ld')
]
}
const arr = await all(split(values()))
console.info(arr) // [encoder.encode('hello'), encoder.encode('world')]
+
+++Splits Uint8Arrays emitted by an (async) iterable by a delimiter
+
Searches Uint8Array
s emitted by an (async)iterable for a delimiter and yields chunks split by that delimiter.
import split from 'it-split'
const encoder = new TextEncoder()
// This can also be an iterator, generator, etc
const values = [
encoder.encode('hello\nwor'),
encoder.encode('ld')
]
const arr = all(split(values))
console.info(arr) // [encoder.encode('hello'), encoder.encode('world')]
+
+You can also split by arbitrary delimiters:
+const values = [
Uint8Array.from([0, 1, 2, 3]),
Uint8Array.from([0, 1, 2, 3]),
Uint8Array.from([1, 1, 2])
]
const delimiter = Uint8Array.from([1, 2])
const arr = all(split(values, {
delimiter
}))
console.info(arr) // [ Buffer.from([0]), Buffer.from([3, 0]), Buffer.from([3, 1]) ]
+
+Async sources must be awaited:
+import split from 'it-split'
const encoder = new TextEncoder()
const values = async function * () {
yield * [
encoder.encode('hello\nwor'),
encoder.encode('ld')
]
}
const arr = await all(split(values()))
console.info(arr) // [encoder.encode('hello'), encoder.encode('world')]
+
+$ npm i it-split
+
+<script>
tagLoading this module through a script tag will make it's exports available as ItSplit
in the global namespace.
<script src="https://unpkg.com/it-split/dist/index.min.js"></script>
+
+Licensed under either of
+Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
+For when you only want a few values out of an (async)iterable.
+import take from 'it-take'
import all from 'it-all'
// This can also be an iterator, generator, etc
const values = [0, 1, 2, 3, 4]
const arr = all(take(values, 2))
console.info(arr) // 0, 1
+
+Async sources must be awaited:
+import take from 'it-take'
import all from 'it-all'
const values = async function * () {
yield * [0, 1, 2, 3, 4]
}
const arr = await all(take(values(), 2))
console.info(arr) // 0, 1
+
+++Stop iteration after n items have been received
+
For when you only want a few values out of an (async)iterable.
+import take from 'it-take'
import all from 'it-all'
// This can also be an iterator, generator, etc
const values = [0, 1, 2, 3, 4]
const arr = all(take(values, 2))
console.info(arr) // 0, 1
+
+Async sources must be awaited:
+import take from 'it-take'
import all from 'it-all'
const values = async function * () {
yield * [0, 1, 2, 3, 4]
}
const arr = await all(take(values(), 2))
console.info(arr) // 0, 1
+
+$ npm i it-take
+
+<script>
tagLoading this module through a script tag will make it's exports available as ItTake
in the global namespace.
<script src="https://unpkg.com/it-take/dist/index.min.js"></script>
+
+Licensed under either of
+Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
+Turns an (async)iterable into a W3C ReadbleStream.
+import toBrowserReadableStream from 'it-to-browser-readablestream'
// This can also be an iterator, async iterator, generator, etc
const values = [Buffer.from([0, 1]), Buffer.from([2, 3])]
const stream = await toBrowserReadableStream(values)
for await (const buf of stream) {
console.info(buf) // Buffer[0, 1]
}
+
+++Takes an async iterator and turns it into a browser readable stream
+
Turns an (async)iterable into a W3C ReadbleStream.
+import toBrowserReadableStream from 'it-to-browser-readablestream'
// This can also be an iterator, async iterator, generator, etc
const values = [Buffer.from([0, 1]), Buffer.from([2, 3])]
const stream = await toBrowserReadableStream(values)
for await (const buf of stream) {
console.info(buf) // Buffer[0, 1]
}
+
+$ npm i it-to-browser-readablestream
+
+<script>
tagLoading this module through a script tag will make it's exports available as ItToBrowserReadablestream
in the global namespace.
<script src="https://unpkg.com/it-to-browser-readablestream/dist/index.min.js"></script>
+
+Licensed under either of
+Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
+Collects all Uint8Array
values from an (async)iterable and returns them as a single Uint8Array
.
import toBuffer from 'it-to-buffer'
// This can also be an iterator, generator, etc
const values = [Buffer.from([0, 1]), Buffer.from([2, 3])]
const result = toBuffer(values)
console.info(result) // Buffer[0, 1, 2, 3]
+
+Async sources must be awaited:
+import toBuffer from 'it-to-buffer'
const values = async function * () {
yield Buffer.from([0, 1])
yield Buffer.from([2, 3])
}
const result = await toBuffer(values())
console.info(result) // Buffer[0, 1, 2, 3]
+
+++Takes an async iterator that yields buffers and concatenates them all together
+
Collects all Uint8Array
values from an (async)iterable and returns them as a single Uint8Array
.
import toBuffer from 'it-to-buffer'
// This can also be an iterator, generator, etc
const values = [Buffer.from([0, 1]), Buffer.from([2, 3])]
const result = toBuffer(values)
console.info(result) // Buffer[0, 1, 2, 3]
+
+Async sources must be awaited:
+import toBuffer from 'it-to-buffer'
const values = async function * () {
yield Buffer.from([0, 1])
yield Buffer.from([2, 3])
}
const result = await toBuffer(values())
console.info(result) // Buffer[0, 1, 2, 3]
+
+$ npm i it-to-buffer
+
+<script>
tagLoading this module through a script tag will make it's exports available as ItToBuffer
in the global namespace.
<script src="https://unpkg.com/it-to-buffer/dist/index.min.js"></script>
+
+Licensed under either of
+Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
+
Optional override for formatting stack traces
+