CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-lodash-es

Lodash utility library exported as ES6 modules for modern JavaScript applications with tree-shaking support.

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

object.mddocs/

Object Functions

Object manipulation functions for property access, modification, merging, and transformation including deep operations and property path handling.

Capabilities

Property Access

Functions for getting and checking object properties, including deep property paths.

/**
 * Gets the value at path of object
 * @param {Object} object - The object to query
 * @param {Array|string} path - The path of the property to get
 * @param {*} defaultValue - The value returned for undefined resolved values
 * @returns {*} Returns the resolved value
 */
function get(object, path, defaultValue);

/**
 * Checks if path is a direct property of object
 * @param {Object} object - The object to query
 * @param {Array|string} path - The path to check
 * @returns {boolean} Returns true if path exists, else false
 */
function has(object, path);

/**
 * Checks if path is a direct or inherited property of object
 * @param {Object} object - The object to query
 * @param {Array|string} path - The path to check
 * @returns {boolean} Returns true if path exists, else false
 */
function hasIn(object, path);

/**
 * Gets the value at path of object. If the resolved value is a function it's invoked
 * @param {Object} object - The object to query
 * @param {Array|string} path - The path of the property to get
 * @param {...*} args - The arguments to invoke the function with
 * @returns {*} Returns the resolved value
 */
function result(object, path, ...args);

Property Modification

Functions for setting, updating, and removing object properties.

/**
 * Sets the value at path of object
 * @param {Object} object - The object to modify
 * @param {Array|string} path - The path of the property to set
 * @param {*} value - The value to set
 * @returns {Object} Returns object
 */
function set(object, path, value);

/**
 * Like set but accepts customizer which is invoked to produce the objects of path
 * @param {Object} object - The object to modify
 * @param {Array|string} path - The path of the property to set
 * @param {*} value - The value to set
 * @param {Function} customizer - The function to customize assigned values
 * @returns {Object} Returns object
 */
function setWith(object, path, value, customizer);

/**
 * Removes the property at path of object
 * @param {Object} object - The object to modify
 * @param {Array|string} path - The path of the property to unset
 * @returns {boolean} Returns true if the property is deleted, else false
 */
function unset(object, path);

/**
 * Sets the value at path of object to the result of updater
 * @param {Object} object - The object to modify
 * @param {Array|string} path - The path of the property to update
 * @param {Function} updater - The function to produce the updated value
 * @returns {Object} Returns object
 */
function update(object, path, updater);

/**
 * Like update but accepts customizer which is invoked to produce the objects of path
 * @param {Object} object - The object to modify
 * @param {Array|string} path - The path of the property to update
 * @param {Function} updater - The function to produce the updated value
 * @param {Function} customizer - The function to customize assigned values
 * @returns {Object} Returns object
 */
function updateWith(object, path, updater, customizer);

Object Keys and Values

Functions for extracting keys, values, and key-value pairs from objects.

/**
 * Creates an array of the own enumerable property names of object
 * @param {Object} object - The object to query
 * @returns {Array} Returns the array of property names
 */
function keys(object);

/**
 * Creates an array of the own and inherited enumerable property names of object
 * @param {Object} object - The object to query
 * @returns {Array} Returns the array of property names
 */
function keysIn(object);

/**
 * Creates an array of the own enumerable string keyed property values of object
 * @param {Object} object - The object to query
 * @returns {Array} Returns the array of property values
 */
function values(object);

/**
 * Creates an array of the own and inherited enumerable string keyed property values of object
 * @param {Object} object - The object to query
 * @returns {Array} Returns the array of property values
 */
function valuesIn(object);

/**
 * Creates an array of own enumerable string keyed-value pairs for object
 * @param {Object} object - The object to query
 * @returns {Array} Returns the key-value pairs
 */
function toPairs(object);

/**
 * Creates an array of own and inherited enumerable string keyed-value pairs for object
 * @param {Object} object - The object to query
 * @returns {Array} Returns the key-value pairs
 */
function toPairsIn(object);

