From f89862161e540b234971e3dfcdcea5e07d7187e5 Mon Sep 17 00:00:00 2001 From: citycide Date: Mon, 14 Nov 2016 12:22:33 -0600 Subject: [PATCH 1/3] feat: allow passing args to object methods Add the ability to pass arguments to object methods in a space delimited format. From what I understand, this would preclude strict adherence to Python's string formatting where spaces would be valid in keys when resolving against the object. --- index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index bcefd18..3eaf21e 100644 --- a/index.js +++ b/index.js @@ -64,7 +64,12 @@ } for (var idx = 0; idx < path.length; idx += 1) { var key = path[idx]; - obj = typeof obj[key] === 'function' ? obj[key]() : obj[key]; + var call = key.split(' '); + var fn = call[0]; + var args = call.slice(1); + obj = typeof obj[fn] === 'function' + ? obj[fn].apply(null, args) + : obj[key]; } return obj; }; From aae3825d7fa300489ff87f4d4f07b5b04bb1ec43 Mon Sep 17 00:00:00 2001 From: citycide Date: Mon, 14 Nov 2016 13:47:00 -0600 Subject: [PATCH 2/3] fix: method binding Change from a `null` binding to binding the method to its object. This fixes things like prototype methods (toLowerCase). --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 3eaf21e..0e7ebcb 100644 --- a/index.js +++ b/index.js @@ -68,7 +68,7 @@ var fn = call[0]; var args = call.slice(1); obj = typeof obj[fn] === 'function' - ? obj[fn].apply(null, args) + ? obj[fn].apply(obj, args) : obj[key]; } return obj; From dd488006b5327be2541f3a2d73005f936c5f8b6a Mon Sep 17 00:00:00 2001 From: citycide Date: Mon, 14 Nov 2016 13:54:38 -0600 Subject: [PATCH 3/3] fix(lint): ternary line breaking --- index.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/index.js b/index.js index 0e7ebcb..5331d30 100644 --- a/index.js +++ b/index.js @@ -67,9 +67,7 @@ var call = key.split(' '); var fn = call[0]; var args = call.slice(1); - obj = typeof obj[fn] === 'function' - ? obj[fn].apply(obj, args) - : obj[key]; + obj = typeof obj[fn] === 'function' ? obj[fn].apply(obj, args) : obj[key]; } return obj; };