remove-words
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -18,3 +18,4 @@ /** | ||
var istanbul= require('gulp-istanbul'); | ||
//var uglify = require('gulp-uglify'); // Uncomment here and below to minify js | ||
var brfs = require('gulp-brfs'); | ||
var uglify = require('gulp-uglify'); | ||
@@ -34,7 +35,8 @@ require('coffee-script/register'); | ||
gulp.task('build', ['clean'], function(){ | ||
return gulp.src('./src/**/*.coffee') | ||
return gulp.src('./index.coffee') | ||
.pipe(lint()) | ||
.pipe(lint.reporter()) | ||
.pipe(coffee()) | ||
//.pipe(uglify()) // Uncomment to minify JS | ||
.pipe(brfs()) | ||
.pipe(uglify()) | ||
.pipe(footer(footerTxt)) | ||
@@ -61,3 +63,3 @@ .pipe(size()) | ||
gulp.task('watch', function(){ | ||
gulp.watch('./src/**/*.coffee', ['test-after-build']); | ||
gulp.watch('./index.coffee', ['test-after-build']); | ||
gulp.watch('./test/**/*.coffee', ['test']); | ||
@@ -72,2 +74,2 @@ }); | ||
/* Defualt gulp task, deletes old files, compiles source files and runs tests */ | ||
gulp.task('default', ['test-after-build', 'watch']); | ||
gulp.task('default', ['test-after-build']); |
95
index.js
@@ -1,95 +0,2 @@ | ||
(function() { | ||
var _private, arrayifySentence, formatSentence, formatWordsArr, fs, removeDuplicates, removeWords; | ||
fs = require('fs'); | ||
_private = {}; | ||
removeWords = function(sentence, wordsArray) { | ||
var dictionaryWord, index, j, k, len, len1, sentenceArr, sentenceWord; | ||
if (wordsArray == null) { | ||
wordsArray = void 0; | ||
} | ||
if (wordsArray == null) { | ||
wordsArray = fs.readFileSync(__dirname + '/words.txt', 'utf8').split('\r\n'); | ||
} else { | ||
wordsArray = typeof wordsArray === 'string' ? [wordsArray] : wordsArray; | ||
wordsArray = formatWordsArr(wordsArray); | ||
} | ||
sentence = typeof sentence === 'string' ? sentence : ''; | ||
sentenceArr = arrayifySentence(sentence); | ||
for (j = 0, len = wordsArray.length; j < len; j++) { | ||
dictionaryWord = wordsArray[j]; | ||
for (index = k = 0, len1 = sentenceArr.length; k < len1; index = ++k) { | ||
sentenceWord = sentenceArr[index]; | ||
if (sentenceWord === dictionaryWord) { | ||
sentenceArr.splice(index, 1); | ||
} | ||
} | ||
} | ||
return removeDuplicates(sentenceArr); | ||
}; | ||
arrayifySentence = function(sentence) { | ||
sentence = formatSentence(sentence); | ||
sentence = sentence.split(' '); | ||
return sentence = sentence.filter(function(n) { | ||
return n !== ''; | ||
}); | ||
}; | ||
formatWordsArr = function(wordsArr) { | ||
var i, j, len, word; | ||
if (!wordsArr instanceof Array) { | ||
return []; | ||
} | ||
for (i = j = 0, len = wordsArr.length; j < len; i = ++j) { | ||
word = wordsArr[i]; | ||
wordsArr[i] = formatSentence(word); | ||
} | ||
return wordsArr; | ||
}; | ||
formatSentence = function(sentence) { | ||
sentence = sentence != null ? sentence : ''; | ||
sentence = sentence.toLowerCase(); | ||
sentence = sentence.replace(/(?:https?|ftp):\/\/[\n\S]+/g, ''); | ||
return sentence = sentence.replace(/[^\w\s]/gi, ''); | ||
}; | ||
removeDuplicates = function(arr) { | ||
var j, key, ref, res, results, value; | ||
if (arr.length === 0) { | ||
return []; | ||
} | ||
res = {}; | ||
for (key = j = 0, ref = arr.length - 1; 0 <= ref ? j <= ref : j >= ref; key = 0 <= ref ? ++j : --j) { | ||
res[arr[key]] = arr[key]; | ||
} | ||
results = []; | ||
for (key in res) { | ||
value = res[key]; | ||
results.push(value); | ||
} | ||
return results; | ||
}; | ||
_private = { | ||
arrayifySentence: arrayifySentence, | ||
formatWordsArr: formatWordsArr, | ||
formatSentence: formatSentence, | ||
removeDuplicates: removeDuplicates | ||
}; | ||
module.exports = removeWords; | ||
if (process.env.NODE_ENV === 'test') { | ||
module.exports = { | ||
main: removeWords, | ||
_private: _private | ||
}; | ||
} | ||
}).call(this); | ||
/* (C) Alicia Sykes <alicia@aliciasykes.com> 2015 *\ | ||
(function(){var n,r,e,t,o,i,s;require.extensions[".txt"]=function(n,r){return n.exports=o.readFileSync(r,"utf8")},n={},s=function(n,e){var o,s,h,a,u,l,f,c;for(null==e&&(e=void 0),null==e?e="aboard\r\nabout\r\nabove\r\nacross\r\nand\r\nafter\r\nagainst\r\nare\r\ngoing\r\nall\r\nalong\r\nalthough\r\namid\r\namong\r\nanother\r\nanti\r\nany\r\nanybody\r\nanyone\r\nanything\r\naround\r\nas\r\nat\r\nbecause\r\nbefore\r\nbehind\r\nbe\r\nbelow\r\nbeneath\r\nbeside\r\nbesides\r\nbetween\r\nbeyond\r\nboth\r\nbut\r\nby\r\nconcerning\r\nconsidering\r\ndespite\r\ndown\r\nduring\r\neach\r\neither\r\neven\r\nevery\r\neverybody\r\neveryone\r\neverything\r\nexcept\r\nexcepting\r\nexcluding\r\nfew\r\nfollowing\r\nfor\r\nfrom\r\nhe\r\nher\r\nhers\r\nherself\r\nhim\r\nhimself\r\nhis\r\nhow\r\nif\r\nin\r\nis\r\ninside\r\ninto\r\nit\r\nits\r\nitself\r\njust\r\nlike\r\nlittle\r\nmany\r\nme\r\nmine\r\nminus\r\nmore\r\nmost\r\nmuch\r\nmy\r\nmyself\r\nnear\r\nneither\r\nnobody\r\nnone\r\nnot\r\nnothing\r\nnow\r\nof\r\noff\r\non\r\nonce\r\none\r\nonly\r\nonto\r\nopposite\r\nother\r\nothers\r\nour\r\nours\r\nourselves\r\noutside\r\nover\r\npast\r\nper\r\nplus\r\nregarding\r\nround\r\nsave\r\nseveral\r\nshe\r\nsince\r\nsome\r\nso\r\nsomebody\r\nsomeone\r\nsomething\r\nthan\r\nthat\r\nthe\r\ntheir\r\ntheirs\r\nthem\r\nthemselves\r\nthese\r\nthey\r\nthis\r\nthose\r\nthough\r\nthrough\r\nto\r\ntoo\r\ntoward\r\ntowards\r\nunder\r\nunderneath\r\nunless\r\nunlike\r\nuntil\r\nup\r\nupon\r\nus\r\nversus\r\nvia\r\nwe\r\nwhat\r\nwhatever\r\nwhen\r\nwhenever\r\nwhereas\r\nwhether\r\nwhich\r\nwhichever\r\nwhile\r\nwho\r\nwhoever\r\nwhy\r\nwhom\r\nwhomever\r\nwhose\r\nwith\r\nwithin\r\nwithout\r\nyou\r\nyour\r\nyours\r\nyourself\r\nyourselves".split("\r\n"):(e="string"==typeof e?[e]:e,e=t(e)),n="string"==typeof n?n:"",f=r(n),h=0,u=e.length;u>h;h++)for(o=e[h],s=a=0,l=f.length;l>a;s=++a)c=f[s],c===o&&f.splice(s,1);return i(f)},r=function(n){return n=e(n),n=n.split(" "),n=n.filter(function(n){return""!==n})},t=function(n){var r,t,o,i;if(!n instanceof Array)return[];for(r=t=0,o=n.length;o>t;r=++t)i=n[r],n[r]=e(i);return n},e=function(n){return n=null!=n?n:"",n=n.toLowerCase(),n=n.replace(/(?:https?|ftp):\/\/[\n\S]+/g,""),n=n.replace(/[^\w\s]/gi,"")},i=function(n){var r,e,t,o,i,s;if(0===n.length)return[];for(o={},e=r=0,t=n.length-1;t>=0?t>=r:r>=t;e=t>=0?++r:--r)o[n[e]]=n[e];i=[];for(e in o)s=o[e],i.push(s);return i},n={arrayifySentence:r,formatWordsArr:t,formatSentence:e,removeDuplicates:i},module.exports=s,"test"===process.env.NODE_ENV&&(module.exports={main:s,_private:n})}).call(this);/* (C) Alicia Sykes <alicia@aliciasykes.com> 2015 *\ | ||
\* MIT License. Read full license at: https://goo.gl/IL4lQJ */ |
{ | ||
"name": "remove-words", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "A node module that returns all words from a string not that were not in a specified list. By default will remove all pronouns and conjunctions", | ||
@@ -27,2 +27,3 @@ "main": "index.js", | ||
"devDependencies": { | ||
"brfs": "^1.4.2", | ||
"chai": "^3.3.0", | ||
@@ -29,0 +30,0 @@ "coffee-script": "^1.10.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
17068
0
14
72