/**
 * Alias for toPairs
 * @param {Object} object - The object to query
 * @returns {Array} Returns the key-value pairs
 */
function entries(object);

/**
 * Alias for toPairsIn
 * @param {Object} object - The object to query
 * @returns {Array} Returns the key-value pairs
 */
function entriesIn(object);

Object Assignment and Merging

Functions for copying properties between objects and merging objects.

/**
 * Assigns own enumerable string keyed properties of source objects to the destination object
 * @param {Object} object - The destination object
 * @param {...Object} sources - The source objects
 * @returns {Object} Returns object
 */
function assign(object, ...sources);

/**
 * Like assign but iterates over own and inherited source properties
 * @param {Object} object - The destination object
 * @param {...Object} sources - The source objects
 * @returns {Object} Returns object
 */
function assignIn(object, ...sources);

/**
 * Like assign but accepts customizer which is invoked to produce the assigned values
 * @param {Object} object - The destination object
 * @param {...Object} sources - The source objects
 * @param {Function} customizer - The function to customize assigned values
 * @returns {Object} Returns object
 */
function assignWith(object, ...sources, customizer);

/**
 * Like assignIn but accepts customizer which is invoked to produce the assigned values
 * @param {Object} object - The destination object
 * @param {...Object} sources - The source objects
 * @param {Function} customizer - The function to customize assigned values
 * @returns {Object} Returns object
 */
function assignInWith(object, ...sources, customizer);

/**
 * Alias for assignIn
 * @param {Object} object - The destination object
 * @param {...Object} sources - The source objects
 * @returns {Object} Returns object
 */
function extend(object, ...sources);

/**
 * Alias for assignInWith
 * @param {Object} object - The destination object
 * @param {...Object} sources - The source objects
 * @param {Function} customizer - The function to customize assigned values
 * @returns {Object} Returns object
 */
function extendWith(object, ...sources, customizer);

/**
 * Recursively merges own and inherited enumerable string keyed properties of source objects
 * @param {Object} object - The destination object
 * @param {...Object} sources - The source objects
 * @returns {Object} Returns object
 */
function merge(object, ...sources);

/**
 * Like merge but accepts customizer which is invoked to produce the merged values
 * @param {Object} object - The destination object
 * @param {...Object} sources - The source objects
 * @param {Function} customizer - The function to customize assigned values
 * @returns {Object} Returns object
 */
function mergeWith(object, ...sources, customizer);

Object Defaults

Functions for setting default property values.

/**
 * Assigns own and inherited enumerable string keyed properties of source objects to the destination object for all destination properties that resolve to undefined
 * @param {Object} object - The destination object
 * @param {...Object} sources - The source objects
 * @returns {Object} Returns object
 */
function defaults(object, ...sources);

/**
 * Like defaults but recursively assigns default properties
 * @param {Object} object - The destination object
 * @param {...Object} sources - The source objects
 * @returns {Object} Returns object
 */
function defaultsDeep(object, ...sources);

Object Property Selection

Functions for selecting and omitting object properties.

/**
 * Creates an object composed of the picked object properties
 * @param {Object} object - The source object
 * @param {...(string|string[])} paths - The property paths to pick
 * @returns {Object} Returns the new object
 */
function pick(object, ...paths);

/**
 * Creates an object composed of the object properties predicate returns truthy for
 * @param {Object} object - The source object
 * @param {Function} predicate - The function invoked per property
 * @returns {Object} Returns the new object
 */
function pickBy(object, predicate);

/**
 * Creates an object composed of the own and inherited enumerable property paths of object that are not omitted
 * @param {Object} object - The source object
 * @param {...(string|string[])} paths - The property paths to omit
 * @returns {Object} Returns the new object
 */
function omit(object, ...paths);

/**
 * The opposite of pickBy; creates an object composed of the own and inherited enumerable string keyed properties of object that predicate doesn't return truthy for
 * @param {Object} object - The source object
 * @param {Function} predicate - The function invoked per property
 * @returns {Object} Returns the new object
 */
function omitBy(object, predicate);

