Skip to content

Commit 656b87c

Browse files
committed
refactor(*): utilize es6 spread in addWords/removeWords
BREAKING CHANGE: changes the way addWords is used, no longer accepts a single array as a parameter unless used with the spread operator
1 parent 2e7e2e7 commit 656b87c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/badwords.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ var Filter = (function () {
7979
*/
8080
Filter.prototype.addWords = function addWords() {
8181
let words = Array.from(arguments);
82-
this.list = this.list.concat(words);
82+
83+
this.list.push(...words);
8384

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

100100
return Filter;

0 commit comments

Comments
 (0)