Socket
Socket
Sign inDemoInstall

fined

Package Overview
Dependencies
20
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    fined

Find a file given a declaration of locations.


Version published
Weekly downloads
3M
increased by4.7%
Maintainers
2
Install size
159 kB
Created
Weekly downloads
 

Readme

Source

fined

NPM version Downloads Build Status Coveralls Status

Find a file given a declaration of locations.

Usage

var fined = require('fined');

fined({ path: 'path/to/file', extensions: ['.js', '.json'] });
// => { path: '/absolute/path/to/file.js', extension: '.js' }  (if file exists)
// => null  (if file does not exist)

var opts = {
  name: '.app',
  cwd: '.',
  extensions: {
    rc: 'default-rc-loader',
    '.yml': 'default-yml-loader',
  },
};

fined({ path: '.' }, opts);
// => { path: '/absolute/of/cwd/.app.yml', extension: { '.yml': 'default-yml-loader' } }

fined({ path: '~', extensions: { rc: 'some-special-rc-loader' } }, opts);
// => { path: '/User/home/.apprc', extension: { 'rc': 'some-special-rc-loader' } }

API

fined(pathObj, opts) => object | null

Arguments:
  • pathObj [string | object] : a path setting for finding a file.

  • opts [object] : a plain object supplements pathObj.

    pathObj and opts can have same properties:

    • path [string] : a path string.
    • name [string] : a basename.
    • extensions: [string | array | object] : extensions.
    • cwd: a base directory of path and for finding up.
    • findUp: [boolean] : a flag to find up.
Return:

This function returns a plain object which consists of following properties if a file exists otherwise null.

  • path : an absolute path
  • extension : a string or a plain object of extension.

License

MIT

Keywords

FAQs

Last updated on 31 Oct 2021

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