/**
 * Creates an array of values corresponding to paths of object
 * @param {Object} object - The object to query
 * @param {...(string|string[])} paths - The property paths to get
 * @returns {Array} Returns the array of property values
 */
function at(object, ...paths);

Object Iteration

Functions for iterating over object properties.

/**
 * Iterates over own enumerable string keyed properties of an object and invokes iteratee for each property
 * @param {Object} object - The object to iterate over
 * @param {Function} iteratee - The function invoked per iteration
 * @returns {Object} Returns object
 */
function forOwn(object, iteratee);

/**
 * Like forOwn but iterates over properties in the opposite order
 * @param {Object} object - The object to iterate over
 * @param {Function} iteratee - The function invoked per iteration
 * @returns {Object} Returns object
 */
function forOwnRight(object, iteratee);

/**
 * Iterates over own and inherited enumerable string keyed properties of an object and invokes iteratee for each property
 * @param {Object} object - The object to iterate over
 * @param {Function} iteratee - The function invoked per iteration
 * @returns {Object} Returns object
 */
function forIn(object, iteratee);

/**
 * Like forIn but iterates over properties in the opposite order
 * @param {Object} object - The object to iterate over
 * @param {Function} iteratee - The function invoked per iteration
 * @returns {Object} Returns object
 */
function forInRight(object, iteratee);

Object Search

Functions for finding properties within objects.

/**
 * Returns the key of the first element predicate returns truthy for
 * @param {Object} object - The object to inspect
 * @param {Function} predicate - The function invoked per iteration
 * @returns {string|undefined} Returns the key of the matched element, else undefined
 */
function findKey(object, predicate);

/**
 * Like findKey but iterates over the object's properties in the opposite order
 * @param {Object} object - The object to inspect
 * @param {Function} predicate - The function invoked per iteration
 * @returns {string|undefined} Returns the key of the matched element, else undefined
 */
function findLastKey(object, predicate);

Object Key/Value Transformation

Functions for transforming object keys and values.

/**
 * Creates an object with the same values as object and keys generated by running each own enumerable string keyed property of object thru iteratee
 * @param {Object} object - The object to iterate over
 * @param {Function} iteratee - The function invoked per iteration
 * @returns {Object} Returns the new mapped object
 */
function mapKeys(object, iteratee);

/**
 * Creates an object with the same keys as object and values generated by running each own enumerable string keyed property of object thru iteratee
 * @param {Object} object - The object to iterate over
 * @param {Function} iteratee - The function invoked per iteration
 * @returns {Object} Returns the new mapped object
 */
function mapValues(object, iteratee);

/**
 * An alternative to _.reduce; this method transforms object to a new accumulator object
 * @param {Array|Object} object - The object to iterate over
 * @param {Function} iteratee - The function invoked per iteration
 * @param {*} accumulator - The custom accumulator value
 * @returns {*} Returns the accumulated value
 */
function transform(object, iteratee, accumulator);

Object Inversion

Functions for inverting object key-value relationships.

/**
 * Creates an object composed of the inverted keys and values of object
 * @param {Object} object - The object to invert
 * @returns {Object} Returns the new inverted object
 */
function invert(object);

/**
 * Like invert but the inverted object is generated from the results of running each element of object thru iteratee
 * @param {Object} object - The object to invert
 * @param {Function} iteratee - The function invoked per iteration
 * @returns {Object} Returns the new inverted object
 */
function invertBy(object, iteratee);

Object Function Properties

Functions for working with function properties of objects.

/**
 * Creates an array of function property names from own enumerable properties of object
 * @param {Object} object - The object to inspect
 * @returns {Array} Returns the function names
 */
function functions(object);

/**
 * Creates an array of function property names from own and inherited enumerable properties of object
 * @param {Object} object - The object to inspect
 * @returns {Array} Returns the function names
 */
function functionsIn(object);

/**
 * Invokes the method at path of object
 * @param {Object} object - The object to query
 * @param {Array|string} path - The path of the method to invoke
 * @param {...*} args - The arguments to invoke the method with
 * @returns {*} Returns the result of the invoked method
 */
