Framework

- About
- Guides
- Community
- API
- Code
- Download

# Kanso API Documentation

Index | View on single page

## path

Path functions ported from node.js to work in CouchDB and the browser. This module is used internally by Kanso, although you can use it in your apps too if you find the functions useful.

### join(path, [...])

Joins multiple paths together using '/'. Accepts a arbitrary number of strings as arguments, returning the joined result as a single string.

Returns: String

### normalizeArray(parts, [keepBlanks])

Normalizes a path split into an array, taking care of '..' and '.' parts.

#### Parameters

parts | Array |
keepBlanks | Boolean |

Returns: Array

### normalize(path, [keepBlanks])

Normalize a string path, taking care of '..' and '.' parts.

#### Parameters

path | String |
keepBlanks | Boolean |

Returns: string

### dirname(path)

Return the directory name of a path. Similar to the Unix dirname command.

#### Parameters

path | String |

Returns: String

### basename(path, ext)

Return the last portion of a path. Similar to the Unix basename command.

Example

    path.basename('/foo/bar/baz/asdf/quux.html')
    // returns
    'quux.html'

    path.basename('/foo/bar/baz/asdf/quux.html', '.html')
    // returns
    'quux'

#### Parameters

path | String |
ext | String |

Returns: String

### extname(path)

Return the extension of the path. Everything after the last '.' in the last portion of the path. If there is no '.' in the last portion of the path or the only '.' is the first character, then it returns an empty string.

    path.extname('index.html')
    // returns
    '.html'

    path.extname('index')
    // returns
    ''

#### Parameters

path | String |

Returns: String