or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

array.mdcollection.mddate.mdfunction.mdindex.mdlang.mdmath.mdnumber.mdobject.mdseq.mdstring.mdutil.md
tile.json

object.mddocs/

0

# Object Functions

1

2

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

3

4

## Capabilities

5

6

### Property Access

7

8

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

9

10

```javascript { .api }

11

/**

12

* Gets the value at path of object

13

* @param {Object} object - The object to query

14

* @param {Array|string} path - The path of the property to get

15

* @param {*} defaultValue - The value returned for undefined resolved values

16

* @returns {*} Returns the resolved value

17

*/

18

function get(object, path, defaultValue);

19

20

/**

21

* Checks if path is a direct property of object

22

* @param {Object} object - The object to query

23

* @param {Array|string} path - The path to check

24

* @returns {boolean} Returns true if path exists, else false

25

*/

26

function has(object, path);

27

28

/**

29

* Checks if path is a direct or inherited property of object

30

* @param {Object} object - The object to query

31

* @param {Array|string} path - The path to check

32

* @returns {boolean} Returns true if path exists, else false

33

*/

34

function hasIn(object, path);

35

36

/**

37

* Gets the value at path of object. If the resolved value is a function it's invoked

38

* @param {Object} object - The object to query

39

* @param {Array|string} path - The path of the property to get

40

* @param {...*} args - The arguments to invoke the function with

41

* @returns {*} Returns the resolved value

42

*/

43

function result(object, path, ...args);

44

```

45

46

### Property Modification

47

48

Functions for setting, updating, and removing object properties.

49

50

```javascript { .api }

51

/**

52

* Sets the value at path of object

53

* @param {Object} object - The object to modify

54

* @param {Array|string} path - The path of the property to set

55

* @param {*} value - The value to set

56

* @returns {Object} Returns object

57

*/

58

function set(object, path, value);

59

60

/**

61

* Like set but accepts customizer which is invoked to produce the objects of path

62

* @param {Object} object - The object to modify

63

* @param {Array|string} path - The path of the property to set

64

* @param {*} value - The value to set

65

* @param {Function} customizer - The function to customize assigned values

66

* @returns {Object} Returns object

67

*/

68

function setWith(object, path, value, customizer);

69

70

/**

71

* Removes the property at path of object

72

* @param {Object} object - The object to modify

73

* @param {Array|string} path - The path of the property to unset

74

* @returns {boolean} Returns true if the property is deleted, else false

75

*/

76

function unset(object, path);

77

78

/**

79

* Sets the value at path of object to the result of updater

80

* @param {Object} object - The object to modify

81

* @param {Array|string} path - The path of the property to update

82

* @param {Function} updater - The function to produce the updated value

83

* @returns {Object} Returns object

84

*/

85

function update(object, path, updater);

86

87

/**

88

* Like update but accepts customizer which is invoked to produce the objects of path

89

* @param {Object} object - The object to modify

90

* @param {Array|string} path - The path of the property to update

91

* @param {Function} updater - The function to produce the updated value

92

* @param {Function} customizer - The function to customize assigned values

93

* @returns {Object} Returns object

94

*/

95

function updateWith(object, path, updater, customizer);

96

```

97

98

### Object Keys and Values

99

100

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

101

102

```javascript { .api }

103

/**

104

* Creates an array of the own enumerable property names of object

105

* @param {Object} object - The object to query

106

* @returns {Array} Returns the array of property names

107

*/

108

function keys(object);

109

110

/**

111

* Creates an array of the own and inherited enumerable property names of object

112

* @param {Object} object - The object to query

113

* @returns {Array} Returns the array of property names

114

*/

115

function keysIn(object);

116

117

/**

118

* Creates an array of the own enumerable string keyed property values of object

119

* @param {Object} object - The object to query

120

* @returns {Array} Returns the array of property values

121

*/

122

function values(object);

123

124

/**

125

* Creates an array of the own and inherited enumerable string keyed property values of object

126

* @param {Object} object - The object to query

127

* @returns {Array} Returns the array of property values

128

*/

129

function valuesIn(object);

130

131

/**

132

* Creates an array of own enumerable string keyed-value pairs for object

133

* @param {Object} object - The object to query

134

* @returns {Array} Returns the key-value pairs

135

*/

136

function toPairs(object);

137

138

/**

139

* Creates an array of own and inherited enumerable string keyed-value pairs for object

140

* @param {Object} object - The object to query

141

* @returns {Array} Returns the key-value pairs

142

*/

143

function toPairsIn(object);

144

145

/**

146

* Alias for toPairs

147

* @param {Object} object - The object to query

148

* @returns {Array} Returns the key-value pairs

149

*/

150

function entries(object);

151

152

/**

153

* Alias for toPairsIn

154

* @param {Object} object - The object to query

155

* @returns {Array} Returns the key-value pairs

156

*/

157

function entriesIn(object);

158

```

