Skip to content

Commit ae9df9c

Browse files
refactor(token-predicate): simplify negate function (#153)
1 parent a3304b9 commit ae9df9c

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

src/token-predicate.mjs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
1-
/**
2-
* Negate the result of `this` calling.
3-
* @param {Token} token The token to check.
4-
* @returns {boolean} `true` if the result of `this(token)` is `false`.
5-
*/
6-
function negate0(token) {
7-
return !this(token) //eslint-disable-line no-invalid-this
8-
}
9-
101
/**
112
* Creates the negate function of the given function.
123
* @param {function(Token):boolean} f - The function to negate.
134
* @returns {function(Token):boolean} Negated function.
145
*/
156
function negate(f) {
16-
return negate0.bind(f)
7+
return (token) => !f(token)
178
}
189

1910
/**

0 commit comments

Comments
 (0)