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

better-scanner

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

better-scanner - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

62

index.js

@@ -0,8 +1,68 @@

var os = require('os');
var cpp = require('child-process-parser');
var clusters = require('clusters');
exports.bin = __dirname + '/bin/scanner';
var homedir = os.homedir();
var getTopRanking = function (suggestions) {
suggestions.sort(function (a, b) {
return (a.score > b.score ? -1 : 1);
})
var data = suggestions.map(function (suggestion) { return [suggestion.score] });
var min = data[data.length-1]
var max = data[0]
clusters.k(2);
clusters.iterations(100);
clusters.data(data);
// console.log(clusters.clusters()[0]);
min = clusters.clusters()[0].points[clusters.clusters()[0].points.length-1];
clusters.data(clusters.clusters()[1].points);
if (clusters.clusters()[0].centroid > clusters.clusters()[1].centroid*50) {
min = clusters.clusters()[0].points[clusters.clusters()[0].points.length-1]
}
// console.log('chose min:', min[0])
return suggestions.filter(function (suggestion) { return suggestion.score >= min });
}
var getSuggestions = function (dir, cb) {
var suggestions = [];
cpp([exports.bin, dir, '--stat'], '\n', function (line) {
// line follows specific format: score ctime mtime atime path
var space = line.indexOf(' ');
var score = parseInt(line.slice(0, space));
var path = line.slice(space+1);
if (dir === homedir && (path === 'Desktop' || path === 'Downloads' || path === 'Diamond')) return;
suggestions.push({
score: score,
path: path,
})
}, function () {
cb(suggestions);
})
}
exports.suggest = function (cb) {
getSuggestions(homedir, function (homeSuggestions) {
homeSuggestions = homeSuggestions.map(function (suggestion) {
suggestion.name = suggestion.path;
suggestion.path = homedir + '/' + suggestion.path;
return suggestion;
});
getSuggestions(homedir + '/Desktop', function (desktopSuggestions) {
desktopSuggestions = desktopSuggestions.map(function (suggestion) {
suggestion.name = suggestion.path;
suggestion.path = homedir + '/Desktop/' + suggestion.path;
return suggestion;
});
var result = getTopRanking(homeSuggestions.concat(desktopSuggestions));
cb(null, result)
})
})
}
exports.scan = function (path, process, cb) {
cpp([exports.bin, path], '\n', function (line) {
// line follows specific format: inode space isDir space path
// line follows specific format: inode isDir path
var space = line.indexOf(' ');

@@ -9,0 +69,0 @@ var inode = parseInt(line.slice(0, space));

5

package.json
{
"name": "better-scanner",
"version": "1.3.0",
"version": "1.4.0",
"description": "Fast way to scan a directory and get all of the inodes",
"main": "index.js",
"dependencies": {
"child-process-parser": "^1.0.0"
"child-process-parser": "^1.0.0",
"clusters": "0.0.4"
},

@@ -9,0 +10,0 @@ "devDependencies": {},

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