Skip to content

Commit c1b165f

Browse files
committed
Use native Array.prototype.map
1 parent af783ac commit c1b165f

File tree

2 files changed

+4
-15
lines changed

2 files changed

+4
-15
lines changed

scan.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,11 @@ module.exports = function (source) {
3333
}
3434

3535
function operator () {
36-
var string = util.oneOf(util.map(
37-
['WITH', 'AND', 'OR', '(', ')', ':', '+'],
38-
function (s) {
36+
var string = util.oneOf(
37+
['WITH', 'AND', 'OR', '(', ')', ':', '+'].map(function (s) {
3938
return function () { return read(s) }
40-
}
41-
))
39+
})
40+
)
4241

4342
if (string === '+' && index > 1 && source[index - 2] === ' ') {
4443
throw new Error('Space before `+`')

util.js

-10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
2-
function map (array, func) {
3-
var result = []
4-
for (var i = 0; i < array.length; i++) {
5-
result.push(func(array[i]))
6-
}
7-
return result
8-
}
9-
101
// Returns the return value of the first function which returns a
112
// truthy value.
123
function oneOf (functions) {
@@ -19,6 +10,5 @@ function oneOf (functions) {
1910
}
2011

2112
module.exports = {
22-
map: map,
2313
oneOf: oneOf
2414
}

0 commit comments

Comments
 (0)