index.js (1446B)
1 /** 2 * @license Apache-2.0 3 * 4 * Copyright (c) 2018 The Stdlib Authors. 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 'use strict'; 20 21 /** 22 * Platform-specific path segment separator. 23 * 24 * @module @stdlib/constants/path/sep 25 * @type {string} 26 * 27 * @example 28 * var IS_WINDOWS = require( '@stdlib/assert/is-windows' ); 29 * var PATH_SEP = require( '@stdlib/constants/path/sep' ); 30 * 31 * var parts; 32 * if ( IS_WINDOWS ) { 33 * parts = 'foo\\bar\\baz'.split( PATH_SEP ); 34 * // returns ['foo','bar','baz'] 35 * } else { 36 * parts = 'foo/bar/baz'.split( PATH_SEP ); 37 * // returns ['foo','bar','baz'] 38 * } 39 */ 40 41 // MODULES // 42 43 var IS_WINDOWS = require( '@stdlib/assert/is-windows' ); 44 var PATH_SEP_WIN32 = require( './../../../path/sep-win32' ); 45 var PATH_SEP_POSIX = require( './../../../path/sep-posix' ); 46 47 48 // MAIN // 49 50 var PATH_SEP; 51 if ( IS_WINDOWS ) { 52 PATH_SEP = PATH_SEP_WIN32; 53 } else { 54 PATH_SEP = PATH_SEP_POSIX; 55 } 56 57 58 // EXPORTS // 59 60 module.exports = PATH_SEP;