edge-sitemap
Advanced tools
Comparing version 1.0.6 to 1.1.1
@@ -44,2 +44,9 @@ /** | ||
/** | ||
* @returns {string} | ||
*/ | ||
get [Symbol.toStringTag]() { | ||
return 'SitemapTransformer' | ||
} | ||
/** @type {TransformerFlushCallback<string>} */ | ||
@@ -132,2 +139,9 @@ flush(controller) { | ||
/** | ||
* @returns {string} | ||
*/ | ||
get [Symbol.toStringTag]() { | ||
return 'SitemapStream' | ||
} | ||
/** | ||
* @returns {ReadableStream<string>} | ||
@@ -134,0 +148,0 @@ */ |
@@ -42,3 +42,3 @@ { | ||
"types": "./src/index.d.ts", | ||
"version": "1.0.6", | ||
"version": "1.1.1", | ||
"scripts": { | ||
@@ -45,0 +45,0 @@ "build": "tsc", |
@@ -10,24 +10,23 @@ # Edge Sitemap | ||
async function writeSitemap(writer) { | ||
await writer.ready | ||
await Promise.all([ | ||
writer.write({ | ||
loc: '/', | ||
priority: 1.0, | ||
}), | ||
writer.write({ | ||
loc: '/privacy', | ||
priority: 0.1, | ||
}), | ||
]) | ||
await writer.close() | ||
function createReadableStream() { | ||
return new ReadableStream({ | ||
start(controller) { | ||
controller.enqueue({ | ||
loc: '/', | ||
priority: 1.0, | ||
}) | ||
controller.enqueue({ | ||
loc: '/privacy', | ||
priority: 0.1, | ||
}) | ||
controller.close() | ||
}, | ||
}) | ||
} | ||
addEventListener('fetch', (event) => { | ||
const { readable: smReadable, writable: smWritable } = new Sitemap({ | ||
baseURL: 'https://example.com/', | ||
}) | ||
const body = smReadable.pipeThrough(new TextEncoderStream()) | ||
const baseURL = 'https://example.com/' | ||
const body = createReadableStream() | ||
.pipeThrough(new SitemapStream({ baseURL })) | ||
.pipeThrough(new TextEncoderStream()) | ||
const response = new Response(body, { | ||
@@ -39,6 +38,4 @@ headers: { | ||
writeSitemap(smWritable.getWriter()) | ||
return event.respondWith(response) | ||
}) | ||
``` |
@@ -27,2 +27,6 @@ /** | ||
transform(chunk: SitemapItem, controller: TransformStreamDefaultController<string>): void | PromiseLike<void>; | ||
/** | ||
* @returns {string} | ||
*/ | ||
get [Symbol.toStringTag](): string; | ||
#private; | ||
@@ -51,2 +55,6 @@ } | ||
get writable(): WritableStream<SitemapItem>; | ||
/** | ||
* @returns {string} | ||
*/ | ||
get [Symbol.toStringTag](): string; | ||
#private; | ||
@@ -53,0 +61,0 @@ } |
@@ -44,2 +44,9 @@ /** | ||
/** | ||
* @returns {string} | ||
*/ | ||
get [Symbol.toStringTag]() { | ||
return 'SitemapTransformer' | ||
} | ||
/** @type {TransformerFlushCallback<string>} */ | ||
@@ -132,2 +139,9 @@ flush(controller) { | ||
/** | ||
* @returns {string} | ||
*/ | ||
get [Symbol.toStringTag]() { | ||
return 'SitemapStream' | ||
} | ||
/** | ||
* @returns {ReadableStream<string>} | ||
@@ -134,0 +148,0 @@ */ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12596
344
40