Skip to content

Commit

Permalink
Use simpler map trim() for values
Browse files Browse the repository at this point in the history
  • Loading branch information
HaveAGitGat committed Jun 3, 2024
1 parent 7767f05 commit 93f258d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,8 @@ var plugin = function (args) {
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
args.inputs = lib.loadDefaultValues(args.inputs, details);
var propertyToCheck = String(args.inputs.propertyToCheck).trim();
var valuesToRemove = String(args.inputs.valuesToRemove).trim().split(',');
var valuesToRemove = String(args.inputs.valuesToRemove).trim().split(',').map(function (item) { return item.trim(); });
var condition = String(args.inputs.condition);
var valuesToRemoveTrimed = [];
valuesToRemove.forEach(function (element) {
var trimedElement = element.trim();
valuesToRemoveTrimed.push(trimedElement);
});
args.variables.ffmpegCommand.streams.forEach(function (stream) {
var _a;
var target = '';
Expand All @@ -83,8 +78,8 @@ var plugin = function (args) {
}
if (target) {
var prop = String(target).toLowerCase();
for (var i = 0; i < valuesToRemoveTrimed.length; i += 1) {
var val = valuesToRemoveTrimed[i].toLowerCase();
for (var i = 0; i < valuesToRemove.length; i += 1) {
var val = valuesToRemove[i].toLowerCase();
var prefix = "Removing stream index ".concat(stream.index, " because ").concat(propertyToCheck, " of ").concat(prop);
if (condition === 'includes' && prop.includes(val)) {
args.jobLog("".concat(prefix, " includes ").concat(val, "\n"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,9 @@ const plugin = (args: IpluginInputArgs): IpluginOutputArgs => {
args.inputs = lib.loadDefaultValues(args.inputs, details);

const propertyToCheck = String(args.inputs.propertyToCheck).trim();
const valuesToRemove = String(args.inputs.valuesToRemove).trim().split(',');
const valuesToRemove = String(args.inputs.valuesToRemove).trim().split(',').map((item) => item.trim());
const condition = String(args.inputs.condition);

const valuesToRemoveTrimed: Array<string> = [];
valuesToRemove.forEach((element) => {
const trimedElement = element.trim();
valuesToRemoveTrimed.push(trimedElement);
});

args.variables.ffmpegCommand.streams.forEach((stream) => {
let target = '';
if (propertyToCheck.includes('.')) {
Expand All @@ -105,8 +99,8 @@ const plugin = (args: IpluginInputArgs): IpluginOutputArgs => {

if (target) {
const prop = String(target).toLowerCase();
for (let i = 0; i < valuesToRemoveTrimed.length; i += 1) {
const val = valuesToRemoveTrimed[i].toLowerCase();
for (let i = 0; i < valuesToRemove.length; i += 1) {
const val = valuesToRemove[i].toLowerCase();
const prefix = `Removing stream index ${stream.index} because ${propertyToCheck} of ${prop}`;
if (condition === 'includes' && prop.includes(val)) {
args.jobLog(`${prefix} includes ${val}\n`);
Expand Down

0 comments on commit 93f258d

Please sign in to comment.