or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

index.md
tile.json

tessl/npm-lodash--isiterateecall

Internal lodash utility that detects iteratee callback invocation patterns for method chaining and array/object iteration.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/lodash._isiterateecall@3.0.x

To install, run

npx @tessl/cli install tessl/npm-lodash--isiterateecall@3.0.0

index.mddocs/

lodash._isiterateecall

Internal lodash utility function that determines whether provided arguments are from an iteratee call in the context of lodash operations. This function analyzes callback invocation patterns to enable lodash's method chaining and iteratee detection system.

Package Information

  • Package Name: lodash._isiterateecall
  • Package Type: npm
  • Language: JavaScript
  • Installation: npm install lodash._isiterateecall

Core Imports

const isIterateeCall = require('lodash._isiterateecall');

Basic Usage

const isIterateeCall = require('lodash._isiterateecall');

// Check if arguments match iteratee call pattern
const users = [{ name: 'Alice' }, { name: 'Bob' }];

// These would return true in an iteratee context:
// isIterateeCall(user, 0, users) => true (when called from array method)
// isIterateeCall(user, 'name', userObject) => true (when called from object method)

// Direct calls typically return false:
const result1 = isIterateeCall({ name: 'Alice' }, 0, users);
// => false (not from iteratee context)

const result2 = isIterateeCall('value', 'key', { key: 'value' });  
// => true (matches object property pattern)

const result3 = isIterateeCall('different', 'key', { key: 'value' });
// => false (value doesn't match object[key])

Capabilities

Iteratee Call Detection

Determines whether three arguments represent a callback invocation pattern from lodash iteration methods like map, filter, and forEach.

/**
 * Checks if the provided arguments are from an iteratee call.
 * 
 * @param {*} value - The potential iteratee value argument
 * @param {*} index - The potential iteratee index or key argument  
 * @param {*} object - The potential iteratee object argument
 * @returns {boolean} Returns true if the arguments are from an iteratee call, else false
 */
function isIterateeCall(value, index, object)

Detection Logic:

The function performs several validation checks:

  1. Object Validation: Ensures the third argument is an object (not null/undefined)
  2. Index Type Checking: Handles both numeric indices and string keys
  3. Array-like Detection: For numeric indices, validates the object is array-like and index is valid
  4. Property Access: For string keys, verifies the key exists in the object
  5. Value Matching: Compares the value argument with object[index], handling NaN cases correctly

Usage Examples:

const isIterateeCall = require('lodash._isiterateecall');

// Array-like iteratee patterns
const arr = ['a', 'b', 'c'];
isIterateeCall('a', 0, arr);  // => true
isIterateeCall('b', 1, arr);  // => true  
isIterateeCall('wrong', 0, arr);  // => false

// Object iteratee patterns  
const obj = { x: 10, y: 20 };
isIterateeCall(10, 'x', obj);  // => true
isIterateeCall(20, 'y', obj);  // => true
isIterateeCall(30, 'x', obj);  // => false

// NaN handling
const nanObj = { prop: NaN };
isIterateeCall(NaN, 'prop', nanObj);  // => true (special NaN comparison)

// Invalid cases
isIterateeCall('any', 'key', null);  // => false (null object)
isIterateeCall('any', -1, arr);  // => false (invalid index)
isIterateeCall('any', 'missing', obj);  // => false (key doesn't exist)

Edge Cases:

  • NaN Values: Uses special comparison logic (value === value ? (value === other) : (other !== other)) to correctly handle NaN comparisons
  • Type Coercion: Numeric strings are converted to numbers for index validation
  • Array-like Objects: Validates indices using length property and MAX_SAFE_INTEGER bounds
  • Non-objects: Returns false immediately if the object parameter is null, undefined, or primitive

This function is essential for lodash's internal operation, enabling the library to distinguish between direct function calls and callback invocations from iteration methods, which is crucial for proper method chaining and iteratee behavior.