
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
tar-iterator
Advanced tools
Extract contents from tar archive type using an iterator API using streams or paths. Use stream interface and pipe transforms to add decompression algorithms
Extract contents from tar archive type using an iterator API using streams or paths. Use stream interface and pipe transforms to add decompression algorithms.
// asyncIterator
var assert = require('assert');
var fs = require('fs');
var TarIterator = require('tar-iterator');
(async function() {
let iterator = new TarIterator('/path/to/archive');
try {
const links = [];
for await (const entry of iterator) {
if (entry.type === 'link') links.unshift(entry);
else if (entry.type === 'symlink') links.push(entry);
else await entry.create(dest, options);
}
// create links after directories and files
for (const entry of links) await entry.create(dest, options);
} catch (err) {
}
iterator.destroy();
iterator = null;
})();
(async function() {
let iterator = new TarIterator(fs.createReadStream('/path/to/archive'));
try {
const links = [];
for await (const entry of iterator) {
if (entry.type === 'link') links.unshift(entry);
else if (entry.type === 'symlink') links.push(entry);
else await entry.create(dest, options);
}
// create links after directories and files
for (const entry of links) await entry.create(dest, options);
} catch (err) {
}
iterator.destroy();
iterator = null;
})();
// Async / Await
var assert = require('assert');
var TarIterator = require('tar-iterator');
// one by one
(async function() {
let iterator = new TarIterator('/path/to/archive');
try {
const links = [];
for await (const entry of iterator) {
if (entry.type === 'link') links.unshift(entry);
else if (entry.type === 'symlink') links.push(entry);
else await entry.create(dest, options);
}
// create links after directories and files
for (const entry of links) await entry.create(dest, options);
} catch (err) {
}
iterator.destroy();
iterator = null;
})();
// infinite concurrency
(async function() {
let iterator = new TarIterator('/path/to/archive');
try {
const links = [];
await iterator.forEach(
async function (entry) {
if (entry.type === 'link') links.unshift(entry);
else if (entry.type === 'symlink') links.push(entry);
else await entry.create(dest, options);
},
{ concurrency: Infinity }
);
// create links after directories and files
for (const entry of links) await entry.create(dest, options);
} catch (err) {
aseert.ok(!err);
}
iterator.destroy();
iterator = null;
})();
// Callbacks
var assert = require('assert');
var Queue = require('queue-cb');
var TarIterator = require('tar-iterator');
var iterator = new TarIterator('/path/to/archive');
// one by one
var links = [];
iterator.forEach(
function (entry, callback) {
if (entry.type === 'link') {
links.unshift(entry);
callback();
} else if (entry.type === 'symlink') {
links.push(entry);
callback();
} else entry.create(dest, options, callback);
},
{ callbacks: true, concurrency: 1 },
function (err) {
// create links after directories and files
var queue = new Queue();
for (var index = 0; index < links.length; index++) {
var entry = links[index];
queue.defer(entry.create.bind(entry, dest, options));
}
queue.await(callback);
iterator.destroy();
iterator = null;
}
);
FAQs
Extract contents from tar archive type using an iterator API using streams or paths. Use stream interface and pipe transforms to add decompression algorithms
The npm package tar-iterator receives a total of 1,179 weekly downloads. As such, tar-iterator popularity was classified as popular.
We found that tar-iterator demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.