-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3b02aca
commit 704c3a8
Showing
17 changed files
with
1,343 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ Amit Jimiwal <[email protected]> | |
Athan Reines <[email protected]> | ||
Brendan Graetz <[email protected]> | ||
Bruno Fenzl <[email protected]> | ||
Chinmay J <[email protected]> | ||
Christopher Dambamuromo <[email protected]> | ||
Dan Rose <[email protected]> | ||
Daniel Killenberger <[email protected]> | ||
|
@@ -36,6 +37,7 @@ Ognjen Jevremović <[email protected]> | |
Philipp Burckhardt <[email protected]> | ||
Prajwal Kulkarni <[email protected]> | ||
Pranav Goswami <[email protected]> | ||
Praneki <[email protected]> | ||
Pratik <[email protected]> | ||
Ricky Reusser <[email protected]> | ||
Robert Gislason <[email protected]> | ||
|
@@ -44,6 +46,7 @@ Rutam <[email protected]> | |
Ryan Seal <[email protected]> | ||
Seyyed Parsa Neshaei <[email protected]> | ||
Shraddheya Shendre <[email protected]> | ||
Shubham <[email protected]> | ||
Spandan Barve <[email protected]> | ||
Stephannie Jiménez Gacha <[email protected]> | ||
Yernar Yergaziyev <[email protected]> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
<!-- | ||
@license Apache-2.0 | ||
Copyright (c) 2024 The Stdlib Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
|
||
# isWellFormedString | ||
|
||
> Test if a string is well-formed. | ||
<section class="usage"> | ||
|
||
## Usage | ||
|
||
```javascript | ||
var isWellFormedString = require( '@stdlib/assert/is-well-formed-string' ); | ||
``` | ||
|
||
#### isWellFormedString( str ) | ||
|
||
Tests if a `string` is well-formed. | ||
|
||
<!-- eslint-disable no-new-wrappers --> | ||
|
||
```javascript | ||
var bool = isWellFormedString( '' ); | ||
// returns true | ||
|
||
bool = isWellFormedString( new String( '' ) ); | ||
// returns true | ||
|
||
bool = isWellFormedString( '\uDBFF' ); | ||
// returns false | ||
|
||
bool = isWellFormedString( '\uDBFFFF\uDBFF' ); | ||
// returns false | ||
|
||
bool = isWellFormedString( [] ); | ||
// returns false | ||
|
||
bool = isWellFormedString( '-5' ); | ||
// returns true | ||
|
||
bool = isWellFormedString( null ); | ||
// returns false | ||
``` | ||
|
||
#### isWellFormedString.isPrimitive( str ) | ||
|
||
Tests if a `string` is a well-formed `string` primitive. | ||
|
||
<!-- eslint-disable no-new-wrappers --> | ||
|
||
```javascript | ||
var bool = isWellFormedString.isPrimitive( '' ); | ||
// returns true | ||
|
||
bool = isWellFormedString.isPrimitive( new String( '' ) ); | ||
// returns false | ||
``` | ||
|
||
#### isWellFormedString.isObject( str ) | ||
|
||
Tests if a `string` is a well-formed `String` object. | ||
|
||
<!-- eslint-disable no-new-wrappers --> | ||
|
||
```javascript | ||
var bool = isWellFormedString.isObject( '' ); | ||
// returns false | ||
|
||
bool = isWellFormedString.isObject( new String( '' ) ); | ||
// returns true | ||
``` | ||
|
||
</section> | ||
|
||
<!-- /.usage --> | ||
|
||
<section class="examples"> | ||
|
||
## Examples | ||
|
||
<!-- eslint-disable no-new-wrappers --> | ||
|
||
<!-- eslint no-undef: "error" --> | ||
|
||
```javascript | ||
var isWellFormedString = require( '@stdlib/assert/is-well-formed-string' ); | ||
|
||
var bool = isWellFormedString( '' ); | ||
// returns true | ||
|
||
bool = isWellFormedString( new String( '' ) ); | ||
// returns true | ||
|
||
bool = isWellFormedString( '\uDBFF' ); | ||
// returns false | ||
|
||
bool = isWellFormedString( '\uDBFF\uDBFF' ); | ||
// returns false | ||
|
||
bool = isWellFormedString( [] ); | ||
// returns false | ||
|
||
bool = isWellFormedString( '-5' ); | ||
// returns true | ||
|
||
bool = isWellFormedString( null ); | ||
// returns false | ||
``` | ||
|
||
</section> | ||
|
||
<!-- /.examples --> | ||
|
||
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. --> | ||
|
||
<section class="related"> | ||
|
||
|
||
</section> | ||
|
||
<!-- /.related --> | ||
|
||
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> | ||
|
||
<section class="links"> | ||
|
||
<!-- <related-links> --> | ||
|
||
|
||
<!-- </related-links> --> | ||
|
||
</section> | ||
|
||
<!-- /.links --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,220 @@ | ||
/** | ||
* @license Apache-2.0 | ||
* | ||
* Copyright (c) 2024 The Stdlib Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/* eslint-disable no-new-wrappers, no-undefined, no-empty-function */ | ||
|
||
'use strict'; | ||
|
||
// MODULES // | ||
|
||
var bench = require( '@stdlib/bench' ); | ||
var isBoolean = require( './../../is-boolean' ).isPrimitive; | ||
var pkg = require( './../package.json' ).name; | ||
var isWellFormedString = require( './../lib' ); | ||
|
||
|
||
// MAIN // | ||
|
||
bench( pkg+'::primitives', function benchmark( b ) { | ||
var strs; | ||
var bool; | ||
var i; | ||
|
||
strs = [ | ||
'', | ||
'\uDBFF', | ||
'Hello World', | ||
'3.14', | ||
'\uDBFF\uDBFF', | ||
-4.0, | ||
NaN, | ||
true, | ||
false, | ||
null, | ||
undefined | ||
]; | ||
|
||
b.tic(); | ||
for ( i = 0; i < b.iterations; i++ ) { | ||
bool = isWellFormedString( strs[ i % strs.length ] ); | ||
if ( typeof bool !== 'boolean' ) { | ||
b.fail( 'should return a boolean' ); | ||
} | ||
} | ||
b.toc(); | ||
if ( !isBoolean( bool ) ) { | ||
b.fail( 'should return a boolean' ); | ||
} | ||
b.pass( 'benchmark finished' ); | ||
b.end(); | ||
}); | ||
|
||
bench( pkg+'::objects', function benchmark( b ) { | ||
var strs; | ||
var bool; | ||
var i; | ||
|
||
strs = [ | ||
[], | ||
{}, | ||
function noop() {}, | ||
new String( '' ), | ||
new String( '\uDBFF' ), | ||
new String( '\uDBFFFF\uDBFF' ) | ||
]; | ||
|
||
b.tic(); | ||
for ( i = 0; i < b.iterations; i++ ) { | ||
bool = isWellFormedString( strs[ i % strs.length ] ); | ||
if ( typeof bool !== 'boolean' ) { | ||
b.fail( 'should return a boolean' ); | ||
} | ||
} | ||
b.toc(); | ||
if ( !isBoolean( bool ) ) { | ||
b.fail( 'should return a boolean' ); | ||
} | ||
b.pass( 'benchmark finished' ); | ||
b.end(); | ||
}); | ||
|
||
bench( pkg+'::primitives:isPrimitive', function benchmark( b ) { | ||
var strs; | ||
var bool; | ||
var i; | ||
|
||
strs = [ | ||
'', | ||
'\uDBFF', | ||
'Hello World', | ||
'3.14', | ||
'\uDBFF\uDBFF', | ||
-4.0, | ||
NaN, | ||
true, | ||
false, | ||
null, | ||
undefined | ||
]; | ||
|
||
b.tic(); | ||
for ( i = 0; i < b.iterations; i++ ) { | ||
bool = isWellFormedString.isPrimitive( strs[ i % strs.length ] ); | ||
if ( typeof bool !== 'boolean' ) { | ||
b.fail( 'should return a boolean' ); | ||
} | ||
} | ||
b.toc(); | ||
if ( !isBoolean( bool ) ) { | ||
b.fail( 'should return a boolean' ); | ||
} | ||
b.pass( 'benchmark finished' ); | ||
b.end(); | ||
}); | ||
|
||
bench( pkg+'::objects:isPrimitive', function benchmark( b ) { | ||
var strs; | ||
var bool; | ||
var i; | ||
|
||
strs = [ | ||
[], | ||
{}, | ||
function noop() {}, | ||
new String( '' ), | ||
new String( '\uDBFF' ), | ||
new String( '\uDBFFFF\uDBFF' ) | ||
]; | ||
|
||
b.tic(); | ||
for ( i = 0; i < b.iterations; i++ ) { | ||
bool = isWellFormedString.isPrimitive( strs[ i % strs.length ] ); | ||
if ( typeof bool !== 'boolean' ) { | ||
b.fail( 'should return a boolean' ); | ||
} | ||
} | ||
b.toc(); | ||
if ( !isBoolean( bool ) ) { | ||
b.fail( 'should return a boolean' ); | ||
} | ||
b.pass( 'benchmark finished' ); | ||
b.end(); | ||
}); | ||
|
||
bench( pkg+'::primitives:isObject', function benchmark( b ) { | ||
var strs; | ||
var bool; | ||
var i; | ||
|
||
strs = [ | ||
'', | ||
'\uDBFF', | ||
'Hello World', | ||
'3.14', | ||
'\uDBFF\uDBFF', | ||
-4.0, | ||
NaN, | ||
true, | ||
false, | ||
null, | ||
undefined | ||
]; | ||
|
||
b.tic(); | ||
for ( i = 0; i < b.iterations; i++ ) { | ||
bool = isWellFormedString.isObject( strs[ i % strs.length ] ); | ||
if ( typeof bool !== 'boolean' ) { | ||
b.fail( 'should return a boolean' ); | ||
} | ||
} | ||
b.toc(); | ||
if ( !isBoolean( bool ) ) { | ||
b.fail( 'should return a boolean' ); | ||
} | ||
b.pass( 'benchmark finished' ); | ||
b.end(); | ||
}); | ||
|
||
bench( pkg+'::objects:isObject', function benchmark( b ) { | ||
var strs; | ||
var bool; | ||
var i; | ||
|
||
strs = [ | ||
[], | ||
{}, | ||
function noop() {}, | ||
new String( '' ), | ||
new String( '\uDBFF' ), | ||
new String( '\uDBFFFF\uDBFF' ) | ||
]; | ||
|
||
b.tic(); | ||
for ( i = 0; i < b.iterations; i++ ) { | ||
bool = isWellFormedString.isObject( strs[ i % strs.length ] ); | ||
if ( typeof bool !== 'boolean' ) { | ||
b.fail( 'should return a boolean' ); | ||
} | ||
} | ||
b.toc(); | ||
if ( !isBoolean( bool ) ) { | ||
b.fail( 'should return a boolean' ); | ||
} | ||
b.pass( 'benchmark finished' ); | ||
b.end(); | ||
}); |
Oops, something went wrong.