Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c86fc0d
commit e7baed6
Showing
27 changed files
with
11,062 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
module.exports = function(fp) { | ||
return /a\/.*\.txt/.test(fp); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
'use strict'; | ||
|
||
var fs = require('fs'); | ||
var argv = require('minimist')(process.argv.slice(2)); | ||
var chalk = require('chalk'); | ||
var path = require('path'); | ||
var mm = require('micromatch').makeRe; | ||
|
||
var c = argv.c || argv._[0] || '*'; | ||
var f = argv.f || argv._[1] || '*'; | ||
|
||
/** | ||
* Sanity check. run to ensure that | ||
* all fns return a correct result. | ||
*/ | ||
|
||
fs.readdirSync(__dirname + '/code').forEach(function (fp) { | ||
var fn = require(path.resolve(__dirname, 'code', fp)); | ||
var name = path.basename(fp, path.extname(fp)); | ||
if (mm(c).test(name) && /\.js/.test(fp)) { | ||
|
||
fs.readdirSync(__dirname + '/fixtures').forEach(function (fixture) { | ||
var basename = path.basename(fixture, path.extname(fixture)); | ||
if (mm(f).test(basename) && /\.js/.test(fixture)) { | ||
fixture = path.resolve(__dirname, 'fixtures', fixture); | ||
console.log(chalk.bold(name) + ':', fn.apply(null, require(fixture)).length); | ||
} | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
'use strict'; | ||
|
||
module.exports = require('array-filter'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
'use strict'; | ||
|
||
module.exports = require('../..'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
'use strict'; | ||
|
||
module.exports = function filter(arr, fn) { | ||
var res = []; | ||
|
||
for (var i in arr) { | ||
if (fn(arr[i], +i)) { | ||
res.push(arr[i]); | ||
} | ||
} | ||
|
||
return res; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
'use strict'; | ||
|
||
var iterator = require('make-iterator'); | ||
|
||
module.exports = function filter(arr, cb, thisArg) { | ||
cb = iterator(cb, thisArg); | ||
var len = arr.length; | ||
var res = []; | ||
|
||
for (var i = 0; i < len; i++) { | ||
var ele = arr[i]; | ||
|
||
if (cb(ele, i)) { | ||
res.push(ele); | ||
} | ||
} | ||
return res; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
'use strict'; | ||
|
||
module.exports = function filter(arr, cb) { | ||
var len = arr.length; | ||
|
||
for (var i = 0; i < len; i++) { | ||
if (!cb(arr[i])) { | ||
arr.splice(i, 1); | ||
} | ||
} | ||
|
||
return arr; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
'use strict'; | ||
|
||
module.exports = function filter(arr, cb) { | ||
var res = arr.slice(); | ||
|
||
for (var i = arr.length - 1; i >= 0; i--) { | ||
if (cb(arr[i])) { | ||
continue; | ||
} | ||
res.splice(i, 1); | ||
} | ||
|
||
return res; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
'use strict'; | ||
|
||
module.exports = function filter(arr, cb) { | ||
var res = arr.slice(); | ||
|
||
for (var i = arr.length - 1; i >= 0; i--) { | ||
if (!cb(arr[i])) { | ||
res.splice(i, 1); | ||
} | ||
} | ||
|
||
return res; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
'use strict'; | ||
|
||
module.exports = function filter(arr, cb) { | ||
var len = arr.length; | ||
var res = []; | ||
|
||
for (var i = 0; i < len; i++) { | ||
var ele = arr[i]; | ||
|
||
if (cb(ele, i)) { | ||
res.push(ele); | ||
} | ||
} | ||
return res; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use strict'; | ||
|
||
module.exports = function filter(arr, cb) { | ||
return arr.filter(cb); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict'; | ||
|
||
module.exports = function filter(arr, cb) { | ||
var res = []; | ||
var len = arr.length; | ||
var i = 0; | ||
|
||
while (len--) { | ||
var val = arr[len]; | ||
if (!cb(val)) { | ||
continue; | ||
} | ||
res[i++] = val; | ||
} | ||
return res; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
'use strict'; | ||
|
||
var iterator = require('make-iterator'); | ||
|
||
module.exports = function filter(arr, cb, thisArg) { | ||
cb = iterator(cb, thisArg); | ||
var len = arr.length; | ||
var res = []; | ||
var i = 0; | ||
|
||
while (len--) { | ||
var ele = arr[i++]; | ||
|
||
if (cb(ele, i, arr)) { | ||
res.push(ele); | ||
} | ||
} | ||
return res; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict'; | ||
|
||
module.exports = function filter(arr, cb) { | ||
var len = arr.length; | ||
var res = []; | ||
var i = 0; | ||
|
||
while (len--) { | ||
var ele = arr[len]; | ||
|
||
if (cb(ele)) { | ||
res.push(ele); | ||
} | ||
} | ||
return res; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
'use strict'; | ||
|
||
module.exports = function filter(arr, cb) { | ||
var len = arr.length; | ||
var res = arr.slice(); | ||
|
||
while (len--) { | ||
if (cb(arr[len])) { | ||
continue; | ||
} | ||
res.splice(len, 1); | ||
} | ||
|
||
return res; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
'use strict'; | ||
|
||
module.exports = function filter(arr, cb) { | ||
var len = arr.length; | ||
var res = arr.slice(); | ||
|
||
while (len--) { | ||
if (!cb(arr[len])) { | ||
res.splice(len, 1); | ||
} | ||
} | ||
|
||
return res; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use strict'; | ||
|
||
var iterator = require('make-iterator'); | ||
|
||
module.exports = function filter(arr, cb, thisArg) { | ||
cb = iterator(cb, thisArg); | ||
var len = arr.length; | ||
|
||
while (len--) { | ||
if (cb(arr[len])) { | ||
continue; | ||
} | ||
arr.splice(len, 1); | ||
} | ||
|
||
return arr; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
'use strict'; | ||
|
||
module.exports = function filter(arr, cb) { | ||
var len = arr.length; | ||
|
||
while (len--) { | ||
if (cb(arr[len])) { | ||
continue; | ||
} | ||
arr.splice(len, 1); | ||
} | ||
|
||
return arr; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
'use strict'; | ||
|
||
module.exports = function filter(arr, cb) { | ||
var len = arr.length; | ||
|
||
while (len--) { | ||
cb(arr[len]) || arr.splice(len, 1); | ||
} | ||
|
||
return arr; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
'use strict'; | ||
|
||
module.exports = function filter(arr, cb) { | ||
var len = arr.length; | ||
|
||
while (len--) { | ||
if (!cb(arr[len])) { | ||
arr.splice(len, 1); | ||
} | ||
} | ||
|
||
return arr; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict'; | ||
|
||
module.exports = function filter(arr, cb) { | ||
var len = arr.length; | ||
var res = []; | ||
var i = 0; | ||
|
||
while (len--) { | ||
var ele = arr[i++]; | ||
|
||
if (cb(ele, i, arr)) { | ||
res.push(ele); | ||
} | ||
} | ||
return res; | ||
}; |
Oops, something went wrong.