Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
better-concat
Advanced tools
Concatenate multiple files and folders
$ npm install better-concat
import concat from 'better-concat'
await concat({
files: ['file1.js', 'file2.js', ...],
out: 'out.js',
})
You can pass folders in the files array and those folders will be scanned and all the contained files will be merged respecting the order.
await concat({
files: ['file1.js', 'folder1', 'folder2', 'file2.js', ...],
out: 'out.js',
})
If you pass folders in the files list you can use the exclude option to decide wich files are excluded. Exclude can be an array of the files to ignore or a function
// List example
await concat({
files: ['file1.js', 'folder1', 'folder2', 'file2.js', ...],
exclude: ['package.json'],
out: 'out.js',
})
// Function example
await concat({
files: ['file1.js', 'folder1', 'folder2', 'file2.js', ...],
exclude: (file, path) => {
if (file == 'package.json') {
return true; //exclude this file
}
return false;
},
out: 'out.js',
})
You can manipulate individual file strings before the string is merged
await concat({
files: ['file1.js', 'folder1', 'folder2', 'file2.js', ...],
fileStr: (str, path) => {
if (path.endsWith('package.json')) {
return str.replace('word', '');
}
return str;
},
out: 'out.js',
})
You can manipulate the merged string with a function.
await concat({
files: ['file1.js', 'folder1', 'folder2', 'file2.js', ...],
outStr: (str) => {
return str.replace('word', '');
},
out: 'out.js',
})
You can prepend or append anything to the merged string
await concat({
files: ['file1.js', 'folder1', 'folder2', 'file2.js', ...],
prepend: '(function () {\n"use strict";\n\n',
append: '})();',
out: 'out.js',
})
Instead of saving the merged string in a file you can save it in a variable and do whatever you want
const concateStr = await concat({
files: ['file1.js', 'folder1', 'folder2', 'file2.js', ...],
out: false,
})
const concateStr = await concat({
files: ['file1.js', 'folder1', ...],
out: 'path to save the merged file or false',
exclude: 'list of files to exclude or function',
invisibles: 'include invisible files if passed folders in files list (false by default)',
outStr: 'function to manipulate the string before it\'s saved or returned',
fileStr: 'function to manipulate the string of individual files',
prepend: 'prepend string to the merged file',
append: 'append string to the merged file',
delimiter: 'delimiter used to merge the files, default is \n leave empty to remove all line breaks'
})
:star: this repo
Copyright (c) 2019 biati digital
FAQs
concatenate multiple files
We found that better-concat demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.