README.md (2263B)
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 # isHexString 22 23 > Test whether a string contains only hexadecimal digits. 24 25 <section class="usage"> 26 27 ## Usage 28 29 ```javascript 30 var isHexString = require( '@stdlib/assert/is-hex-string' ); 31 ``` 32 33 #### isHexString( value ) 34 35 Tests whether a string contains only hexadecimal digits. 36 37 ```javascript 38 var bool = isHexString( '0123456789abcdefABCDEF' ); 39 // returns true 40 ``` 41 42 </section> 43 44 <!-- /.usage --> 45 46 <section class="notes"> 47 48 ## Notes 49 50 - For non-string values, the function returns `false`. 51 - The function does **not** recognize `x` (as in the standard `0x` prefix). 52 53 </section> 54 55 <!-- /.notes --> 56 57 <section class="examples"> 58 59 ## Examples 60 61 <!-- eslint no-undef: "error" --> 62 63 ```javascript 64 var isHexString = require( '@stdlib/assert/is-hex-string' ); 65 66 var out = isHexString( '0123456789abcdefABCDEF' ); 67 // returns true 68 69 out = isHexString( '' ); 70 // returns false 71 72 out = isHexString( '0xffffff' ); 73 // returns false 74 75 out = isHexString( 123 ); 76 // returns false 77 ``` 78 79 </section> 80 81 <!-- /.examples --> 82 83 * * * 84 85 <section class="cli"> 86 87 ## CLI 88 89 <section class="usage"> 90 91 ### Usage 92 93 ```text 94 Usage: is-hex-string [options] [<string>] 95 96 Options: 97 98 -h, --help Print this message. 99 -V, --version Print the package version. 100 ``` 101 102 </section> 103 104 <!-- /.usage --> 105 106 <section class="examples"> 107 108 ### Examples 109 110 ```bash 111 $ is-hex-string 0123456789abcdefABCDEF 112 true 113 ``` 114 115 To use as a [standard stream][standard-streams], 116 117 ```bash 118 $ echo -n '0123456789abcdefABCDEF' | is-hex-string 119 true 120 ``` 121 122 </section> 123 124 <!-- /.examples --> 125 126 </section> 127 128 <!-- /.cli --> 129 130 <section class="links"> 131 132 [standard-streams]: https://en.wikipedia.org/wiki/Standard_streams 133 134 </section> 135 136 <!-- /.links -->