Socket
Socket
Sign inDemoInstall

require-package-name

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

require-package-name

gets the package name for a require statement


Version published
Maintainers
1
Weekly downloads
1,300,631
decreased by-25.72%

Weekly downloads

Readme

Source

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.

Keywords

FAQs

Last updated on 07 May 2015

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