rm index and indexof
This commit is contained in:
32
fd.cm
32
fd.cm
@@ -1,15 +1,43 @@
|
||||
var fd = this
|
||||
var wildstar = use('wildstar')
|
||||
|
||||
function last_pos(str, sep) {
|
||||
var last = null
|
||||
replace(str, sep, function(m, pos) {
|
||||
last = pos
|
||||
return m
|
||||
})
|
||||
return last
|
||||
}
|
||||
|
||||
// Helper to join paths
|
||||
function join_paths(base, rel) {
|
||||
base = base.replace(/\/+$/, "")
|
||||
rel = rel.replace(/^\/+/, "")
|
||||
base = replace(base, /\/+$/, "")
|
||||
rel = replace(rel, /^\/+/, "")
|
||||
if (!base) return rel
|
||||
if (!rel) return base
|
||||
return base + "/" + rel
|
||||
}
|
||||
|
||||
fd.join_paths = join_paths
|
||||
fd.basename = function basename(path) {
|
||||
var last = last_pos(path, '/')
|
||||
if (last == null) return path
|
||||
return text(path, last+1)
|
||||
}
|
||||
|
||||
fd.dirname = function dirname(path) {
|
||||
var last = last_pos(path, '/')
|
||||
if (last == null) return ""
|
||||
return text(path,0,last)
|
||||
}
|
||||
|
||||
fd.stem = function stem(path) {
|
||||
var last = last_pos(path, '.')
|
||||
if (last == null) return path
|
||||
return text(path,0,last)
|
||||
}
|
||||
|
||||
fd.globfs = function(globs, dir) {
|
||||
if (dir == null) dir = "."
|
||||
var results = []
|
||||
|
||||
Reference in New Issue
Block a user