159

160

### Object Assignment and Merging

161

162

Functions for copying properties between objects and merging objects.

163

164

```javascript { .api }

165

/**

166

* Assigns own enumerable string keyed properties of source objects to the destination object

167

* @param {Object} object - The destination object

168

* @param {...Object} sources - The source objects

169

* @returns {Object} Returns object

170

*/

171

function assign(object, ...sources);

172

173

/**

174

* Like assign but iterates over own and inherited source properties

175

* @param {Object} object - The destination object

176

* @param {...Object} sources - The source objects

177

* @returns {Object} Returns object

178

*/

179

function assignIn(object, ...sources);

180

181

/**

182

* Like assign but accepts customizer which is invoked to produce the assigned values

183

* @param {Object} object - The destination object

184

* @param {...Object} sources - The source objects

185

* @param {Function} customizer - The function to customize assigned values

186

* @returns {Object} Returns object

187

*/

188

function assignWith(object, ...sources, customizer);

189

190

/**

191

* Like assignIn but accepts customizer which is invoked to produce the assigned values

192

* @param {Object} object - The destination object

193

* @param {...Object} sources - The source objects

194

* @param {Function} customizer - The function to customize assigned values

195

* @returns {Object} Returns object

196

*/

197

function assignInWith(object, ...sources, customizer);

198

199

/**

200

* Alias for assignIn

201

* @param {Object} object - The destination object

202

* @param {...Object} sources - The source objects

203

* @returns {Object} Returns object

204

*/

205

function extend(object, ...sources);

206

207

/**

208

* Alias for assignInWith

209

* @param {Object} object - The destination object

210

* @param {...Object} sources - The source objects

211

* @param {Function} customizer - The function to customize assigned values

212

* @returns {Object} Returns object

213

*/

214

function extendWith(object, ...sources, customizer);

215

216

/**

217

* Recursively merges own and inherited enumerable string keyed properties of source objects

218

* @param {Object} object - The destination object

219

* @param {...Object} sources - The source objects

220

* @returns {Object} Returns object

221

*/

222

function merge(object, ...sources);

223

224

/**

225

* Like merge but accepts customizer which is invoked to produce the merged values

226

* @param {Object} object - The destination object

227

* @param {...Object} sources - The source objects

228

* @param {Function} customizer - The function to customize assigned values

229

* @returns {Object} Returns object

230

*/

231

function mergeWith(object, ...sources, customizer);

232

```

233

234

### Object Defaults

235

236

Functions for setting default property values.

237

238

```javascript { .api }

239

/**

240

* Assigns own and inherited enumerable string keyed properties of source objects to the destination object for all destination properties that resolve to undefined

241

* @param {Object} object - The destination object

242

* @param {...Object} sources - The source objects

243

* @returns {Object} Returns object

244

*/

245

function defaults(object, ...sources);

246

247

/**

248

* Like defaults but recursively assigns default properties

249

* @param {Object} object - The destination object

250

* @param {...Object} sources - The source objects

251

* @returns {Object} Returns object

252

*/

253

function defaultsDeep(object, ...sources);

254

```

255

256

### Object Property Selection

257

258

Functions for selecting and omitting object properties.

259

260

```javascript { .api }

261

/**

262

* Creates an object composed of the picked object properties

263

* @param {Object} object - The source object

264

* @param {...(string|string[])} paths - The property paths to pick

265

* @returns {Object} Returns the new object

266

*/

267

function pick(object, ...paths);

268

269

/**

270

* Creates an object composed of the object properties predicate returns truthy for

271

* @param {Object} object - The source object

272

* @param {Function} predicate - The function invoked per property

273

* @returns {Object} Returns the new object

274

*/

275

function pickBy(object, predicate);

276

277

/**

278

* Creates an object composed of the own and inherited enumerable property paths of object that are not omitted

279

* @param {Object} object - The source object

280

* @param {...(string|string[])} paths - The property paths to omit

281

* @returns {Object} Returns the new object

282

*/

283

function omit(object, ...paths);

284

285

/**

286

* 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

287

* @param {Object} object - The source object

288

* @param {Function} predicate - The function invoked per property

289

* @returns {Object} Returns the new object

290

*/

291

function omitBy(object, predicate);

292

293

/**

294

* Creates an array of values corresponding to paths of object

295

* @param {Object} object - The object to query

296

* @param {...(string|string[])} paths - The property paths to get

297

* @returns {Array} Returns the array of property values

298

*/

299

function at(object, ...paths);

300

```

