Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove lodash dependency #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions lib/bruteforce.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
/* eslint no-use-before-define:0 */

var debug = require("debug")("talon");
var _ = require("lodash");


module.exports = {
Expand Down Expand Up @@ -216,11 +215,13 @@ function extractSignature (msgBody) {
function getSignatureCandidate (lines) {
debug("getSignatureCandidate", lines);
// keep only non-empty lines: ["hello", "", "world"] → [0, 2]
var nonEmpty = _.filter(_.map(lines, function (line, index) {
return (line && line.trim()) ? index : null;
}), function isNotNull (index) {
return index !== null;
});
var nonEmpty = lines
.map(function (line, index) {
return (line && line.trim()) ? index : null
})
.filter(function (index) {
return index !== null
});
debug("nonEmpty", nonEmpty);

// if message is empty or just one line then there is no signature
Expand Down Expand Up @@ -263,7 +264,7 @@ function markCandidateIndices (lines, candidateIndices) {
// that did not seem very logical so I mark from the top to bottom here
debug("markCandidateIndices", lines, candidateIndices);
var markers = "";
_.forEachRight(candidateIndices, function (lineIdx) {
candidateIndices.slice().reverse().forEach(function (lineIdx) {
var line = lines[lineIdx].trim();
if (lineLengthIgnoringURLs(line) > TOO_LONG_SIGNATURE_LINE) {
markers += "l"; // Marked as too long
Expand Down Expand Up @@ -293,7 +294,7 @@ function processMarkedCandidateIndices (candidateIndices, markers) {
return [];
}

var found = _.filter(match)[1] || "";
var found = match.filter(Boolean)[1] || "";
var end = match.index + found.length;

var candidates = candidateIndices.slice(-end);
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
},
"homepage": "https://github.com/lmtm/node-talon",
"dependencies": {
"debug": "^2.1.1",
"lodash": "^3.2.0"
"debug": "^2.1.1"
},
"devDependencies": {
"chai": "^2.0.0",
Expand Down