From 85656a26fd7210f6d51712c18800bc9bae99f4e6 Mon Sep 17 00:00:00 2001 From: Chris Wanstrath Date: Sun, 13 Nov 2011 20:13:49 -0800 Subject: [PATCH] add 'path' to stdlib. bad? not in commonjs but in node.js --- src/stdlib/path.coffee | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/stdlib/path.coffee diff --git a/src/stdlib/path.coffee b/src/stdlib/path.coffee new file mode 100644 index 000000000..337b60d6b --- /dev/null +++ b/src/stdlib/path.coffee @@ -0,0 +1,15 @@ +# node.js path module +# http://nodejs.org/docs/v0.6.0/api/path.html + +_ = require 'underscore' + +module.exports = + # Return the last portion of a path. Similar to the Unix basename command. + basename: (filepath) -> + _.last filepath.split '/' + + # Return the extension of the path, from the last '.' to end of string in + # the last portion of the path. If there is no '.' in the last portion of + # the path or the first character of it is '.', then it returns an empty string. + extname: (filepath) -> + _.last filepath.split '.'