dot-wild icon indicating copy to clipboard operation
dot-wild copied to clipboard

Get value returned from function [deeply]

Open emahuni opened this issue 7 years ago • 0 comments

This package is awesome. I was actually writting something exactly like this. With a few exceptional rules tho. The difference was on the wildcard *. mine doesn't require that. but seeing this is already fully featured. Let's expand on that.

Key panther does something nice, take a look at this:

var getKeypath = require('keypather/get');
var obj = {
  foo: function () {
    return function () {
      return function () {
        return 'val';
      };
    };
  }
};
getKeypath(obj, "foo()()()"); // val

This should be easy to implement. Just call the function at the path end and return its value. Do that deeply as much as it takes.

emahuni avatar Aug 16 '18 06:08 emahuni