Skip to content

Latest commit

 

History

History
28 lines (20 loc) · 691 Bytes

README.md

File metadata and controls

28 lines (20 loc) · 691 Bytes

npm version

@aegenet/belt-obj-first-key

Object first key

💾 Installation

yarn add @aegenet/belt-obj-first-key@^2.0.0
# or
npm i @aegenet/belt-obj-first-key@^2.0.0

📝 Usage

import { objectFirstKey } from '@aegenet/belt-obj-first-key';

objectFirstKey(null); // null;
objectFirstKey(undefined); // null
objectFirstKey({}); // null
objectFirstKey({ id: 1 }); // 'id'
objectFirstKey({ id: 1, code: 'go' }); // 'id'

objectFirstKey({ _privateStuff: true, id: 1, code: 'go' }, key => !key.startsWith('_')); // 'id'