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

converter-toless-plugin

Package Overview
Dependencies
Maintainers
1
Versions
96
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

converter-toless-plugin - npm Package Compare versions

Comparing version 0.1.254 to 0.1.255

52

lib/components/filter.js

@@ -19,9 +19,9 @@ "use strict";

words: [
"fuck", "shit", "Swear", "www", "https", "http"
"fuck", "shit", "Swear", "www", "https", "http", "*", ">", '"'
],
replaceBy: "u",
filterWords: true,
filterComas: true,
filterSlashes: true,
filterUsingDecoder: true
filterUsingDecoder: true,
replaceBy: "u",
};

@@ -31,41 +31,41 @@ exports.default = (string, filter) => __awaiter(void 0, void 0, void 0, function* () {

let _string = string;
_string = (_filter.filterWords) ? yield step1(_string, _filter) : _string;
_string = (_filter.filterWords) ? yield step2(_string, _filter) : _string;
_string = (_filter.filterWords) ? yield step3(_string) : _string;
_string = (_filter.filterWords) ? yield step4(_string, _filter) : _string;
_string = (_filter.filterWords) ? yield layer1(_string, _filter) : _string;
_string = (_filter.filterWords) ? yield layer2(_string, _filter) : _string;
_string = (_filter.filterWords) ? yield layer3(_string) : _string;
_string = (_filter.filterWords) ? yield layer4(_string, _filter) : _string;
return _string;
});
function step1(string, filter) {
function layer1(str, filter) {
return new Promise((solve) => {
let _string = string;
let _str = str;
filter.words.forEach((word) => {
_string = replaceAll(_string, word, filter.replaceBy);
_str = replaceAll(_str, word, filter.replaceBy);
});
solve(_string);
return _string;
solve(_str);
return _str;
});
}
function step2(string, filter) {
function layer2(str, filter) {
return new Promise((solve) => {
let _string = string.replace(/"/gi, filter.replaceBy);
_string = _string.replace(/'/gi, filter.replaceBy);
solve(_string);
return _string;
let _str = str.replace(/"/gi, filter.replaceBy);
_str = _str.replace(/'/gi, filter.replaceBy);
solve(_str);
return _str;
});
}
function step3(string, filter) {
function layer3(str) {
return new Promise((solve) => {
let _string = encodeURI(string);
solve(_string);
return _string;
let _str = encodeURI(str);
solve(_str);
return _str;
});
}
function step4(string, filter) {
function layer4(str, filter) {
return new Promise((solve) => {
let _string = string.replace(/\\/gi, filter.replaceBy);
_string = _string.replace(/\//gi, filter.replaceBy);
solve(_string);
return _string;
let _str = str.replace(/\\/gi, filter.replaceBy);
_str = _str.replace(/\//gi, filter.replaceBy);
solve(_str);
return _str;
});
}
//# sourceMappingURL=filter.js.map
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getNameOf = exports.deleteAllFilesInDirectory = exports.deleteDirectory = exports.deleteFile = exports.getProps = void 0;
exports.deleteAllFilesInDirectory = exports.deleteDirectory = exports.deleteFile = exports.deleteFileOrDirectory = exports.getProps = exports.getNameOf = void 0;
const path_1 = require("path");
const fs = require("fs");
const del = require("del");
function getNameOf(arry, name) {
let indexofar = -1;
arry.forEach((ar, i) => {
if (ar.name === name) {
indexofar = i;
}
});
return indexofar;
}
exports.getNameOf = getNameOf;
function getProps(name) {

@@ -14,15 +34,11 @@ const n = name.split(".");

exports.getProps = getProps;
function deleteFileOrDirectory(filePath) {
return __awaiter(this, void 0, void 0, function* () {
yield del(filePath, { force: true });
});
}
exports.deleteFileOrDirectory = deleteFileOrDirectory;
function deleteFile(filePath) {
return new Promise((s, r) => {
try {
fs.unlink(filePath, (err) => {
if (err) {
r(err);
}
s();
});
}
catch (err) {
r(err);
}
return __awaiter(this, void 0, void 0, function* () {
yield del(filePath, { force: true });
});

@@ -32,9 +48,4 @@ }

function deleteDirectory(dirPath) {
return new Promise((s, r) => {
try {
fs.rmdir(dirPath, s);
}
catch (err) {
r(err);
}
return __awaiter(this, void 0, void 0, function* () {
yield del(dirPath, { force: true });
});

@@ -45,3 +56,3 @@ }

return new Promise((s, r) => {
fs.readdir(dir, (err, files) => {
fs.readdir(dir, (err, files) => __awaiter(this, void 0, void 0, function* () {
if (err)

@@ -51,24 +62,9 @@ r(err);

const pathi = path_1.join(dir, file);
if (!fs.statSync(pathi).isDirectory()) {
fs.unlink(pathi, err => {
if (err)
r(err);
});
}
deleteFileOrDirectory(pathi);
}
s();
});
}));
});
}
exports.deleteAllFilesInDirectory = deleteAllFilesInDirectory;
function getNameOf(arry, name) {
let indexofar = -1;
arry.forEach((ar, i) => {
if (ar.name === name) {
indexofar = i;
}
});
return indexofar;
}
exports.getNameOf = getNameOf;
//# sourceMappingURL=utils.js.map

@@ -48,8 +48,10 @@ "use strict";

start() {
this.setInputOutputDir();
if (this.deleteallTempFilesOnStart) {
this.deleteGarbage();
}
this.GarbageCleaner();
this.setup();
return __awaiter(this, void 0, void 0, function* () {
this.setInputOutputDir();
if (this.deleteallTempFilesOnStart) {
yield this.deleteGarbage();
}
this.GarbageCleaner();
this.setup();
});
}

@@ -257,12 +259,18 @@ setup() {

deleteGarbage() {
const dirin = this.inputdir;
const dirout = this.outputdir;
utils_1.deleteAllFilesInDirectory(dirin);
utils_1.deleteAllFilesInDirectory(dirout);
if (!fs.existsSync(dirin)) {
fs.mkdirSync(dirin);
}
if (!fs.existsSync(dirout)) {
fs.mkdirSync(dirout);
}
return __awaiter(this, void 0, void 0, function* () {
const dirin = this.inputdir;
if (!fs.existsSync(dirin)) {
fs.mkdirSync(dirin);
}
else {
yield utils_1.deleteAllFilesInDirectory(dirin);
}
const dirout = this.outputdir;
if (!fs.existsSync(dirout)) {
fs.mkdirSync(dirout);
}
else {
yield utils_1.deleteAllFilesInDirectory(dirout);
}
});
}

@@ -280,11 +288,14 @@ getIndexByName(name) {

const _path = path_1.join(_dir, file);
const stats = fs.statSync(_path);
const mtime = stats.mtime;
if (Number(new Date()) - Number(new Date(mtime)) >= this.timetoGarbageCleaner * Minute) {
if (!stats.isDirectory())
fs.unlink(_path, (err) => {
if (err)
console.error(err);
});
let stats = fs.statSync(_path);
if (stats.isDirectory()) {
stats = null;
}
else {
const mtime = stats.mtime;
if (Number(new Date()) - Number(new Date(mtime)) >= this.timetoGarbageCleaner * Minute) {
(() => __awaiter(this, void 0, void 0, function* () {
yield utils_1.deleteFile(_path);
}))();
}
}
}

@@ -291,0 +302,0 @@ });

{
"name": "converter-toless-plugin",
"version": "0.1.254",
"version": "0.1.255",
"description": "this is a plugin",

@@ -31,2 +31,3 @@ "main": "./lib/index.js",

"child_process": "^1.0.2",
"del": "^6.0.0",
"express": "^4.17.1",

@@ -33,0 +34,0 @@ "mime-types": "^2.1.28",

@@ -19,6 +19,4 @@ // String.prototype.replaceAll = function ra(string, string2) {

words: [
"fuck", "shit", "Swear", "www", "https", "http"
"fuck", "shit", "Swear", "www", "https", "http", "*", ">", '"'
],
replaceBy: "u",
filterWords: true,

@@ -30,3 +28,5 @@

filterUsingDecoder: true
filterUsingDecoder: true,
replaceBy: "u",
}

@@ -38,6 +38,6 @@

_string = (_filter.filterWords) ? await step1(_string, _filter) : _string;
_string = (_filter.filterWords) ? await step2(_string, _filter) : _string;
_string = (_filter.filterWords) ? await step3(_string) : _string;
_string = (_filter.filterWords) ? await step4(_string, _filter) : _string;
_string = (_filter.filterWords) ? await layer1(_string, _filter) : _string;
_string = (_filter.filterWords) ? await layer2(_string, _filter) : _string;
_string = (_filter.filterWords) ? await layer3(_string) : _string;
_string = (_filter.filterWords) ? await layer4(_string, _filter) : _string;

@@ -47,41 +47,41 @@ return _string

// filter words
function step1(string: string, filter: FilterOps): Promise<string> {
/** Filtering words out */
function layer1(str: string, filter: FilterOps): Promise<string> {
return new Promise((solve) => {
let _string = string
let _str = str
filter.words.forEach((word: string) => {
_string = replaceAll(_string, word, filter.replaceBy)
_str = replaceAll(_str, word, filter.replaceBy)
})
solve(_string)
return _string;
solve(_str)
return _str;
})
}
// filter commas
function step2(string: string, filter: FilterOps): Promise<string> {
/** Filtering commas out */
function layer2(str: string, filter: FilterOps): Promise<string> {
return new Promise((solve) => {
let _string = string.replace(/"/gi, filter.replaceBy)
_string = _string.replace(/'/gi, filter.replaceBy)
solve(_string);
return _string
let _str = str.replace(/"/gi, filter.replaceBy)
_str = _str.replace(/'/gi, filter.replaceBy)
solve(_str);
return _str
})
}
// filter with decoding
function step3(string: string, filter?: FilterOps): Promise<string> {
/** Filtering with encoding */
function layer3(str: string): Promise<string> {
return new Promise((solve) => {
let _string = encodeURI(string)
solve(_string);
return _string
let _str = encodeURI(str)
solve(_str);
return _str
})
}
// filter slashes
function step4(string: string, filter: FilterOps): Promise<string> {
/** Filtering slashes out */
function layer4(str: string, filter: FilterOps): Promise<string> {
return new Promise((solve) => {
let _string = string.replace(/\\/gi, filter.replaceBy)
_string = _string.replace(/\//gi, filter.replaceBy)
solve(_string);
return _string
let _str = str.replace(/\\/gi, filter.replaceBy)
_str = _str.replace(/\//gi, filter.replaceBy)
solve(_str);
return _str
})
}

@@ -6,7 +6,16 @@ import { join } from "path"

import del = require('del');
export function getNameOf(arry: Compiler[], name: string) {
let indexofar = -1;
arry.forEach((ar, i) => {
if (ar.name === name) {
indexofar = i;
}
});
return indexofar;
}
export function getProps(name: string) {

@@ -20,44 +29,28 @@ const n = name.split(".");

// delete functions
export function deleteFile(filePath: string): Promise<void> {
return new Promise((s, r) => {
try {
fs.unlink(filePath, (err) => {
if (err) {
r(err)
}
s()
})
} catch (err) {
r(err)
}
})
export async function deleteFileOrDirectory(filePath: string): Promise<void> {
await del(filePath, { force: true })
}
export async function deleteFile(filePath: string): Promise<void> {
await del(filePath, { force: true })
}
export function deleteDirectory(dirPath: string) {
return new Promise((s, r) => {
try {
fs.rmdir(dirPath, s)
} catch (err) {
r(err)
}
})
export async function deleteDirectory(dirPath: string): Promise<any> {
await del(dirPath, { force: true })
}
export function deleteAllFilesInDirectory(dir: string): Promise<void> {
return new Promise((s, r) => {
fs.readdir(dir, (err, files) => {
fs.readdir(dir, async (err, files) => {
if (err) r(err);
for (const file of files) {
const pathi = join(dir, file);
if (!fs.statSync(pathi).isDirectory()) {
fs.unlink(pathi, err => {
if (err) r(err)
});
}
deleteFileOrDirectory(pathi);
}
s()

@@ -69,11 +62,2 @@ });

export function getNameOf(arry: Compiler[], name: string) {
let indexofar = -1;
arry.forEach((ar, i) => {
if (ar.name === name) {
indexofar = i;
}
});
return indexofar;
}

@@ -80,0 +64,0 @@

@@ -92,3 +92,3 @@ // for running commands

/** this function starts the server */
start() {
async start() {
this.setInputOutputDir()

@@ -98,3 +98,3 @@

if (this.deleteallTempFilesOnStart) {
this.deleteGarbage()
await this.deleteGarbage()
}

@@ -464,13 +464,15 @@

/** function to delete temp files off input and output folders*/
deleteGarbage() {
async deleteGarbage() {
const dirin = this.inputdir
const dirout = this.outputdir
deleteAllFilesInDirectory(dirin);
deleteAllFilesInDirectory(dirout);
if (!fs.existsSync(dirin)) {
fs.mkdirSync(dirin);
} else {
await deleteAllFilesInDirectory(dirin);
}
const dirout = this.outputdir
if (!fs.existsSync(dirout)) {
fs.mkdirSync(dirout);
} else {
await deleteAllFilesInDirectory(dirout);
}

@@ -493,9 +495,12 @@ }

const _path = join(_dir, file)
const stats = fs.statSync(_path);
const mtime = stats.mtime;
if (Number(new Date()) - Number(new Date(mtime)) >= this.timetoGarbageCleaner * Minute) {
if (!stats.isDirectory())
fs.unlink(_path, (err: any) => {
if (err) console.error(err)
});
let stats: any = fs.statSync(_path);
if (stats.isDirectory()) {
stats = null;
} else {
const mtime = stats.mtime;
if (Number(new Date()) - Number(new Date(mtime)) >= this.timetoGarbageCleaner * Minute) {
(async () => {
await deleteFile(_path)
})()
}
}

@@ -502,0 +507,0 @@ }

Sorry, the diff of this file is not supported yet

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