Skip to content

Commit

Permalink
refactor(*): utilize es6 spread in addWords/removeWords
Browse files Browse the repository at this point in the history
BREAKING CHANGE: changes the way addWords is used, no longer accepts a single array as a parameter unless used with the spread operator
  • Loading branch information
web-mech committed Oct 23, 2018
1 parent 2e7e2e7 commit 656b87c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/badwords.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ var Filter = (function () {
*/
Filter.prototype.addWords = function addWords() {
let words = Array.from(arguments);
this.list = this.list.concat(words);

this.list.push(...words);

words.forEach(function (word) {
if (!!~this.exclude.indexOf(word)) {
Expand All @@ -93,8 +94,7 @@ var Filter = (function () {
* @param {(string|string[])} word - Word to add to whitelist.
*/
Filter.prototype.removeWords = function removeWords() {
let words = Array.from(arguments);
this.exclude.push.apply(this.exclude, words);
this.exclude.push(...Array.from(arguments));
};

return Filter;
Expand Down

0 comments on commit 656b87c

Please sign in to comment.