UNPKG

es-toolkit

Version:

A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.

19 lines (14 loc) 564 B
'use strict'; Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); const identity = require('../function/identity.js'); const isObject = require('../predicate/isObject.js'); const iteratee = require('../util/iteratee.js'); function findLastKey(obj, predicate) { if (!isObject.isObject(obj)) { return undefined; } const iteratee$1 = iteratee.iteratee(predicate ?? identity.identity); const keys = Object.keys(obj); return keys.findLast(key => iteratee$1(obj[key], key, obj)); } exports.findLastKey = findLastKey;