301

302

### Object Iteration

303

304

Functions for iterating over object properties.

305

306

```javascript { .api }

307

/**

308

* Iterates over own enumerable string keyed properties of an object and invokes iteratee for each property

309

* @param {Object} object - The object to iterate over

310

* @param {Function} iteratee - The function invoked per iteration

311

* @returns {Object} Returns object

312

*/

313

function forOwn(object, iteratee);

314

315

/**

316

* Like forOwn but iterates over properties in the opposite order

317

* @param {Object} object - The object to iterate over

318

* @param {Function} iteratee - The function invoked per iteration

319

* @returns {Object} Returns object

320

*/

321

function forOwnRight(object, iteratee);

322

323

/**

324

* Iterates over own and inherited enumerable string keyed properties of an object and invokes iteratee for each property

325

* @param {Object} object - The object to iterate over

326

* @param {Function} iteratee - The function invoked per iteration

327

* @returns {Object} Returns object

328

*/

329

function forIn(object, iteratee);

330

331

/**

332

* Like forIn but iterates over properties in the opposite order

333

* @param {Object} object - The object to iterate over

334

* @param {Function} iteratee - The function invoked per iteration

335

* @returns {Object} Returns object

336

*/

337

function forInRight(object, iteratee);

338

```

339

340

### Object Search

341

342

Functions for finding properties within objects.

343

344

```javascript { .api }

345

/**

346

* Returns the key of the first element predicate returns truthy for

347

* @param {Object} object - The object to inspect

348

* @param {Function} predicate - The function invoked per iteration

349

* @returns {string|undefined} Returns the key of the matched element, else undefined

350

*/

351

function findKey(object, predicate);

352

353

/**

354

* Like findKey but iterates over the object's properties in the opposite order

355

* @param {Object} object - The object to inspect

356

* @param {Function} predicate - The function invoked per iteration

357

* @returns {string|undefined} Returns the key of the matched element, else undefined

358

*/

359

function findLastKey(object, predicate);

360

```

361

362

### Object Key/Value Transformation

363

364

Functions for transforming object keys and values.

365

366

```javascript { .api }

367

/**

368

* Creates an object with the same values as object and keys generated by running each own enumerable string keyed property of object thru iteratee

369

* @param {Object} object - The object to iterate over

370

* @param {Function} iteratee - The function invoked per iteration

371

* @returns {Object} Returns the new mapped object

372

*/

373

function mapKeys(object, iteratee);

374

375

/**

376

* Creates an object with the same keys as object and values generated by running each own enumerable string keyed property of object thru iteratee

377

* @param {Object} object - The object to iterate over

378

* @param {Function} iteratee - The function invoked per iteration

379

* @returns {Object} Returns the new mapped object

380

*/

381

function mapValues(object, iteratee);

382

383

/**

384

* An alternative to _.reduce; this method transforms object to a new accumulator object

385

* @param {Array|Object} object - The object to iterate over

386

* @param {Function} iteratee - The function invoked per iteration

387

* @param {*} accumulator - The custom accumulator value

388

* @returns {*} Returns the accumulated value

389

*/

390

function transform(object, iteratee, accumulator);

391

```

392

393

### Object Inversion

394

395

Functions for inverting object key-value relationships.

396

397

```javascript { .api }

398

/**

399

* Creates an object composed of the inverted keys and values of object

400

* @param {Object} object - The object to invert

401

* @returns {Object} Returns the new inverted object

402

*/

403

function invert(object);

404

405

/**

406

* Like invert but the inverted object is generated from the results of running each element of object thru iteratee

407

* @param {Object} object - The object to invert

408

* @param {Function} iteratee - The function invoked per iteration

409

* @returns {Object} Returns the new inverted object

410

*/

411

function invertBy(object, iteratee);

412

```

413

414

### Object Function Properties

415

416

Functions for working with function properties of objects.

417

418

