README.md (2892B)
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 # isAnagram 22 23 > Test if a value is an [anagram][anagram]. 24 25 <section class="usage"> 26 27 ## Usage 28 29 ```javascript 30 var isAnagram = require( '@stdlib/assert/is-anagram' ); 31 ``` 32 33 #### isAnagram( str, value ) 34 35 Tests if a `value` is an [anagram][anagram]. 36 37 ```javascript 38 var str = 'I am a weakish speller'; 39 var value = 'William Shakespeare'; 40 41 var bool = isAnagram( str, value ); 42 // returns true 43 ``` 44 45 </section> 46 47 <!-- /.usage --> 48 49 <section class="notes"> 50 51 ## Notes 52 53 - The function does **not** address the presence of [diacritics][diacritics]. 54 - Only **alphanumeric** characters are considered. 55 - Capitalization is **ignored**. 56 - If provided a non-string for the first `argument`, the function throws an `Error`. 57 - If provided a non-string for the second `argument`, the function returns `false`. 58 59 </section> 60 61 <!-- /.notes --> 62 63 <section class="examples"> 64 65 ## Examples 66 67 <!-- eslint no-undef: "error" --> 68 69 ```javascript 70 var isAnagram = require( '@stdlib/assert/is-anagram' ); 71 72 var bool = isAnagram( 'I am a weakish speller', 'William Shakespeare' ); 73 // returns true 74 75 bool = isAnagram( 'bat', 'tab' ); 76 // returns true 77 78 bool = isAnagram( 'bat', 'TAB' ); 79 // returns true 80 81 bool = isAnagram( 'bat', 't a b' ); 82 // returns true 83 84 bool = isAnagram( 'bat 321', 'tab 123' ); 85 // returns true 86 87 bool = isAnagram( 'bat', 'tabba' ); 88 // returns false 89 90 bool = isAnagram( 'bat', 5 ); 91 // returns false 92 93 bool = isAnagram( '123', 321 ); 94 // returns false 95 ``` 96 97 </section> 98 99 <!-- /.examples --> 100 101 * * * 102 103 <section class="cli"> 104 105 ## CLI 106 107 <section class="usage"> 108 109 ### Usage 110 111 ```text 112 Usage: is-anagram [options] [<string>] --str=<string> 113 114 Options: 115 116 -h, --help Print this message. 117 -V, --version Print the package version. 118 --str string Comparison string. 119 ``` 120 121 </section> 122 123 <!-- /.usage --> 124 125 <section class="examples"> 126 127 ### Examples 128 129 ```bash 130 $ is-anagram baz --str=zab 131 true 132 ``` 133 134 To use as a [standard stream][standard-streams], 135 136 ```bash 137 $ echo -n 'tab\nbaz' | is-anagram --str=bat 138 true 139 false 140 ``` 141 142 </section> 143 144 <!-- /.examples --> 145 146 </section> 147 148 <!-- /.cli --> 149 150 <section class="links"> 151 152 [anagram]: http://en.wikipedia.org/wiki/Anagram 153 154 [diacritics]: http://en.wikipedia.org/wiki/Diacritic 155 156 [standard-streams]: https://en.wikipedia.org/wiki/Standard_streams 157 158 </section> 159 160 <!-- /.links -->