Socket
Socket
Sign inDemoInstall

position-in-file

Package Overview
Dependencies
6
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    position-in-file

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


Version published
Maintainers
1
Install size
225 kB
Created

Readme

Source

position-in-file

A node.js util to find element position on a file of a folder.

An asynchronous version of position-in-file is available : position-in-file-async.

How to use :

Install position-in-file via npm :

npm install --save position-in-file

Use it :

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 :

	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

Keywords

FAQs

Last updated on 15 Jun 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc