New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

asset-pipe-js-reader

Package Overview
Dependencies
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asset-pipe-js-reader - npm Package Compare versions

Comparing version 1.0.0-beta.5 to 1.0.0-beta.6

89

lib/reader.js

@@ -6,4 +6,53 @@ 'use strict';

const mergeStream = require('merge-stream');
const through = require('through2');
const stream = require('readable-stream');
// Ensure output order is the same as input order. The sorter only sorts the
// modules, not execution order. `order` is consumed by browserify's
// `browser-pack`. The feeds already have an order, but they are always `0` as
// each feed only have a single entrypoint.
class OrderDecorator extends stream.Transform {
constructor (order) {
super({
objectMode: true,
});
this.order = order;
}
_transform (row, encoding, next) {
if (row.entry === true) {
row.order = this.order;
}
next(null, row);
}
}
class SortAndDedupe extends stream.Transform {
constructor () {
super({
objectMode: true,
});
this.rows = new Map();
}
_transform (row, encoding, next) {
// FIXME: This is too simplistic. We have to handle the case of rows
// having keys like `expose` set, and ensure the correct configuration
// bubbles up
if (!this.rows.has(row.id)) {
this.rows.set(row.id, row);
}
next();
}
end () {
Array
.from(this.rows.values())
.sort(compareId)
.forEach(row => this.push(row));
this.push(null);
}
}
module.exports = class Reader extends pack {

@@ -17,3 +66,3 @@ constructor (streams = []) {

streams.forEach((strm, index) => {
const orderDecorator = createOrderDecorator(index);
const orderDecorator = new OrderDecorator(index);

@@ -46,2 +95,3 @@ strm.on('file found', (file) => {

// Set up the pipeline
const sortAndDedupe = new SortAndDedupe();
merged

@@ -51,3 +101,3 @@ .on('error', (error) => {

})
.pipe(sortAndDedupe())
.pipe(sortAndDedupe)
.on('error', (error) => {

@@ -60,37 +110,4 @@ this.emit('error', error);

// Ensure output order is the same as input order
// The sorter only sorts the modules, not execution order
// `order` is consumed by browserify's `browser-pack`
function createOrderDecorator (order) {
return through.obj((row, enc, next) => {
if (row.entry === true) {
row.order = order;
}
next(null, row);
});
}
function sortAndDedupe () {
const rows = new Map();
return through.obj(write, end);
function write (row, enc, next) {
if (!rows.has(row.id)) {
rows.set(row.id, row);
}
next();
}
function end (next) {
Array
.from(rows.values())
.sort(compareId)
.forEach(row => this.push(row));
this.push(null);
next();
}
}
function compareId (a, b) {
return a.id.localeCompare(b.id);
}
{
"name": "asset-pipe-js-reader",
"version": "1.0.0-beta.5",
"version": "1.0.0-beta.6",
"author": {

@@ -32,3 +32,3 @@ "name": "Trygve Lie",

"merge-stream": "1.0.1",
"through2": "2.0.3"
"readable-stream": "2.2.9"
},

@@ -35,0 +35,0 @@ "devDependencies": {

# asset-pipe-js-reader
[![Greenkeeper badge](https://badges.greenkeeper.io/asset-pipe/asset-pipe-js-reader.svg)](https://greenkeeper.io/)
This is an internal module intended for use by other modules in the [asset-pipe project][asset-pipe].

@@ -4,0 +6,0 @@

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