fined

2019-01-13 admin

fined是什么

什么是fined,Find a file given a declaration of locations.

fined使用教程帮助文档

fined

NPM version Downloads Travis Build Status AppVeyor Build Status Coveralls Status Gitter chat

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

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-50896.html

文章标题:fined

相关文章
Uncaught ReferenceError: ReactDOM is not defined
JonesVIvRRimUm提出了一个问题:Uncaught ReferenceError: ReactDOM is not defined,或许与您遇到的问题类似。 回答者Alexander T.给出了该问题的处理方式: ReactDOM...
2018-04-28
DataTables: Uncaught TypeError: Cannot read property 'defaults' of undefined
Ryan Kohn提出了一个问题:DataTables: Uncaught TypeError: Cannot read property ‘defaults’ of undefined,或许与您遇到的问题类似。 回答者Ryan Kohn给...
2018-04-10
Js基础——数据类型之Null和Undefined
原始值就是值本身不可改变,并且没有方法和属性。操作的时候看似操作原始值,其实是操作它的副本。 Null 代表空指针,就是没有对象存在,它不是全局对象的属性。Null type对应唯一的字面量值null Undefined 是全局对象的属性,...
2018-04-21
ReferenceError: module is not defined - Karma/Jasmine configuration with Angular/Laravel app
Raphael Rafatpanah提出了一个问题:ReferenceError: module is not defined - Karma/Jasmine configuration with Angular/Laravel app,或...
2018-04-08
Uncaught TypeError: Cannot read property 'toLowerCase' of undefined
Rory McCrossanRonald提出了一个问题:Uncaught TypeError: Cannot read property ‘toLowerCase’ of undefined,或许与您遇到的问题类似。 回答者Rory McC...
2018-04-24
Cannot read property 'protocol' of undefined
user2901304提出了一个问题:Cannot read property ‘protocol’ of undefined,或许与您遇到的问题类似。 回答者Stewie给出了该问题的处理方式: You’re issuing a malf...
2018-04-13
C3JS - Cannot read property 'category10' of undefined
JJC提出了一个问题:C3JS - Cannot read property ‘category10’ of undefined,或许与您遇到的问题类似。 回答者Arto Bendiken给出了该问题的处理方式: I solved the ...
2018-04-26
【前端工程师手册】null和undefined到底是什么关系?
它们是什么 undefined undefined代表了一个并不存在的值,很多情况都会产生undefined,比如: 没有返回语句的函数运行结束,就会返回undefined 访问数组中不存在的下标和对象不存在的属性 void运算符会返回u...
2018-07-03
回到顶部