console.js icon indicating copy to clipboard operation
console.js copied to clipboard

console.find(where, what)

Open NV opened this issue 14 years ago • 0 comments

Or console.grep, or console.filter. I don't know yet.

Objects:

obj = {
  a: 1,
  b: {c: [1, "buz"]}
}

>>> console.find(obj, 1)
-> [obj.a, obj.b.c]
>>> console.find(obj, [1, "buz"])
-> obj.b.c

DOM:

<body>
  <p>Fuuuuuuuu!</p>
  <p>Bar.</p>
</body>

>>> console.find(document.body, function(e){
  return e.textContent.indexOf('Fuu') === 0
}
->  <p>Fuuuuuuuu!</p>

Inspired by method_finder.

NV avatar Apr 13 '10 11:04 NV