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.4.1 to 0.5.0

4

CHANGELOG.md

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

# v0.5.0
- Simplify if/else handling of conditional transforms - see API docs
# v0.4.1

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

58

dist/index.cjs.js

@@ -61,7 +61,2 @@ 'use strict';

let TRANSFORM = Symbol();
let IF = Symbol();
let ELSE = Symbol();
let END = Symbol();
class Defiler extends EventEmitter {

@@ -121,4 +116,4 @@ constructor() {

if (config.transform) {
let { transform } = config;
this._transforms.push({ type: TRANSFORM, transform });
let { transform, if: if_ } = config;
this._transforms.push({ transform, if: if_ });
}

@@ -136,20 +131,2 @@

if(condition) {
this._checkBeforeExec('if');
this._transforms.push({ type: IF, condition });
return this
}
else() {
this._checkBeforeExec('else');
this._transforms.push({ type: ELSE });
return this
}
end() {
this._checkBeforeExec('end');
this._transforms.push({ type: END });
return this
}
// exec

@@ -194,4 +171,5 @@

this.on('file', origPath => this._processDependents(origPath));
this.on('deleted', origPath => this._processDependents(origPath));
let _processDependents = this._processDependents.bind(this);
this.on('file', _processDependents);
this.on('deleted', _processDependents);

@@ -307,27 +285,7 @@ this._filePromises = null;

async _transformFile(file) {
let depth = 0;
let skipDepth = null;
let { path: path$$1 } = file;
try {
for (let { type, transform, condition } of this._transforms) {
if (type === TRANSFORM) {
if (skipDepth === null) {
await transform.call(this, file);
}
} else if (type === IF) {
if (skipDepth === null && !condition.call(this, file)) {
skipDepth = depth;
}
depth++;
} else if (type === ELSE) {
if (skipDepth === null) {
skipDepth = depth - 1;
} else if (skipDepth === depth - 1) {
skipDepth = null;
}
} else if (type === END) {
depth--;
if (skipDepth === depth) {
skipDepth = null;
}
for (let { transform, if: if_ } of this._transforms) {
if (!if_ || (await if_.call(this, file))) {
await transform.call(this, file);
}

@@ -334,0 +292,0 @@ }

@@ -57,7 +57,2 @@ import EventEmitter from 'events';

let TRANSFORM = Symbol();
let IF = Symbol();
let ELSE = Symbol();
let END = Symbol();
class Defiler extends EventEmitter {

@@ -117,4 +112,4 @@ constructor() {

if (config.transform) {
let { transform } = config;
this._transforms.push({ type: TRANSFORM, transform });
let { transform, if: if_ } = config;
this._transforms.push({ transform, if: if_ });
}

@@ -132,20 +127,2 @@

if(condition) {
this._checkBeforeExec('if');
this._transforms.push({ type: IF, condition });
return this
}
else() {
this._checkBeforeExec('else');
this._transforms.push({ type: ELSE });
return this
}
end() {
this._checkBeforeExec('end');
this._transforms.push({ type: END });
return this
}
// exec

@@ -190,4 +167,5 @@

this.on('file', origPath => this._processDependents(origPath));
this.on('deleted', origPath => this._processDependents(origPath));
let _processDependents = this._processDependents.bind(this);
this.on('file', _processDependents);
this.on('deleted', _processDependents);

@@ -303,27 +281,7 @@ this._filePromises = null;

async _transformFile(file) {
let depth = 0;
let skipDepth = null;
let { path: path$$1 } = file;
try {
for (let { type, transform, condition } of this._transforms) {
if (type === TRANSFORM) {
if (skipDepth === null) {
await transform.call(this, file);
}
} else if (type === IF) {
if (skipDepth === null && !condition.call(this, file)) {
skipDepth = depth;
}
depth++;
} else if (type === ELSE) {
if (skipDepth === null) {
skipDepth = depth - 1;
} else if (skipDepth === depth - 1) {
skipDepth = null;
}
} else if (type === END) {
depth--;
if (skipDepth === depth) {
skipDepth = null;
}
for (let { transform, if: if_ } of this._transforms) {
if (!if_ || (await if_.call(this, file))) {
await transform.call(this, file);
}

@@ -330,0 +288,0 @@ }

{
"name": "defiler",
"version": "0.4.1",
"version": "0.5.0",
"description": "A small, strange building block",

@@ -5,0 +5,0 @@ "main": "./dist/index.cjs.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