time-to-botec

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

README.md (4851B)


      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 # UNC Path
     22 
     23 > [Regular expression][regexp] to parse a [UNC][unc] path.
     24 
     25 <section class="usage">
     26 
     27 ## Usage
     28 
     29 ```javascript
     30 var reUncPath = require( '@stdlib/regexp/unc-path' );
     31 ```
     32 
     33 #### reUncPath()
     34 
     35 Return a [regular expression][regexp] to parse a [UNC][unc] path. 
     36 
     37 ```javascript
     38 var RE_UNC_PATH = reUncPath();
     39 var parts = RE_UNC_PATH.exec( '\\\\server\\share\\foo\\bar\\baz:a:b' );
     40 /* returns
     41     [
     42         '\\\\server\\share\\foo\\bar\\baz:a:b',
     43         'server',                                // host name
     44         'share',                                 // share name
     45         '\\foo\\bar\\baz:a:b',                   // object name
     46         '\\foo\\bar',                            // path name
     47         'baz:a:b',                               // file name
     48         'a',                                     // stream name
     49         'b',                                     // stream type
     50         'index': 0,
     51         'input': '\\\\server\\share\\foo\\bar\\baz:a:b'
     52     ]
     53 */
     54 
     55 parts = RE_UNC_PATH.exec( '\\\\server\\share' );
     56 /* returns
     57     [
     58         '\\\\server\\share',
     59         'server',                                // host name
     60         'share',                                 // share name
     61         '',                                      // object name
     62         undefined,                               // path name
     63         undefined,                               // file name
     64         undefined,                               // stream name
     65         undefined,                               // stream type
     66         'index': 0,
     67         'input': '\\\\server\\share'
     68     ]
     69 */
     70 ```
     71 
     72 #### reUncPath.REGEXP
     73 
     74 [Regular expression][regexp] to parse a [UNC][unc] path. 
     75 
     76 ```javascript
     77 var parts = reUncPath.REGEXP.exec( '\\\\server\\share\\foo\\bar\\baz' )[ 1 ];
     78 // returns 'server'
     79 ```
     80 
     81 </section>
     82 
     83 <!-- /.usage -->
     84 
     85 <section class="examples">
     86 
     87 ## Examples
     88 
     89 <!-- eslint no-undef: "error" -->
     90 
     91 ```javascript
     92 var reUncPath = require( '@stdlib/regexp/unc-path' );
     93 
     94 var RE_UNC_PATH = reUncPath();
     95 var bool;
     96 var path;
     97 
     98 path = '\\\\server\\share\\foo\\bar\\baz:a:b';
     99 bool = RE_UNC_PATH.test( path );
    100 // returns true
    101 
    102 path = '\\\\server\\share\\foo\\bar\\baz::b';
    103 bool = RE_UNC_PATH.test( path );
    104 // returns true
    105 
    106 path = '\\\\server\\share\\foo\\bar\\baz:a';
    107 bool = RE_UNC_PATH.test( path );
    108 // returns true
    109 
    110 path = '\\\\server\\share\\foo\\bar\\baz';
    111 bool = RE_UNC_PATH.test( path );
    112 // returns true
    113 
    114 path = '\\\\server\\share\\foo\\bar';
    115 bool = RE_UNC_PATH.test( path );
    116 // returns true
    117 
    118 path = '\\\\server\\share\\foo';
    119 bool = RE_UNC_PATH.test( path );
    120 // returns true
    121 
    122 path = '\\\\server\\share';
    123 bool = RE_UNC_PATH.test( path );
    124 // returns true
    125 
    126 path = '\\\\server\\\\share';
    127 bool = RE_UNC_PATH.test( path );
    128 // returns false
    129 
    130 path = '\\\\\\\\server\\share';
    131 bool = RE_UNC_PATH.test( path );
    132 // returns false
    133 
    134 path = 'beep boop \\\\server\\share';
    135 bool = RE_UNC_PATH.test( path );
    136 // returns false
    137 
    138 path = '\\\\server';
    139 bool = RE_UNC_PATH.test( path );
    140 // returns false
    141 
    142 path = '\\';
    143 bool = RE_UNC_PATH.test( path );
    144 // returns false
    145 
    146 path = '';
    147 bool = RE_UNC_PATH.test( path );
    148 // returns false
    149 
    150 path = '\\\\server\\share\\';
    151 bool = RE_UNC_PATH.test( path );
    152 // returns false
    153 
    154 path = '\\\\server\\share\\foo\\bar\\baz:';
    155 bool = RE_UNC_PATH.test( path );
    156 // returns false
    157 
    158 path = '\\\\server\\share\\foo\\bar\\baz:a:';
    159 bool = RE_UNC_PATH.test( path );
    160 // returns false
    161 
    162 path = '\\\\server\\share\\foo\\bar\\baz::';
    163 bool = RE_UNC_PATH.test( path );
    164 // returns false
    165 
    166 path = '\\\\server\\share\\foo\\bar\\baz:a:b:c';
    167 bool = RE_UNC_PATH.test( path );
    168 // returns false
    169 
    170 path = '\\\\server\\share\\foo\\bar\\';
    171 bool = RE_UNC_PATH.test( path );
    172 // returns false
    173 
    174 path = '//server/share';
    175 bool = RE_UNC_PATH.test( path );
    176 // returns false
    177 
    178 path = '/foo/bar';
    179 bool = RE_UNC_PATH.test( path );
    180 // returns false
    181 
    182 path = 'foo/bar';
    183 bool = RE_UNC_PATH.test( path );
    184 // returns false
    185 
    186 path = './foo/bar';
    187 bool = RE_UNC_PATH.test( path );
    188 // returns false
    189 
    190 path = '/foo/../bar';
    191 bool = RE_UNC_PATH.test( path );
    192 // returns false
    193 ```
    194 
    195 </section>
    196 
    197 <!-- /.examples -->
    198 
    199 <section class="links">
    200 
    201 [regexp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
    202 
    203 [unc]: https://msdn.microsoft.com/en-us/library/gg465305.aspx
    204 
    205 </section>
    206 
    207 <!-- /.links -->