require-package-name

2018-10-12 admin

require-package-name是什么

什么是require-package-name,gets the package name for a require statement

require-package-name使用教程帮助文档

require-package-name

stable

Gets the base package name for a module path in a require statement. Assumes the path is not relative.

var name = require('require-package-name')

//get the module name for a require path
name('events')                  => 'events'
name('events/')                 => 'events'
name('events/index.js')         => 'events'
name('@username/button/a.js')   => '@username/button'
name('@username//foo/a.js')     => '@username/foo'

//or, get the base name excluding any scope
name.base('@username/button/a.js')   => 'button'
name.base('@username//foo/a.js')     => 'foo'

Usage

NPM

name = packageName(str)

Gets the name of a module for a require string like 'xtend' from 'xtend/mutable.js'.

base = packageName.base(str)

Gets the base name of a module. This is the same as above, except it excludes scoped usernames.

License

MIT, see LICENSE.md for details.

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

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

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

文章标题:require-package-name

回到顶部