Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

defiler

Package Overview
Dependencies
Maintainers
1
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

defiler - npm Package Compare versions

Comparing version 0.17.5 to 0.18.0

4

CHANGELOG.md

@@ -0,1 +1,5 @@

# v0.18.0
- `defiler.get(filter)` now also returns virtual files in addition to physical ones
# v0.17.5

@@ -2,0 +6,0 @@

102

dist/index.cjs.js

@@ -226,8 +226,7 @@ 'use strict';

this.files = new Map();
this._status = Status.Before;
this._status = 0;
this._active = new Set();
this._waitingFor = new Map();
this._whenFound = new Map();
this._deps = new Array();
this._queue = new Array();
this._deps = [];
this._queue = [];
this._isProcessing = false;

@@ -275,3 +274,3 @@ this._endWave = null;

this._transform = transform;
this._generators = new Map(generators.map(generator => [Symbol(), generator]));
this._generators = generators;
this._resolver = resolver;

@@ -281,9 +280,9 @@ this._onerror = onerror;

async exec() {
if (this._status !== Status.Before) {
if (this._status !== 0) {
throw new Error('defiler.exec: cannot call more than once');
}
this._status = Status.During;
this._status = 1;
this._isProcessing = true;
const done = this._startWave();
const files = new Array();
const files = [];
await Promise.all(this._watchers.map(async (watcher) => {

@@ -301,4 +300,4 @@ watcher.on('', event => this._enqueue(watcher, event));

}));
for (const symbol of this._generators.keys()) {
this._active.add(symbol);
for (const generator of this._generators) {
this._active.add(generator);
}

@@ -308,7 +307,7 @@ for (const [watcher, path$$1, file] of files) {

}
for (const symbol of this._generators.keys()) {
this._processGenerator(symbol);
for (const generator of this._generators) {
this._processGenerator(generator);
}
await done;
this._status = Status.After;
this._status = 2;
this._isProcessing = false;

@@ -318,8 +317,8 @@ this._enqueue();

async get(_) {
if (typeof _ === 'string') {
_ = this.resolve(_);
}
if (Array.isArray(_)) {
return Promise.all(_.map(path$$1 => this.get(path$$1)));
}
if (typeof _ !== 'function') {
_ = this.resolve(_);
}
if (typeof _ !== 'string' && typeof _ !== 'function') {

@@ -332,7 +331,5 @@ throw new TypeError('defiler.get: argument must be a string, an array, or a function');

}
if (typeof _ === 'function') {
return this.get([...this.paths].filter(_).sort());
}
if (this._status === Status.During && !this.files.has(_) && current$$1) {
this._waitingFor.set(current$$1, (this._waitingFor.get(current$$1) || 0) + 1);
if (this._status === 1 &&
current$$1 &&
(typeof _ === 'function' || !this.files.has(_))) {
if (this._whenFound.has(_)) {

@@ -350,6 +347,8 @@ const { promise, paths } = this._whenFound.get(_);

}
return this.files.get(_);
return typeof _ === 'function'
? this.get([...this.files.keys()].filter(_).sort())
: this.files.get(_);
}
add(file) {
if (this._status === Status.Before) {
if (this._status === 0) {
throw new Error('defiler.add: cannot call before calling exec');

@@ -424,3 +423,3 @@ }

this.files.set(path$$1, file);
if (this._status === Status.During) {
if (this._status === 1) {
this._markFound(path$$1);

@@ -446,7 +445,6 @@ }

}
async _processGenerator(symbol) {
this._active.add(symbol);
const generator = this._generators.get(symbol);
async _processGenerator(generator) {
this._active.add(generator);
await null;
create(symbol);
create(generator);
try {

@@ -460,3 +458,3 @@ await generator();

}
this._active.delete(symbol);
this._active.delete(generator);
this._checkWave();

@@ -473,8 +471,8 @@ }

for (const dependent of dependents) {
if (this._origData.has(dependent)) {
if (typeof dependent === 'function') {
this._processGenerator(dependent);
}
else if (this._origData.has(dependent)) {
this._processFile(this._origData.get(dependent), 'retransform');
}
else if (this._generators.has(dependent)) {
this._processGenerator(dependent);
}
}

@@ -487,9 +485,25 @@ this._checkWave();

}
else if (this._status === Status.During &&
[...this._active].every(path$$1 => !!this._waitingFor.get(path$$1))) {
for (const path$$1 of this._whenFound.keys()) {
if (!this._active.has(path$$1)) {
this._markFound(path$$1);
else if (this._status === 1) {
const filterWaiting = new Set();
const allWaiting = new Set();
for (const [path$$1, { paths }] of this._whenFound) {
if (typeof path$$1 === 'function' || this._active.has(path$$1)) {
paths.forEach(path$$1 => filterWaiting.add(path$$1));
}
paths.forEach(path$$1 => allWaiting.add(path$$1));
}
if ([...this._active].every(path$$1 => filterWaiting.has(path$$1))) {
for (const path$$1 of this._whenFound.keys()) {
if (typeof path$$1 === 'function') {
this._markFound(path$$1);
}
}
}
else if ([...this._active].every(path$$1 => allWaiting.has(path$$1))) {
for (const path$$1 of this._whenFound.keys()) {
if (typeof path$$1 === 'string' && !this._active.has(path$$1)) {
this._markFound(path$$1);
}
}
}
}

@@ -499,7 +513,3 @@ }

if (this._whenFound.has(path$$1)) {
const { resolve, paths } = this._whenFound.get(path$$1);
for (const path$$1 of paths) {
this._waitingFor.set(path$$1, this._waitingFor.get(path$$1) - 1);
}
resolve();
this._whenFound.get(path$$1).resolve();
this._whenFound.delete(path$$1);

@@ -509,8 +519,2 @@ }

}
var Status;
(function (Status) {
Status[Status["Before"] = 0] = "Before";
Status[Status["During"] = 1] = "During";
Status[Status["After"] = 2] = "After";
})(Status || (Status = {}));

@@ -517,0 +521,0 @@ exports.File = File;

@@ -222,8 +222,7 @@ import { readdir, readFile, stat, watch } from 'fs';

this.files = new Map();
this._status = Status.Before;
this._status = 0;
this._active = new Set();
this._waitingFor = new Map();
this._whenFound = new Map();
this._deps = new Array();
this._queue = new Array();
this._deps = [];
this._queue = [];
this._isProcessing = false;

@@ -271,3 +270,3 @@ this._endWave = null;

this._transform = transform;
this._generators = new Map(generators.map(generator => [Symbol(), generator]));
this._generators = generators;
this._resolver = resolver;

@@ -277,9 +276,9 @@ this._onerror = onerror;

async exec() {
if (this._status !== Status.Before) {
if (this._status !== 0) {
throw new Error('defiler.exec: cannot call more than once');
}
this._status = Status.During;
this._status = 1;
this._isProcessing = true;
const done = this._startWave();
const files = new Array();
const files = [];
await Promise.all(this._watchers.map(async (watcher) => {

@@ -297,4 +296,4 @@ watcher.on('', event => this._enqueue(watcher, event));

}));
for (const symbol of this._generators.keys()) {
this._active.add(symbol);
for (const generator of this._generators) {
this._active.add(generator);
}

@@ -304,7 +303,7 @@ for (const [watcher, path, file] of files) {

}
for (const symbol of this._generators.keys()) {
this._processGenerator(symbol);
for (const generator of this._generators) {
this._processGenerator(generator);
}
await done;
this._status = Status.After;
this._status = 2;
this._isProcessing = false;

@@ -314,8 +313,8 @@ this._enqueue();

async get(_) {
if (typeof _ === 'string') {
_ = this.resolve(_);
}
if (Array.isArray(_)) {
return Promise.all(_.map(path => this.get(path)));
}
if (typeof _ !== 'function') {
_ = this.resolve(_);
}
if (typeof _ !== 'string' && typeof _ !== 'function') {

@@ -328,7 +327,5 @@ throw new TypeError('defiler.get: argument must be a string, an array, or a function');

}
if (typeof _ === 'function') {
return this.get([...this.paths].filter(_).sort());
}
if (this._status === Status.During && !this.files.has(_) && current$$1) {
this._waitingFor.set(current$$1, (this._waitingFor.get(current$$1) || 0) + 1);
if (this._status === 1 &&
current$$1 &&
(typeof _ === 'function' || !this.files.has(_))) {
if (this._whenFound.has(_)) {

@@ -346,6 +343,8 @@ const { promise, paths } = this._whenFound.get(_);

}
return this.files.get(_);
return typeof _ === 'function'
? this.get([...this.files.keys()].filter(_).sort())
: this.files.get(_);
}
add(file) {
if (this._status === Status.Before) {
if (this._status === 0) {
throw new Error('defiler.add: cannot call before calling exec');

@@ -420,3 +419,3 @@ }

this.files.set(path, file);
if (this._status === Status.During) {
if (this._status === 1) {
this._markFound(path);

@@ -442,7 +441,6 @@ }

}
async _processGenerator(symbol) {
this._active.add(symbol);
const generator = this._generators.get(symbol);
async _processGenerator(generator) {
this._active.add(generator);
await null;
create(symbol);
create(generator);
try {

@@ -456,3 +454,3 @@ await generator();

}
this._active.delete(symbol);
this._active.delete(generator);
this._checkWave();

@@ -469,8 +467,8 @@ }

for (const dependent of dependents) {
if (this._origData.has(dependent)) {
if (typeof dependent === 'function') {
this._processGenerator(dependent);
}
else if (this._origData.has(dependent)) {
this._processFile(this._origData.get(dependent), 'retransform');
}
else if (this._generators.has(dependent)) {
this._processGenerator(dependent);
}
}

@@ -483,9 +481,25 @@ this._checkWave();

}
else if (this._status === Status.During &&
[...this._active].every(path => !!this._waitingFor.get(path))) {
for (const path of this._whenFound.keys()) {
if (!this._active.has(path)) {
this._markFound(path);
else if (this._status === 1) {
const filterWaiting = new Set();
const allWaiting = new Set();
for (const [path, { paths }] of this._whenFound) {
if (typeof path === 'function' || this._active.has(path)) {
paths.forEach(path => filterWaiting.add(path));
}
paths.forEach(path => allWaiting.add(path));
}
if ([...this._active].every(path => filterWaiting.has(path))) {
for (const path of this._whenFound.keys()) {
if (typeof path === 'function') {
this._markFound(path);
}
}
}
else if ([...this._active].every(path => allWaiting.has(path))) {
for (const path of this._whenFound.keys()) {
if (typeof path === 'string' && !this._active.has(path)) {
this._markFound(path);
}
}
}
}

@@ -495,7 +509,3 @@ }

if (this._whenFound.has(path)) {
const { resolve: resolve$$1, paths } = this._whenFound.get(path);
for (const path of paths) {
this._waitingFor.set(path, this._waitingFor.get(path) - 1);
}
resolve$$1();
this._whenFound.get(path).resolve();
this._whenFound.delete(path);

@@ -505,10 +515,4 @@ }

}
var Status;
(function (Status) {
Status[Status["Before"] = 0] = "Before";
Status[Status["During"] = 1] = "During";
Status[Status["After"] = 2] = "After";
})(Status || (Status = {}));
export { File, Defiler };
//# sourceMappingURL=index.es.js.map
{
"name": "defiler",
"version": "0.17.5",
"version": "0.18.0",
"description": "A small, strange building block",

@@ -35,5 +35,5 @@ "keywords": [

"scripts": {
"dev": "rollup -c -w",
"build": "rollup -c"
"dev": "rollup -c rollup/dev.js -w",
"build": "tsc && rollup -c rollup/prod.js"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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