Path Separator

Platform-specific path segment separator.

Usage

var PATH_SEP = require( '@stdlib/constants/string/path-sep' );

PATH_SEP

Platform-specific path segment separator.

var isWindows = require( '@stdlib/assert/is-windows' );

var bool;
if ( isWindows ) {
    bool = ( PATH_SEP === '\\' );
    // returns true
} else {
    bool = ( PATH_SEP === '/' );
    // returns true
}

Examples

var isWindows = require( '@stdlib/assert/is-windows' );
var PATH_SEP = require( '@stdlib/constants/string/path-sep' );

var parts;
var path;

if ( isWindows ) {
    path = 'foo\\bar\\baz';
} else {
    path = 'foo/bar/baz';
}
parts = path.split( PATH_SEP );
console.log( parts );
// => ['foo','bar','baz']