```javascript { .api }

419

/**

420

* Creates an array of function property names from own enumerable properties of object

421

* @param {Object} object - The object to inspect

422

* @returns {Array} Returns the function names

423

*/

424

function functions(object);

425

426

/**

427

* Creates an array of function property names from own and inherited enumerable properties of object

428

* @param {Object} object - The object to inspect

429

* @returns {Array} Returns the function names

430

*/

431

function functionsIn(object);

432

433

/**

434

* Invokes the method at path of object

435

* @param {Object} object - The object to query

436

* @param {Array|string} path - The path of the method to invoke

437

* @param {...*} args - The arguments to invoke the method with

438

* @returns {*} Returns the result of the invoked method

439

*/

440

function invoke(object, path, ...args);

441

```

442

443

### Object Creation

444

445

Functions for creating new objects.

446

447

```javascript { .api }

448

/**

449

* Creates an object that inherits from the prototype object

450

* @param {Object} prototype - The object to inherit from

451

* @param {Object} properties - The properties to assign to the object

452

* @returns {Object} Returns the new object

453

*/

454

function create(prototype, properties);

455

```

456

457

## Usage Examples

458

459

### Property Access and Modification

460

461

```javascript

462

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

463

464

const user = {

465

name: "Alice",

466

profile: {

467

age: 25,

468

settings: {

469

theme: "dark",

470

notifications: true

471

}

472

}

473

};

474

475

// Get nested properties

476

const age = get(user, "profile.age"); // 25

477

const theme = get(user, "profile.settings.theme", "light"); // "dark"

478

const missing = get(user, "profile.bio", "No bio"); // "No bio"

479

480

// Check property existence

481

const hasAge = has(user, "profile.age"); // true

482

const hasBio = has(user, "profile.bio"); // false

483

484

// Set nested properties

485

set(user, "profile.bio", "Software engineer");

486

set(user, "profile.settings.language", "en");

487

488

// Remove properties

489

unset(user, "profile.settings.notifications");

490

```

491

492

### Object Merging and Assignment

493

494

```javascript

495

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

496

497

const target = { a: 1, b: 2 };

498

const source1 = { b: 3, c: 4 };

499

const source2 = { c: 5, d: 6 };

500

501

// Shallow assignment (modifies target)

502

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

503

504

// Deep merging

505

const obj1 = { user: { name: "Alice", age: 25 } };

506

const obj2 = { user: { age: 26, city: "NYC" } };

507

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

508

509

// Set defaults

510

const config = { timeout: 1000 };

511

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

512

513

// Pick and omit properties

514

const data = { name: "Alice", age: 25, password: "secret", email: "alice@example.com" };

515

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

516

const basicInfo = pick(data, ["name", "age"]); // { name: "Alice", age: 25 }

517

```

518

519

### Object Transformation

520

521

```javascript

522

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

523

524

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

525

526

// Transform keys

527

const upperKeys = mapKeys(scores, (value, key) => key.toUpperCase());

528

// { ALICE: 85, BOB: 92, CHARLIE: 78 }

529

530

// Transform values

531

const percentages = mapValues(scores, score => `${score}%`);

532

// { alice: "85%", bob: "92%", charlie: "78%" }

533

534

// Custom transformation

535

const result = transform(

536

scores,

537

(acc, score, name) => {

538

if (score >= 80) {

539

acc.push({ name, score, grade: "A" });

540

}

541

},

542

[]

543

);

544

// [{ name: "alice", score: 85, grade: "A" }, { name: "bob", score: 92, grade: "A" }]

545

546

// Extract keys, values, and pairs

547

const names = keys(scores); // ["alice", "bob", "charlie"]

548

const scoreValues = values(scores); // [85, 92, 78]

549

const pairs = toPairs(scores); // [["alice", 85], ["bob", 92], ["charlie", 78]]

550

```

551

552

### Advanced Object Operations

553

554

```javascript

555

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

556

557

const users = {

558

alice: { age: 25, active: true },

559

bob: { age: 30, active: false },

560

charlie: { age: 35, active: true }

561

};

562

563

// Find key by predicate

564

const firstActive = findKey(users, { active: true }); // "alice"

565

const over30 = findKey(users, user => user.age > 30); // "charlie"

566

567

// Invert object

568

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

569

570

// Work with function properties

571

const calculator = {

572

add: (a, b) => a + b,

573

multiply: (a, b) => a * b,

574

name: "Calculator"

575

};

576

577

const methods = functions(calculator); // ["add", "multiply"]

578

const result = invoke(calculator, "add", 5, 3); // 8

579

```