function invoke(object, path, ...args);

Object Creation

Functions for creating new objects.

/**
 * Creates an object that inherits from the prototype object
 * @param {Object} prototype - The object to inherit from
 * @param {Object} properties - The properties to assign to the object
 * @returns {Object} Returns the new object
 */
function create(prototype, properties);

Usage Examples

Property Access and Modification

import { get, set, has, unset } from "lodash-es";

const user = {
  name: "Alice",
  profile: {
    age: 25,
    settings: {
      theme: "dark",
      notifications: true
    }
  }
};

// Get nested properties
const age = get(user, "profile.age"); // 25
const theme = get(user, "profile.settings.theme", "light"); // "dark"
const missing = get(user, "profile.bio", "No bio"); // "No bio"

// Check property existence
const hasAge = has(user, "profile.age"); // true
const hasBio = has(user, "profile.bio"); // false

// Set nested properties
set(user, "profile.bio", "Software engineer");
set(user, "profile.settings.language", "en");

// Remove properties
unset(user, "profile.settings.notifications");

Object Merging and Assignment

import { assign, merge, defaults, pick, omit } from "lodash-es";

const target = { a: 1, b: 2 };
const source1 = { b: 3, c: 4 };
const source2 = { c: 5, d: 6 };

// Shallow assignment (modifies target)
assign(target, source1, source2); // { a: 1, b: 3, c: 5, d: 6 }

// Deep merging
const obj1 = { user: { name: "Alice", age: 25 } };
const obj2 = { user: { age: 26, city: "NYC" } };
const merged = merge({}, obj1, obj2); // { user: { name: "Alice", age: 26, city: "NYC" } }

// Set defaults
const config = { timeout: 1000 };
defaults(config, { timeout: 5000, retries: 3 }); // { timeout: 1000, retries: 3 }

// Pick and omit properties
const data = { name: "Alice", age: 25, password: "secret", email: "alice@example.com" };
const publicData = omit(data, ["password"]); // { name: "Alice", age: 25, email: "alice@example.com" }
const basicInfo = pick(data, ["name", "age"]); // { name: "Alice", age: 25 }

Object Transformation

import { mapKeys, mapValues, transform, keys, values, toPairs } from "lodash-es";

const scores = { alice: 85, bob: 92, charlie: 78 };

// Transform keys
const upperKeys = mapKeys(scores, (value, key) => key.toUpperCase());
// { ALICE: 85, BOB: 92, CHARLIE: 78 }

// Transform values
const percentages = mapValues(scores, score => `${score}%`);
// { alice: "85%", bob: "92%", charlie: "78%" }

// Custom transformation
const result = transform(
  scores,
  (acc, score, name) => {
    if (score >= 80) {
      acc.push({ name, score, grade: "A" });
    }
  },
  []
);
// [{ name: "alice", score: 85, grade: "A" }, { name: "bob", score: 92, grade: "A" }]

// Extract keys, values, and pairs
const names = keys(scores); // ["alice", "bob", "charlie"]
const scoreValues = values(scores); // [85, 92, 78]
const pairs = toPairs(scores); // [["alice", 85], ["bob", 92], ["charlie", 78]]

Advanced Object Operations

import { findKey, invert, functions, invoke } from "lodash-es";

const users = {
  alice: { age: 25, active: true },
  bob: { age: 30, active: false },
  charlie: { age: 35, active: true }
};

// Find key by predicate
const firstActive = findKey(users, { active: true }); // "alice"
const over30 = findKey(users, user => user.age > 30); // "charlie"

// Invert object
const ageToName = invert(mapValues(users, "age")); // { "25": "alice", "30": "bob", "35": "charlie" }

// Work with function properties
const calculator = {
  add: (a, b) => a + b,
  multiply: (a, b) => a * b,
  name: "Calculator"
};

const methods = functions(calculator); // ["add", "multiply"]
const result = invoke(calculator, "add", 5, 3); // 8

docs

array.md

collection.md

date.md

function.md

index.md

lang.md

math.md

number.md

object.md

seq.md

string.md

util.md

tile.json