time-to-botec

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

README.md (2643B)


      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 # Open URL
     22 
     23 > Open a URL.
     24 
     25 <section class="usage">
     26 
     27 ## Usage
     28 
     29 ```javascript
     30 var openURL = require( '@stdlib/utils/open-url' );
     31 ```
     32 
     33 #### openURL( url )
     34 
     35 Opens a URL in a user's default browser.
     36 
     37 <!-- run-disable -->
     38 
     39 ```javascript
     40 var proc = openURL( 'https://google.com' );
     41 ```
     42 
     43 The returned child process is unreferenced, and, thus, the calling process will not wait for the child process to end before exiting. To try and end the child process, send an appropriate `kill` signal.
     44 
     45 <!-- run-disable -->
     46 
     47 <!-- eslint-disable stdlib/no-redeclare -->
     48 
     49 ```javascript
     50 var proc = openURL( 'https://google.com' );
     51 
     52 function close() {
     53     proc.kill( 'SIGINT' );
     54 }
     55 
     56 setTimeout( close, 1000 );
     57 ```
     58 
     59 ### Web Browser
     60 
     61 In a web browser, `openURL` defers to the [`window.open()`][window-open] method.
     62 
     63 #### openURL( url )
     64 
     65 Opens a URL either in a new tab or window (based on the web browser and/or user preferences), returning a reference to a `window` object.
     66 
     67 <!-- run-disable -->
     68 
     69 ```javascript
     70 var win = openURL( 'https://google.com' );
     71 ```
     72 
     73 </section>
     74 
     75 <!-- /.usage -->
     76 
     77 <section class="examples">
     78 
     79 ## Examples
     80 
     81 <!-- run-disable -->
     82 
     83 <!-- eslint-disable stdlib/no-redeclare -->
     84 
     85 <!-- eslint no-undef: "error" -->
     86 
     87 ```javascript
     88 var openURL = require( '@stdlib/utils/open-url' );
     89 
     90 // Open a URL:
     91 var proc = openURL( 'https://github.com' );
     92 
     93 // After some time, kill the spawned process...
     94 function close() {
     95     proc.kill( 'SIGINT' );
     96 }
     97 
     98 setTimeout( close, 5000 );
     99 ```
    100 
    101 </section>
    102 
    103 <!-- /.examples -->
    104 
    105 * * *
    106 
    107 <section class="cli">
    108 
    109 ## CLI
    110 
    111 <section class="usage">
    112 
    113 ### Usage
    114 
    115 ```text
    116 Usage: open-url [options] <url>
    117 
    118 Options:
    119 
    120   -h,    --help                Print this message.
    121   -V,    --version             Print the package version.
    122 ```
    123 
    124 </section>
    125 
    126 <!-- /.usage -->
    127 
    128 <section class="examples">
    129 
    130 ### Examples
    131 
    132 ```bash
    133 $ open-url https://github.com
    134 <pid>
    135 ```
    136 
    137 </section>
    138 
    139 <!-- /.examples -->
    140 
    141 </section>
    142 
    143 <!-- /.cli -->
    144 
    145 <section class="links">
    146 
    147 [window-open]: https://developer.mozilla.org/en-US/docs/Web/API/Window/open
    148 
    149 </section>
    150 
    151 <!-- /.links -->