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