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