Socket
Socket
Sign inDemoInstall

sitemap

Package Overview
Dependencies
Maintainers
2
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sitemap - npm Package Compare versions

Comparing version 7.1.1 to 7.1.2

6

CHANGELOG.md
# Changelog
## 7.1.2
- fix #425 via #426 thanks to @huntharo update streamToPromise to bubble up errors + jsDoc
- fix #415 thanks to @mohd-akram Fix circular dependency breaking Node.js 20.6
- non-breaking updates of dependent packages
## 7.1.1

@@ -4,0 +10,0 @@

2

dist/lib/sitemap-index-stream.d.ts

@@ -39,3 +39,3 @@ /// <reference types="node" />

constructor(opts: SitemapAndIndexStreamOptions);
_writeSMI(item: SitemapItemLoose): void;
_writeSMI(item: SitemapItemLoose, callback: () => void): void;
_transform(item: SitemapItemLoose, encoding: string, callback: TransformCallback): void;

@@ -42,0 +42,0 @@ _flush(cb: TransformCallback): void;

@@ -69,5 +69,10 @@ "use strict";

}
_writeSMI(item) {
this.currentSitemap.write(item);
_writeSMI(item, callback) {
this.i++;
if (!this.currentSitemap.write(item)) {
this.currentSitemap.once('drain', callback);
}
else {
process.nextTick(callback);
}
}

@@ -77,4 +82,3 @@ _transform(item, encoding, callback) {

if (this.i === 0) {
this._writeSMI(item);
super._transform(this.idxItem, encoding, callback);
this._writeSMI(item, () => super._transform(this.idxItem, encoding, callback));
}

@@ -86,5 +90,6 @@ else if (this.i % this.limit === 0) {

this.currentSitemapPipeline = currentSitemapPipeline;
this._writeSMI(item);
// push to index stream
super._transform(idxItem, encoding, callback);
this._writeSMI(item, () =>
// push to index stream
super._transform(idxItem, encoding, callback));
};

@@ -95,4 +100,3 @@ (_a = this.currentSitemapPipeline) === null || _a === void 0 ? void 0 : _a.on('finish', onFinish);

else {
this._writeSMI(item);
callback();
this._writeSMI(item, callback);
}

@@ -99,0 +103,0 @@ }

@@ -427,2 +427,3 @@ "use strict";

try {
const cb = () => callback(this.level === types_1.ErrorLevel.THROW ? this.error : null);
// correcting the type here can be done without making it a breaking change

@@ -432,4 +433,8 @@ // TODO fix this

// @ts-ignore
this.saxStream.write(data, encoding);
callback(this.level === types_1.ErrorLevel.THROW ? this.error : null);
if (!this.saxStream.write(data, encoding)) {
this.saxStream.once('drain', cb);
}
else {
process.nextTick(cb);
}
}

@@ -436,0 +441,0 @@ catch (error) {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.simpleSitemapAndIndex = void 0;
const index_1 = require("../index");
const sitemap_index_stream_1 = require("./sitemap-index-stream");
const sitemap_stream_1 = require("./sitemap-stream");
const utils_1 = require("./utils");
const zlib_1 = require("zlib");

@@ -30,6 +32,6 @@ const fs_1 = require("fs");

await fs_1.promises.mkdir(destinationDir, { recursive: true });
const sitemapAndIndexStream = new index_1.SitemapAndIndexStream({
const sitemapAndIndexStream = new sitemap_index_stream_1.SitemapAndIndexStream({
limit,
getSitemapStream: (i) => {
const sitemapStream = new index_1.SitemapStream({
const sitemapStream = new sitemap_stream_1.SitemapStream({
hostname,

@@ -61,3 +63,3 @@ });

if (typeof sourceData === 'string') {
src = (0, index_1.lineSeparatedURLsToSitemapOptions)((0, fs_1.createReadStream)(sourceData));
src = (0, utils_1.lineSeparatedURLsToSitemapOptions)((0, fs_1.createReadStream)(sourceData));
}

@@ -64,0 +66,0 @@ else if (sourceData instanceof stream_1.Readable) {

@@ -42,5 +42,12 @@ /// <reference types="node" />

/**
* Takes a stream returns a promise that resolves when stream emits finish
* @param stream what you want wrapped in a promise
* Converts a readable stream into a promise that resolves with the concatenated data from the stream.
*
* The function listens for 'data' events from the stream, and when the stream ends, it resolves the promise with the concatenated data. If an error occurs while reading from the stream, the promise is rejected with the error.
*
* ⚠️ CAUTION: This function should not generally be used in production / when writing to files as it holds a copy of the entire file contents in memory until finished.
*
* @param {Readable} stream - The readable stream to convert to a promise.
* @returns {Promise<Buffer>} A promise that resolves with the concatenated data from the stream as a Buffer, or rejects with an error if one occurred while reading from the stream. If the stream is empty, the promise is rejected with an EmptyStream error.
* @throws {EmptyStream} If the stream is empty.
*/
export declare function streamToPromise(stream: Readable): Promise<Buffer>;

@@ -74,4 +74,8 @@ "use strict";

}
this.smiStream.write((0, utils_1.validateSMIOptions)((0, utils_1.normalizeURL)(item, this.hostname, this.lastmodDateOnly), this.level, this.errorHandler));
callback();
if (!this.smiStream.write((0, utils_1.validateSMIOptions)((0, utils_1.normalizeURL)(item, this.hostname, this.lastmodDateOnly), this.level, this.errorHandler))) {
this.smiStream.once('drain', callback);
}
else {
process.nextTick(callback);
}
}

@@ -90,4 +94,11 @@ _flush(cb) {

/**
* Takes a stream returns a promise that resolves when stream emits finish
* @param stream what you want wrapped in a promise
* Converts a readable stream into a promise that resolves with the concatenated data from the stream.
*
* The function listens for 'data' events from the stream, and when the stream ends, it resolves the promise with the concatenated data. If an error occurs while reading from the stream, the promise is rejected with the error.
*
* ⚠️ CAUTION: This function should not generally be used in production / when writing to files as it holds a copy of the entire file contents in memory until finished.
*
* @param {Readable} stream - The readable stream to convert to a promise.
* @returns {Promise<Buffer>} A promise that resolves with the concatenated data from the stream as a Buffer, or rejects with an error if one occurred while reading from the stream. If the stream is empty, the promise is rejected with an EmptyStream error.
* @throws {EmptyStream} If the stream is empty.
*/

@@ -98,2 +109,5 @@ function streamToPromise(stream) {

stream
// Error propagation is not automatic
// Bubble up errors on the read stream
.on('error', reject)
.pipe(new stream_1.Writable({

@@ -105,2 +119,4 @@ write(chunk, enc, next) {

}))
// This bubbles up errors when writing to the internal buffer
// This is unlikely to happen, but we have this for completeness
.on('error', reject)

@@ -107,0 +123,0 @@ .on('finish', () => {

{
"name": "sitemap",
"version": "7.1.1",
"version": "7.1.2",
"description": "Sitemap-generating lib/cli",

@@ -189,4 +189,3 @@ "keywords": [

"npm": ">=5.6.0"
},
"License": "MIT"
}
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc