time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

README.md (3963B)


      1 <!--
      2 
      3 @license Apache-2.0
      4 
      5 Copyright (c) 2018 The Stdlib Authors.
      6 
      7 Licensed under the Apache License, Version 2.0 (the "License");
      8 you may not use this file except in compliance with the License.
      9 You may obtain a copy of the License at
     10 
     11    http://www.apache.org/licenses/LICENSE-2.0
     12 
     13 Unless required by applicable law or agreed to in writing, software
     14 distributed under the License is distributed on an "AS IS" BASIS,
     15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     16 See the License for the specific language governing permissions and
     17 limitations under the License.
     18 
     19 -->
     20 
     21 # isRelativePath
     22 
     23 > Test if a value is a relative path.
     24 
     25 <section class="intro">
     26 
     27 </section>
     28 
     29 <!-- /.intro -->
     30 
     31 <section class="usage">
     32 
     33 ## Usage
     34 
     35 ```javascript
     36 var isRelativePath = require( '@stdlib/assert/is-relative-path' );
     37 ```
     38 
     39 #### isRelativePath( value )
     40 
     41 Tests if a `value` is a relative path.
     42 
     43 ```javascript
     44 var IS_WINDOWS = require( '@stdlib/assert/is-windows' );
     45 
     46 var bool;
     47 if ( IS_WINDOWS ) {
     48     bool = isRelativePath( 'foo\\bar\\baz' );
     49     // returns true
     50 
     51     bool = isRelativePath( 'C:\\foo\\..\\bar\\baz' );
     52     // returns false
     53 } else {
     54     bool = isRelativePath( './foo/bar/baz' );
     55     // returns true
     56 
     57     bool = isRelativePath( '/foo/../bar/baz' );
     58     // returns false
     59 }
     60 ```
     61 
     62 #### isRelativePath.posix( value )
     63 
     64 Tests if a `value` is a POSIX relative path.
     65 
     66 ```javascript
     67 var bool = isRelativePath.posix( './foo/bar/baz' );
     68 // returns true
     69 
     70 bool = isRelativePath.posix( '/foo/../bar/baz' );
     71 // returns false
     72 ```
     73 
     74 #### isRelativePath.win32( value )
     75 
     76 Tests if a `value` is a Windows relative path.
     77 
     78 ```javascript
     79 var bool = isRelativePath.win32( 'foo\\bar\\baz' );
     80 // returns true
     81 
     82 bool = isRelativePath.win32( 'C:\\foo\\..\\bar\\baz' );
     83 // returns false
     84 ```
     85 
     86 </section>
     87 
     88 <!-- /.usage -->
     89 
     90 <section class="notes">
     91 
     92 ## Notes
     93 
     94 -   `isRelativePath()` is platform-specific. On Windows platforms, the function is equal to `isRelativePath.win32()`. On POSIX platforms, the function is equal to `isRelativePath.posix()`.
     95 
     96 </section>
     97 
     98 <!-- /.notes -->
     99 
    100 <section class="examples">
    101 
    102 ## Examples
    103 
    104 <!-- eslint no-undef: "error" -->
    105 
    106 ```javascript
    107 var isRelativePath = require( '@stdlib/assert/is-relative-path' );
    108 
    109 var bool = isRelativePath.posix( 'foo/' );
    110 // returns true
    111 
    112 bool = isRelativePath.posix( 'foo' );
    113 // returns true
    114 
    115 bool = isRelativePath.posix( '.' );
    116 // returns true
    117 
    118 bool = isRelativePath.posix( '' );
    119 // returns true
    120 
    121 bool = isRelativePath.posix( '/foo/bar/baz' );
    122 // returns false
    123 
    124 bool = isRelativePath.posix( '/foo/..' );
    125 // returns false
    126 
    127 bool = isRelativePath.win32( 'foo\\bar\\baz' );
    128 // returns true
    129 
    130 bool = isRelativePath.win32( 'foo/bar/baz' );
    131 // returns true
    132 
    133 bool = isRelativePath.win32( 'foo/..' );
    134 // returns true
    135 
    136 bool = isRelativePath.win32( '.' );
    137 // returns true
    138 
    139 bool = isRelativePath.win32( '' );
    140 // returns true
    141 
    142 bool = isRelativePath.win32( 'C:\\foo\\bar\\baz' );
    143 // returns false
    144 
    145 bool = isRelativePath.win32( '//server' );
    146 // returns false
    147 
    148 bool = isRelativePath.win32( '\\\\server' );
    149 // returns false
    150 
    151 bool = isRelativePath.win32( 'C:/foo/bar/baz' );
    152 // returns false
    153 
    154 bool = isRelativePath.win32( '/foo/..' );
    155 // returns false
    156 ```
    157 
    158 </section>
    159 
    160 <!-- /.examples -->
    161 
    162 * * *
    163 
    164 <section class="cli">
    165 
    166 ## CLI
    167 
    168 <section class="usage">
    169 
    170 ### Usage
    171 
    172 ```text
    173 Usage: is-relative-path [options] [<path>]
    174 
    175 Options:
    176 
    177   -h,    --help                Print this message.
    178   -V,    --version             Print the package version.
    179          --platform name       Platform: 'win32' or 'posix'.
    180 ```
    181 
    182 </section>
    183 
    184 <!-- /.usage -->
    185 
    186 <section class="examples">
    187 
    188 ### Examples
    189 
    190 ```bash
    191 $ is-relative-path ./foo/bar/baz --platform=posix
    192 true
    193 ```
    194 
    195 To use as a [standard stream][standard-streams],
    196 
    197 ```bash
    198 $ echo -n './docs/repl.txt' | is-relative-path
    199 true
    200 ```
    201 
    202 </section>
    203 
    204 <!-- /.examples -->
    205 
    206 </section>
    207 
    208 <!-- /.cli -->
    209 
    210 <section class="links">
    211 
    212 [standard-streams]: https://en.wikipedia.org/wiki/Standard_streams
    213 
    214 </section>
    215 
    216 <!-- /.links -->