# position-in-file

> A node.js util to find element position on a file list

Latest version **1.1.3** (published 2017-06-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install position-in-file
pnpm add position-in-file
yarn add position-in-file
bun add position-in-file
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.3 |
| Published | 2017-06-15 |
| First published | 2017-05-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Arnaud CETOUTE |
| Maintainers | arncet |
| Keywords | position, search, find, file, line, column, node |

## Links

- npm: https://www.npmjs.com/package/position-in-file
- Repository: https://github.com/arncet/position-in-file
- Homepage: https://github.com/arncet/position-in-file#readme
- Issues: https://github.com/arncet/position-in-file/issues
- npm.io page: https://npm.io/package/position-in-file

## Dependencies (1)

- [ext-name](https://npm.io/package/ext-name.md) ^4.0.0

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 1.1.3 (latest) — 2017-06-15
- 1.1.2 — 2017-06-15
- 1.1.1 — 2017-05-14
- 1.1.0 — 2017-05-14
- 1.0.3 — 2017-05-11
- 1.0.2 — 2017-05-10
- 1.0.1 — 2017-05-10
- 1.0.0 — 2017-05-10

## README

# position-in-file
![](https://travis-ci.org/arncet/position-in-file.svg?branch=master)

A [node.js](https://nodejs.org/en/) util to find element position on a file of a folder.

An asynchronous version of `position-in-file` is available : [position-in-file-async](https://github.com/arncet/position-in-file-async).

## How to use :

Install `position-in-file` via npm :

```
npm install --save position-in-file
```

Use it : 

```javascript
const positionInFile = require('position-in-file')

//positionInFile(needle, haystack, options)

//Exemple :
positionInFile('element-to-look-for', 'where-to-search', {deep: false, ...})

//Result : 
[
	{file: 'finded-in-this-file.ext', lines: {2: [5]}}, //Line 2 column 5
	{file: 'finded-here.too.ext', lines: {1: [2, 19]}}, //Line 1 column 5, line 1 column 19
	...
]
```

If node doest display deep object you can use [util.inspect](https://nodejs.org/api/util.html#util_util_inspect_object_options) : 

```javascript
	const inspect = require('util').inspect

	const result = positionInFile('element-to-look-for', 'where-to-search', {deep: false, ...})
	console.log(inspect(result, {showHidden: false, depth: null}))
```

## Parameters

* **`needle`** *(String || RegExp)* : The element to search, can be a *string* or a *regular expression*.
* **`haystack`** *(String)* : The path where the research will be executed, it can be a file or folder path. If *haystack* is not defined the research will be excecuted in the current folder.
* **`options`** *(Object)* : Some aditionnals options :
	* **`deep`** *(Boolean)* : If the research will be apply on deep folder. Default : ```true```.
	* **`ignore `** : *(Array)* An array to define the file/filter to ignore. Default : empty array.
	* **`fullPathRequired `** *(Boolean)* : If full path need to be specified on ```option.ignore``` or just the file name. Default : ```true```.
	* **`gitIgnore `** *(Boolean)* : If .gitIgnore's file/folder need to be ignored. Default : ```true```.
	
## License :

MIT

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