diff --git a/README.md b/README.md index 0890e67..e781ea5 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Fetch and parse XML documents using the power of JavaScript web streams and asyn ## Usage -See the `examples` directory for platform specific examples. +Add dependency from JSR: [@dbushell/xml-streamify](https://jsr.io/@dbushell/xml-streamify). See the `examples` directory for platform specific examples. ```javascript import {parse} from "jsr:@dbushell/xml-streamify@0.2"; diff --git a/deno.json b/deno.json index c8cb1ca..73ad881 100644 --- a/deno.json +++ b/deno.json @@ -1,6 +1,6 @@ { "name": "@dbushell/xml-streamify", - "version": "0.2.1", + "version": "0.2.2", "exports": { ".": "./mod.ts", "./node": "./src/node.ts", diff --git a/mod.ts b/mod.ts index 1017ecb..60da9fc 100644 --- a/mod.ts +++ b/mod.ts @@ -1,3 +1,7 @@ +/** + * @module + * Fetch and parse XML documents using web streams and async iterators. + */ export * from './src/node.ts'; export * from './src/parse.ts'; export * from './src/stream.ts'; diff --git a/src/node.ts b/src/node.ts index 74f3978..00f5f2f 100644 --- a/src/node.ts +++ b/src/node.ts @@ -1,6 +1,8 @@ /** - * XML node with helper methods to read data and traverse the tree + * @module + * Module exports an XML Node class */ +/** XML node with helper methods to read data and traverse the tree */ export class Node { #type: string; #children: Array; diff --git a/src/parse.ts b/src/parse.ts index 6892ec1..c26d205 100644 --- a/src/parse.ts +++ b/src/parse.ts @@ -1,3 +1,7 @@ +/** + * @module + * Module export an async generator function for parsing a streamed XML document. + */ import type {ParseOptions} from './types.ts'; import {NodeType} from './types.ts'; import {Node} from './node.ts'; @@ -9,6 +13,12 @@ const ignoreTypes: Partial> = { [NodeType.DOCTYPE]: 'ignoreDoctype' } as const; +/** + * Async generator function for parsing a streamed XML document + * @param url URL to fetch and parse + * @param options Parsing options {@link ParseOptions} + * @returns Yields parsed XML nodes {@link Node} + */ export async function* parse( url: string | URL, options?: ParseOptions diff --git a/src/stream.ts b/src/stream.ts index 403253d..6656b7e 100644 --- a/src/stream.ts +++ b/src/stream.ts @@ -1,3 +1,7 @@ +/** + * @module + * Module exports a `TransformStream` class for decoding binary XML streams into structured data. + */ import {NodeType, StateType} from './types.ts'; type State = NodeType | StateType; @@ -25,6 +29,7 @@ const ENTITIES = { } } as const; +/** Transformer object for `TransformStream` constructed by `XMLStream` */ export const transformer: Transformer & { buf: string; state: State; @@ -91,9 +96,7 @@ export const transformer: Transformer & { } }; -/** - * Convert a binary XML stream into a stream of XML nodes - */ +/** Transform a binary XML stream into a stream of structured XML data */ export class XMLStream extends TransformStream { constructor() { super({...transformer}); diff --git a/src/types.ts b/src/types.ts index 9d0c60a..390d14e 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,3 +1,8 @@ +/** + * @module + * Types for `@dbushell/xml-streamify` + */ +/** Options for `parse` async generator function */ export interface ParseOptions { /** Abort signal for fetch and parser */ signal?: AbortSignal;