Package Exports
- filename-to-module-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 (filename-to-module-name) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
filename-to-module-name
Returns the shortest module name for the given filename.
Here is a pseudocode, effectively the inverse of require.resolve algorithm used by Node:
1. If X is a directory,
a. return basename(X)
b. STOP
2. Let Y be X with ".js", ".json" or ".node" removed
3. If exists(Y), return basename(X). STOP
4. For E in [".js", ".json", ".node"],
a. If X ends with E, return basename(Y). STOP
b. If exists(Y + E), return basename(X). STOP
5. Return basename(X)
Example
var moduleName = require('filename-to-module-name');
moduleName('./index.js');
//=> "index"
API
filenameToModuleName(filename)
Returns the module name. filename
should be a name of an existing file or directory.
Install
npm install filename-to-module-name
License
MIT