Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including node-name with all npm packages installed. Try it out:

var nodeName = require("node-name")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

node-name v0.1.3

Basic utility methods for transforming and handling file paths.

node-name

Basic utility methods for transforming and handling file paths. As with node.js, the file system is not consulted to check whether paths are valid.

Getting Started

Install the module with: npm install node-name

Require it:

var name = require('node-name');

Test it:

console.log(name.basename('foo/bar/baz.quux'));
// => baz

Methods

name.dir('path/to/transform.txt');
name.file('path/to/transform.txt');
name.filename('path/to/transform.txt');
name.base('path/to/transform.txt');
name.basename('path/to/transform.txt');
name.ext('path/to/transform.txt');

About

After I started paying attention to how the Node.js path module handles and transforms file paths (path.basename, path.extname, etc.), I was surprised at the results. Not that I should have been, but when utilities like this are so easy to use, I sometimes forget that I still need to look at what's happening under the hood.

Currently, this module just makes it a tiny bit more convenient to see how paths are transformed by these utilities. But over time my goal is to build out this library to include more robust utilities.

Contributions and feedback are welcome!

Author

License

Copyright (c) 2013 Jon Schlinkert Licensed under the MIT License (MIT)

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free