New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

colleqtor

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

colleqtor - npm Package Compare versions

Comparing version 2.0.2 to 2.1.0

45

colleqtor.js

@@ -7,4 +7,9 @@ const { version } = require('./package.json');

const isArray = a => Array.isArray(a);
const isObject = o => typeof o === 'object';
const isString = s => typeof s === 'string';
const isFunction = f => typeof f === 'function';
function checkOptions (methodName = '?', options) {
if (typeof options !== 'object') {
if (!isObject(options)) {
throw new TypeError(`

@@ -18,2 +23,28 @@ API changed in V2.0:

const extensionFilter = ext => item => {
if (isString(ext) && ext.length) {
const itemExt = path.extname(item).toLowerCase();
return isString(itemExt)
&& itemExt.length > 1
&& (itemExt === ext.toLowerCase()
|| itemExt.substring(1) === ext.toLowerCase());
} else if (isArray(ext)) {
return ext.some(subExtension => extensionFilter(subExtension)(item));
}
return true;
}
const exclusionFilter = predicate => item => {
if (isFunction(predicate))
return !predicate(item);
if (isString(predicate))
return item.indexOf(predicate) === -1;
if (isArray(predicate))
return predicate.every(subPredicate => excludeFilter(subPredicate)(item));
return true;
};
function listFiles (dir, options = {}) {

@@ -25,3 +56,4 @@ checkOptions('listFiles', options);

stripDirPath = null,
recursive = null
recursive = null,
exclude = null
} = options;

@@ -45,10 +77,9 @@

const resultFilter = item => !extension
|| (jawn.getFileExtension(item) === extension.toLowerCase());
return fileNames.filter(resultFilter);
return fileNames
.filter(extensionFilter(extension))
.filter(exclusionFilter(exclude));
};
function gatherFileNames (dir, options = {}) {
checkOptions(options);
checkOptions('gatherFileNames', options);

@@ -55,0 +86,0 @@ const { extension = null, stripDirPath = false } = options;

2

package.json
{
"name": "colleqtor",
"version": "2.0.2",
"version": "2.1.0",
"description": "Seize the directory.",

@@ -5,0 +5,0 @@ "main": "colleqtor.js",

@@ -10,6 +10,6 @@ const zaq = require('zaq');

zaq.ok('listFiles: Dir and extension (txt) provided:', colleqtor.listFiles(testDir, { extension: 'txt' }));
zaq.ok('listFiles: Dir and extension (xml) provided:', colleqtor.listFiles(testDir, { extension: 'xml' }));
zaq.ok('listFiles: Dir and extensions (log, txt) provided:', colleqtor.listFiles(testDir, { extension: ['log', 'txt'] }));
zaq.ok('listFiles: Dir and extension (txt) provided, stripping directory:', colleqtor.listFiles(testDir, { extension: 'txt', stripDirPath: true }));
zaq.ok('gatherFileNames: Only dir provided:', colleqtor.gatherFileNames(testDir));
zaq.ok('.requireAll(testDir + \'/requireable\')', colleqtor.requireAll(testDir + '/requirable'));
zaq.ok('getFileContent(listFiles(testDir, \'txt\'))', colleqtor.getFileContent(colleqtor.listFiles(testDir, { extension: 'txt' })));
zaq.ok('getFileContent(listFiles(testDir, \'txt\'))', colleqtor.getFileContents(colleqtor.listFiles(testDir, { extension: 'txt' })));
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