# object-line-finder

> Search for line number using an object's key

Latest version **1.0.2** (published 2021-03-12) · ISC license · 0 weekly downloads

## Install

```sh
npm install object-line-finder
pnpm add object-line-finder
yarn add object-line-finder
bun add object-line-finder
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2021-03-12 |
| First published | 2021-03-12 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | GlennChia |
| Maintainers | glennchia |
| Keywords | search, object, line |

## Links

- npm: https://www.npmjs.com/package/object-line-finder
- Repository: https://github.com/GlennChia/object-line-finder
- Homepage: https://github.com/GlennChia/object-line-finder#readme
- Issues: https://github.com/GlennChia/object-line-finder/issues
- npm.io page: https://npm.io/package/object-line-finder

## Alternatives

- [localforage](https://npm.io/package/localforage.md) — 6.2M weekly downloads
- [localforage-observable](https://npm.io/package/localforage-observable.md) — 30.8K weekly downloads
- [@y/y](https://npm.io/package/@y/y.md) — 30.1K weekly downloads
- [@metaobjectsdev/render](https://npm.io/package/@metaobjectsdev/render.md) — 3.5K weekly downloads
- [@ledgerhq/coin-algorand](https://npm.io/package/@ledgerhq/coin-algorand.md) — 1.1K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2021-03-12
- 1.0.1 — 2021-03-12

## README

# object-line-finder

Search for line number using an object's key. Object's keys must be strings and not numbers.

## Table of Contents:

* [Getting Started](#Gettingstarted)
* [Additional information](#additional)
* [Contributing](#Contributing)

## Getting Started <a name="Gettingstarted"></a>

## How To Install

Run:

```bash
npm i --save object-line-finder
```

Then:

```javascript
const objectLineFinder = require("object-line-finder");

const example = 
{
  "firstName": "user",
  "lastName": "a",
  "age": 50
}

console.log(objectLineFinder(example, "age")); // [4]
```

# Additional information <a name="additional"></a>

This [Stackoverflow link](https://stackoverflow.com/questions/280713/elements-order-in-a-for-in-loop) talks about how elements of an object are looped in the order they are declared if all the keys are strings. However, keys that are numbers are always first.

Jest somehow adds an additional `default` key that maps to the entire object. This causes the code to break. A temporary fix is to exclude the default key when doing the checks.

```typescript
if (key === 'default') { break; }
```

# Contributing <a name="Contributing"></a>

We welcome community contributions and pull requests.

The repo uses TypeScript. To compile, run:

```bash
npm run start
```

---
_Source: https://npm.io/package/object-line-finder · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
