MCPcopy Index your code
hub / github.com/nodejs/node / firstDefined

Function firstDefined

test/fixtures/snapshot/typescript.js:402–413  ·  view source on GitHub ↗

Like `forEach`, but suitable for use with numbers and strings (which may be falsy).

(array, callback)

Source from the content-addressed store, hash-verified

400 ts.forEachRight = forEachRight;
401 /** Like `forEach`, but suitable for use with numbers and strings (which may be falsy). */
402 function firstDefined(array, callback) {
403 if (array === undefined) {
404 return undefined;
405 }
406 for (var i = 0; i < array.length; i++) {
407 var result = callback(array[i], i);
408 if (result !== undefined) {
409 return result;
410 }
411 }
412 return undefined;
413 }
414 ts.firstDefined = firstDefined;
415 function firstDefinedIterator(iter, callback) {
416 while (true) {

Callers

nothing calls this directly

Calls 1

callbackFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…