JSPM

require-package-name

2.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2421979
  • Score
    100M100P100Q198757F
  • License MIT

gets the package name for a require statement

Package Exports

  • require-package-name

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (require-package-name) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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.