From bd98e44f7aaa3cd9fb84fff3ad4f2eadfaa2db3c Mon Sep 17 00:00:00 2001 From: jquense Date: Sun, 20 Dec 2015 20:22:10 -0500 Subject: [PATCH] [added] tap() method --- src/common.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/common.js b/src/common.js index d741952..1698818 100644 --- a/src/common.js +++ b/src/common.js @@ -25,10 +25,8 @@ export default function($){ return this }, - get() { - var result = [] - this.each(el => result.push(el)) - return result + tap(fn) { + fn.call(this, this) }, reduce(cb, initial){ @@ -42,13 +40,19 @@ export default function($){ }, []) }, + get() { + var result = [] + this.each(el => result.push(el)) + return result + }, + find(selector) { return this._reduce((result, element) => { return result.concat($.match(selector, element, false)) }, []) }, - traverse(test){ + traverse(test) { return this._reduce((result, element) => { return result.concat(utils.traverse(element, test)) }, [])