README.md (2220B)
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 # isString 22 23 > Test if a value is a string. 24 25 <section class="usage"> 26 27 ## Usage 28 29 ```javascript 30 var isString = require( '@stdlib/assert/is-string' ); 31 ``` 32 33 #### isString( value ) 34 35 Tests if a value is a `string`. 36 37 <!-- eslint-disable no-new-wrappers --> 38 39 ```javascript 40 var bool = isString( 'beep' ); 41 // returns true 42 43 bool = isString( new String( 'beep' ) ); 44 // returns true 45 ``` 46 47 #### isString.isPrimitive( value ) 48 49 Tests if a `value` is a primitive `string`. 50 51 <!-- eslint-disable no-new-wrappers --> 52 53 ```javascript 54 var bool = isString.isPrimitive( 'beep' ); 55 // returns true 56 57 bool = isString.isPrimitive( new String( 'boop' ) ); 58 // returns false 59 ``` 60 61 #### isString.isObject( value ) 62 63 Tests if a `value` is a `String` object. 64 65 <!-- eslint-disable no-new-wrappers --> 66 67 ```javascript 68 var bool = isString.isObject( 'beep' ); 69 // returns false 70 71 bool = isString.isObject( new String( 'boop' ) ); 72 // returns true 73 ``` 74 75 </section> 76 77 <!-- /.usage --> 78 79 <section class="examples"> 80 81 ## Examples 82 83 <!-- eslint-disable no-new-wrappers, no-restricted-syntax, no-empty-function --> 84 85 <!-- eslint no-undef: "error" --> 86 87 ```javascript 88 var isString = require( '@stdlib/assert/is-string' ); 89 90 var bool = isString( 'beep' ); 91 // returns true 92 93 bool = isString( new String( 'beep' ) ); 94 // returns true 95 96 bool = isString( 5 ); 97 // returns false 98 99 bool = isString( null ); 100 // returns false 101 102 bool = isString( void 0 ); 103 // returns false 104 105 bool = isString( {} ); 106 // returns false 107 108 bool = isString( [] ); 109 // returns false 110 111 bool = isString( function foo() {} ); 112 // returns false 113 ``` 114 115 </section> 116 117 <!-- /.examples --> 118 119 <section class="links"> 120 121 </section> 122 123 <!-- /.links -->