From 3f86dfbb8ad48625522bf6a01b121983039b0daf Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Mon, 26 Feb 2024 10:34:50 +0530 Subject: [PATCH 01/23] feat: added string/is-well-formed-string This commit adds the string/is-well-formed-string module for checking well-formed-strings. --- .../string/is-well-formed-string/README.md | 139 +++++++++++ .../benchmark/benchmark.js | 220 ++++++++++++++++++ .../is-well-formed-string/docs/repl.txt | 76 ++++++ .../docs/types/index.d.ts | 125 ++++++++++ .../is-well-formed-string/docs/types/test.ts | 61 +++++ .../is-well-formed-string/examples/index.js | 44 ++++ .../string/is-well-formed-string/lib/index.js | 81 +++++++ .../is-well-formed-string/lib/iswellformed.js | 79 +++++++ .../string/is-well-formed-string/lib/main.js | 62 +++++ .../is-well-formed-string/lib/object.js | 52 +++++ .../is-well-formed-string/lib/primitive.js | 51 ++++ .../string/is-well-formed-string/package.json | 71 ++++++ .../string/is-well-formed-string/test/test.js | 43 ++++ .../is-well-formed-string/test/test.main.js | 61 +++++ .../is-well-formed-string/test/test.object.js | 69 ++++++ .../test/test.primitive.js | 66 ++++++ 16 files changed, 1300 insertions(+) create mode 100644 lib/node_modules/@stdlib/string/is-well-formed-string/README.md create mode 100644 lib/node_modules/@stdlib/string/is-well-formed-string/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/string/is-well-formed-string/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/string/is-well-formed-string/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/string/is-well-formed-string/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/string/is-well-formed-string/examples/index.js create mode 100644 lib/node_modules/@stdlib/string/is-well-formed-string/lib/index.js create mode 100644 lib/node_modules/@stdlib/string/is-well-formed-string/lib/iswellformed.js create mode 100644 lib/node_modules/@stdlib/string/is-well-formed-string/lib/main.js create mode 100644 lib/node_modules/@stdlib/string/is-well-formed-string/lib/object.js create mode 100644 lib/node_modules/@stdlib/string/is-well-formed-string/lib/primitive.js create mode 100644 lib/node_modules/@stdlib/string/is-well-formed-string/package.json create mode 100644 lib/node_modules/@stdlib/string/is-well-formed-string/test/test.js create mode 100644 lib/node_modules/@stdlib/string/is-well-formed-string/test/test.main.js create mode 100644 lib/node_modules/@stdlib/string/is-well-formed-string/test/test.object.js create mode 100644 lib/node_modules/@stdlib/string/is-well-formed-string/test/test.primitive.js diff --git a/lib/node_modules/@stdlib/string/is-well-formed-string/README.md b/lib/node_modules/@stdlib/string/is-well-formed-string/README.md new file mode 100644 index 000000000000..8e39e4f129fc --- /dev/null +++ b/lib/node_modules/@stdlib/string/is-well-formed-string/README.md @@ -0,0 +1,139 @@ + + +# isWellFormedString + +> Test if a string is well-formed. + +
+ +## Usage + +```javascript +var isWellFormedString = require( '@stdlib/string/is-well-formed-string' ); +``` + +#### isWellFormedString( str ) + +Tests if a `string` is well-formed. + + + +```javascript +var bool = isWellFormedString( '' ); +// returns true +bool = isWellFormedString( new String( '' ) ); +// returns true +bool = isWellFormedString( '\uD800\uD800' ); +// returns false +bool = isWellFormedString( '\uDBFF' ); +// returns false +bool = isWellFormedString( null ); +// returns false +``` + +#### isWellFormedString.isPrimitive( str ) + +Tests if a `string` is a well-formed `string` primitive. + + + +```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. + + + +```javascript +var bool = isWellFormedString.isObject( '' ); +// returns false +bool = isWellFormedString.isObject( new String( '' ) ); +// returns true +``` + +
+ + + +
+ +## Examples + + + + + +```javascript +var isWellFormedString = require( '@stdlib/string/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 +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/string/is-well-formed-string/benchmark/benchmark.js b/lib/node_modules/@stdlib/string/is-well-formed-string/benchmark/benchmark.js new file mode 100644 index 000000000000..b7624fa9d870 --- /dev/null +++ b/lib/node_modules/@stdlib/string/is-well-formed-string/benchmark/benchmark.js @@ -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( '@stdlib/assert/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(); +}); diff --git a/lib/node_modules/@stdlib/string/is-well-formed-string/docs/repl.txt b/lib/node_modules/@stdlib/string/is-well-formed-string/docs/repl.txt new file mode 100644 index 000000000000..48e489345ed6 --- /dev/null +++ b/lib/node_modules/@stdlib/string/is-well-formed-string/docs/repl.txt @@ -0,0 +1,76 @@ + +{{alias}}( str ) + Tests if a string is well-formed. + + Parameters + ---------- + str: any + String to test. + + Returns + ------- + bool: boolean + Boolean indicating whether str is well-formed. + + Examples + -------- + > var bool = {{alias}}( '\uDBFFFFG' ) + false + + > bool = {{alias}}( new String( '0xDFFFFF' ) ) + false + + > bool = {{alias}}( '\uDBFF' ) + false + + > bool = {{alias}}( '\uDBFF\uDBFF' ) + false + + > bool = {{alias}}( null ) + false + + +{{alias}}.isPrimitive( str ) + Tests if a string is a well-formed string primitive. + + Parameters + ---------- + str: any + String to test. + + Returns + ------- + bool: boolean + Boolean indicating whether str is a well-formed string primitive. + + Examples + -------- + > var bool = {{alias}}.isPrimitive( '' ) + true + > bool = {{alias}}.isPrimitive( new String( '' ) ) + false + + +{{alias}}.isObject( str ) + Tests if a string is a well-formed string object. + + Parameters + ---------- + str: any + String to test. + + Returns + ------- + bool: boolean + Boolean indicating whether str is a well-formed string object. + + Examples + -------- + > var bool = {{alias}}.isObject( '' ) + false + > bool = {{alias}}.isObject( new String( '0xDFFF' ) ) + false + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/string/is-well-formed-string/docs/types/index.d.ts b/lib/node_modules/@stdlib/string/is-well-formed-string/docs/types/index.d.ts new file mode 100644 index 000000000000..da69bb82b320 --- /dev/null +++ b/lib/node_modules/@stdlib/string/is-well-formed-string/docs/types/index.d.ts @@ -0,0 +1,125 @@ +/* +* @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. +*/ + +// TypeScript Version: 4.1 + +/** +* Interface defining `isWellFormedString` with methods for testing for primitives and objects, respectively. +*/ +interface isWellFormedString { + /** + * Tests if a string is well-formed. + * + * @param str - string to test + * @returns boolean indicating whether string is well-formed + * + * @example + * var bool = isWellFormedString( '' ); + * // returns true + * + * @example + * var bool = isWellFormedString( new String( '' ) ); + * // returns true + * + * @example + * var bool = isWellFormedString( '\uDBFF' ); + * // returns false + * + * @example + * var bool = isWellFormedString( '\uDBFF\uDBFF' ); + * // returns false + * + * @example + * var bool = isWellFormedString( null ); + * // returns false + */ + ( str: any ): str is string | String; + + /** + * Tests if a string is a well-formed string primitive. + * + * @param str - string to test + * @returns boolean indicating if a string is a well-formed string primitive. + * + * @example + * var bool = isWellFormedString.isPrimitive( '' ); + * // returns true + * + * @example + * var bool = isWellFormedString.isPrimitive( new String( '' ) ); + * // returns false + */ + isPrimitive( str: any ): str is string; + + /** + * Tests if a string is a well-formed string object. + * + * @param str - string to test + * @returns boolean indicating if a string is a well-formed string object + * + * @example + * var bool = isWellFormedString.isObject( '' ); + * // returns false + * + * @example + * var bool = isWellFormedString.isObject( new String( '' ) ); + * // returns true + */ + isObject( str: any ): str is Object; +} + +/** +* Tests if a string is well-formed. +* +* @param str - string to test +* @returns boolean indicating whether string is well-formed +* +* @example +* var bool = isWellFormedString( '' ); +* // returns true +* +* @example +* var bool = isWellFormedString( new String( '' ) ); +* // returns true +* +* @example +* var bool = isWellFormedString( '\uDBFF' ); +* // returns false +* +* @example +* var bool = isWellFormedString( '\uDBFFFF\uDBFF' ); +* // returns false +* +* @example +* var bool = isWellFormedString( null ); +* // returns false +* +* @example +* var bool = isWellFormedString.isPrimitive( new String('') ); +* // returns false +* +* @example +* var bool = isWellFormedString.isObject( new String( '' ) ); +* // returns true +*/ +declare var isWellFormedString: isWellFormedString; + + +// EXPORTS // + +export = isWellFormedString; diff --git a/lib/node_modules/@stdlib/string/is-well-formed-string/docs/types/test.ts b/lib/node_modules/@stdlib/string/is-well-formed-string/docs/types/test.ts new file mode 100644 index 000000000000..4010fd556266 --- /dev/null +++ b/lib/node_modules/@stdlib/string/is-well-formed-string/docs/types/test.ts @@ -0,0 +1,61 @@ +/* +* @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. +*/ + +import isWellFormedString = require( './index' ); + + +// TESTS // + +// The function returns a boolean... +{ + isWellFormedString( '' ); // $ExpectType boolean + isWellFormedString( 'Hello' ); // $ExpectType boolean +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + isWellFormedString(); // $ExpectError + isWellFormedString( '', '\uDBFF' ); // $ExpectError +} + +// Attached to main export is an isPrimitive method which returns a boolean... +{ + // eslint-disable-next-line no-new-wrappers + isWellFormedString.isPrimitive( new String( '' ) ); // $ExpectType boolean + isWellFormedString.isPrimitive( '' ); // $ExpectType boolean +} + +// The compiler throws an error if the isPrimitive method is provided an unsupported number of arguments... +{ + isWellFormedString.isPrimitive(); // $ExpectError + isWellFormedString.isPrimitive( '', '\uDBFF' ); // $ExpectError +} + + +// Attached to main export is an isPrimitive method which returns a boolean... +{ + // eslint-disable-next-line no-new-wrappers + isWellFormedString.isObject( new String( '' ) ); // $ExpectType boolean + isWellFormedString.isObject( '\uDBFF' ); // $ExpectType boolean +} + +// The compiler throws an error if the isObject method is provided an unsupported number of arguments... +{ + isWellFormedString.isObject(); // $ExpectError + isWellFormedString.isObject( '', '\uDBFF' ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/string/is-well-formed-string/examples/index.js b/lib/node_modules/@stdlib/string/is-well-formed-string/examples/index.js new file mode 100644 index 000000000000..a0e9cfb68297 --- /dev/null +++ b/lib/node_modules/@stdlib/string/is-well-formed-string/examples/index.js @@ -0,0 +1,44 @@ +/** +* @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 */ + +'use strict'; + +var isWellFormedString = require( './../lib' ); + +console.log( isWellFormedString( '' ) ); +// => true + +console.log( isWellFormedString( new String( '' ) ) ); +// => false + +console.log( isWellFormedString( '\uDBFF' ) ); +// => false + +console.log( isWellFormedString( '\uDBFFFF\uDBFF' ) ); +// => false + +console.log( isWellFormedString( [] ) ); +// => false + +console.log( isWellFormedString( '-5' ) ); +// => true + +console.log( isWellFormedString( null ) ); +// => false diff --git a/lib/node_modules/@stdlib/string/is-well-formed-string/lib/index.js b/lib/node_modules/@stdlib/string/is-well-formed-string/lib/index.js new file mode 100644 index 000000000000..eb1b1b8a3e5b --- /dev/null +++ b/lib/node_modules/@stdlib/string/is-well-formed-string/lib/index.js @@ -0,0 +1,81 @@ +/** +* @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. +*/ + +'use strict'; + +/** +* Test if a string is well-formed. +* +* @module @stdlib/string/is-well-formed-string +* +* @example +* var isWellFormedString = require( '@stdlib/string/is-well-formed-string' ); +* +* var bool = isWellFormedString( '' ); +* // returns true +* +* bool = isWellFormedString( new String( '' ) ); +* // returns true +* +* bool = isWellFormedString( '\uDC00' ); +* // returns false +* +* bool = isWellFormedString( '\uDBFFFFF' ); +* // returns false +* +* bool = isWellFormedString( null ); +* // returns false +* +* @example +* // Use interface to check for well-formed string primitives... +* var isWellFormedString = require( '@stdlib/string/is-well-formed-string' ).isPrimitive; +* +* var bool = isWellFormedString( '\uDC00' ); +* // returns false +* +* bool = isWellFormedString( new String( '' ) ); +* // returns false +* +* @example +* // Use interface to check for well-formed string objects... +* var isWellFormedString = require( '@stdlib/string/is-well-formed-string' ).isObject; +* +* var bool = isWellFormedString( '\uDC00' ); +* // returns false +* +* bool = isWellFormedString( new String( '' ) ); +* // returns true +*/ + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var main = require( './main.js' ); +var isPrimitive = require( './primitive.js' ); +var isObject = require( './object.js' ); + + +// MAIN // + +setReadOnly( main, 'isPrimitive', isPrimitive ); +setReadOnly( main, 'isObject', isObject ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/string/is-well-formed-string/lib/iswellformed.js b/lib/node_modules/@stdlib/string/is-well-formed-string/lib/iswellformed.js new file mode 100644 index 000000000000..b020a29ebaa7 --- /dev/null +++ b/lib/node_modules/@stdlib/string/is-well-formed-string/lib/iswellformed.js @@ -0,0 +1,79 @@ +/** +* @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. +*/ + +'use strict'; + +// VARIABLES // + +var RE_UTF16_LOW_SURROGATE = /[\uDC00-\uDFFF]/; +var RE_UTF16_HIGH_SURROGATE = /[\uD800-\uDBFF]/; +var i = 0; + + +// MAIN // + +/** +* Tests if a string is a well-formed string. +* +* @param {string} str - input string +* @returns {boolean} boolean indicating if a value is a well-formed string primitive +* +* @example +* var bool = isWellFormed( '' ); +* // returns true +* +* @example +* var bool = isWellFormed( new String( '\uDC00' ) ); +* // returns false +*/ +function isWellFormed(str) { + for ( i = 0; i < str.length; i++) { + // Checking if a low surrogate is present at the beginning + if (i === 0 && RE_UTF16_LOW_SURROGATE.test(str[i])) { + return false; + } + + // Checking if a high surrogate is present at the last + if (i === str.length - 1 && RE_UTF16_HIGH_SURROGATE.test(str[i])) { + return false; + } + + // Checking if there is no low surrogate after a high surrogate + if (i < str.length - 1 && RE_UTF16_HIGH_SURROGATE.test(str[i])) { + if (RE_UTF16_LOW_SURROGATE.test(str[i + 1])) { + i+=1; + } + else { + return false; + } + } + + // Checking if there is no high surrogate before a low surrogate + if ( i>0 && RE_UTF16_LOW_SURROGATE.test(str[i])) { + if (!RE_UTF16_HIGH_SURROGATE.test(str[i - 1])) { + return false; + } + } + } + return true; +} + + +// EXPORTS // + +module.exports = isWellFormed; diff --git a/lib/node_modules/@stdlib/string/is-well-formed-string/lib/main.js b/lib/node_modules/@stdlib/string/is-well-formed-string/lib/main.js new file mode 100644 index 000000000000..cc1611c5adf0 --- /dev/null +++ b/lib/node_modules/@stdlib/string/is-well-formed-string/lib/main.js @@ -0,0 +1,62 @@ +/** +* @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. +*/ + +'use strict'; + +// MODULES // + +var isPrimitive = require( './primitive.js' ); +var isObject = require( './object.js' ); + + +// MAIN // + +/** +* Tests if a string is well-formed. +* +* @param {string} str - input string +* @returns {boolean} boolean indicating whether a string is well-formed +* +* @example +* var bool = isWellFormedString( '' ); +* // returns true +* +* @example +* var bool = isWellFormedString( new String( '' ) ); +* // returns false +* +* @example +* var bool = isWellFormedString( '\uDC00' ); +* // returns false +* +* @example +* var bool = isWellFormedString( '\uDBFFFFF' ); +* // returns false +* +* @example +* var bool = isWellFormedString( null ); +* // returns false +*/ +function isWellFormedString( str ) { + return ( isPrimitive( str ) || isObject( str ) ); +} + + +// EXPORTS // + +module.exports = isWellFormedString; diff --git a/lib/node_modules/@stdlib/string/is-well-formed-string/lib/object.js b/lib/node_modules/@stdlib/string/is-well-formed-string/lib/object.js new file mode 100644 index 000000000000..c2120eec9f98 --- /dev/null +++ b/lib/node_modules/@stdlib/string/is-well-formed-string/lib/object.js @@ -0,0 +1,52 @@ +/** +* @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. +*/ + +'use strict'; + +// MODULES // + +var isWellFormed = require('./iswellformed.js'); + + +// MAIN // + +/** +* Tests if a string is a well-formed string object. +* +* @param {string} str - input string +* @returns {boolean} boolean indicating if a string is a well-formed string object +* +* @example +* var bool = isWellFormedString( '\uDC00' ); +* // returns false +* +* @example +* var bool = isWellFormedString( new String( '' ) ); +* // returns true +*/ +function isWellFormedString( str ) { + return ( + str instanceof String && + isWellFormed(str.valueOf()) + ); +} + + +// EXPORTS // + +module.exports = isWellFormedString; diff --git a/lib/node_modules/@stdlib/string/is-well-formed-string/lib/primitive.js b/lib/node_modules/@stdlib/string/is-well-formed-string/lib/primitive.js new file mode 100644 index 000000000000..020ca652a0fa --- /dev/null +++ b/lib/node_modules/@stdlib/string/is-well-formed-string/lib/primitive.js @@ -0,0 +1,51 @@ +/** +* @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. +*/ + +'use strict'; + +// MODULES // + +var isWellFormed = require('./iswellformed.js'); + + +// MAIN // + +/** +* Tests if a string is a well-formed string primitive. +* +* @param {string} str - input string +* @returns {boolean} boolean indicating if a string is a well-formed string primitive +* +* @example +* var bool = isWellFormedString( '\uDC00' ); +* // returns false +* +* @example +* var bool = isWellFormedString( new String( '' ) ); +* // returns false +*/ +function isWellFormedString( str ) { + return ( + typeof str === 'string' && isWellFormed(str) + ); +} + + +// EXPORTS // + +module.exports = isWellFormedString; diff --git a/lib/node_modules/@stdlib/string/is-well-formed-string/package.json b/lib/node_modules/@stdlib/string/is-well-formed-string/package.json new file mode 100644 index 000000000000..2baaeae6d0a0 --- /dev/null +++ b/lib/node_modules/@stdlib/string/is-well-formed-string/package.json @@ -0,0 +1,71 @@ +{ + "name": "@stdlib/assert/is-negative-number", + "version": "0.0.0", + "description": "Test if a value is a number having a negative value.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdassert", + "assertion", + "assert", + "utilities", + "utility", + "utils", + "util", + "number", + "numeric", + "negative", + "is", + "isnumber", + "isnumeric", + "type", + "check", + "primitive", + "object" + ] +} diff --git a/lib/node_modules/@stdlib/string/is-well-formed-string/test/test.js b/lib/node_modules/@stdlib/string/is-well-formed-string/test/test.js new file mode 100644 index 000000000000..4c6566bac575 --- /dev/null +++ b/lib/node_modules/@stdlib/string/is-well-formed-string/test/test.js @@ -0,0 +1,43 @@ +/** +* @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. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isWellFormedString = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof isWellFormedString, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the main export is a method to test for a well-formed string primitive', function test( t ) { + t.equal( typeof isWellFormedString.isPrimitive, 'function', 'export is a function' ); + t.end(); +}); + +tape( 'attached to the main export is a method to test for a well-formed string object', function test( t ) { + t.equal( typeof isWellFormedString.isObject, 'function', 'export is a function' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/string/is-well-formed-string/test/test.main.js b/lib/node_modules/@stdlib/string/is-well-formed-string/test/test.main.js new file mode 100644 index 000000000000..eab84390dd1d --- /dev/null +++ b/lib/node_modules/@stdlib/string/is-well-formed-string/test/test.main.js @@ -0,0 +1,61 @@ +/** +* @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. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isWellFormedString = require( './../lib/main.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof isWellFormedString, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `true` if provided a well-formed string', function test( t ) { + t.equal( isWellFormedString( '' ), true, 'returns true' ); + t.equal( isWellFormedString( new String( '' ) ), true, 'returns true' ); // eslint-disable-line no-new-wrappers + t.end(); +}); + +tape( 'the function returns `false` if not provided a well-formed string', function test( t ) { + var strs; + var i; + + strs = [ + '5\uDBFF', + '\uDBFF\uDBFF', + 'Hello \uDBFFWorld', + '\uDBFF', + '\uDBFFFFF', + '\uDC00\uDC00', + [], + {}, + function noop() {} + ]; + + for ( i = 0; i < strs.length; i++ ) { + t.equal( isWellFormedString( strs[i] ), false, 'returns false when provided '+strs[i] ); + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/string/is-well-formed-string/test/test.object.js b/lib/node_modules/@stdlib/string/is-well-formed-string/test/test.object.js new file mode 100644 index 000000000000..8914b0d8d1aa --- /dev/null +++ b/lib/node_modules/@stdlib/string/is-well-formed-string/test/test.object.js @@ -0,0 +1,69 @@ +/** +* @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. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isWellFormedString = require( './../lib/object.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof isWellFormedString, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `true` if provided a well-formed string object', function test( t ) { + t.equal( isWellFormedString( new String( '' ) ), true, 'returns true' ); // eslint-disable-line no-new-wrappers + t.end(); +}); + +tape( 'the function returns `false` if provided a string primitive, even if it is well-formed', function test( t ) { + t.equal( isWellFormedString( '' ), false, 'returns false' ); + t.end(); +}); + +tape( 'the function returns `false` if not provided a well-formed string', function test( t ) { + var strs; + var i; + + strs = [ + '\uDBFF', + new String( '\uDBFF\uDBFF' ), // eslint-disable-line no-new-wrappers + new String( '\uD800' ), // eslint-disable-line no-new-wrappers + '\uDBFFFFFF', + null, + true, + void 0, + [], + {}, + new Date(), + /./, + new RegExp( '.' ), // eslint-disable-line prefer-regex-literals + function noop() {} + ]; + + for ( i = 0; i < strs.length; i++ ) { + t.equal( isWellFormedString( strs[i] ), false, 'returns false when provided '+strs[i] ); + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/string/is-well-formed-string/test/test.primitive.js b/lib/node_modules/@stdlib/string/is-well-formed-string/test/test.primitive.js new file mode 100644 index 000000000000..1ef40a7b6b61 --- /dev/null +++ b/lib/node_modules/@stdlib/string/is-well-formed-string/test/test.primitive.js @@ -0,0 +1,66 @@ +/** +* @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. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isWellFormedString = require( './../lib/primitive.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof isWellFormedString, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `true` if provided a well-formed string primitive', function test( t ) { + t.equal( isWellFormedString( '' ), true, 'returns true' ); + t.end(); +}); + +tape( 'the function returns `false` if provided a string object, even if the string is well-formed', function test( t ) { + t.equal( isWellFormedString( new String( '' ) ), false, 'returns false' ); // eslint-disable-line no-new-wrappers + t.end(); +}); + +tape( 'the function returns `false` if not provided a well-formed string', function test( t ) { + var strs; + var i; + + strs = [ + '\uDBFFFFFF', + '\uD800', + new String( '\uDBFF' ), // eslint-disable-line no-new-wrappers + 3.14, + null, + true, + void 0, + [], + {}, + function noop() {} + ]; + + for ( i = 0; i < strs.length; i++ ) { + t.equal( isWellFormedString( strs[i] ), false, 'returns false when provided '+strs[i] ); + } + t.end(); +}); From 6b7d7e918a246e694f1bfff0658cd5d50c69978f Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Mon, 26 Feb 2024 10:47:45 +0530 Subject: [PATCH 02/23] feat: added assert/is-well-formed-string This commit adds the assert/is-well-formed-string module for checking well-formed-strings. --- .../{string => assert}/is-well-formed-string/README.md | 4 ++-- .../is-well-formed-string/benchmark/benchmark.js | 0 .../is-well-formed-string/docs/repl.txt | 0 .../is-well-formed-string/docs/types/index.d.ts | 0 .../is-well-formed-string/docs/types/test.ts | 0 .../is-well-formed-string/examples/index.js | 0 .../{string => assert}/is-well-formed-string/lib/index.js | 8 ++++---- .../is-well-formed-string/lib/iswellformed.js | 0 .../{string => assert}/is-well-formed-string/lib/main.js | 0 .../is-well-formed-string/lib/object.js | 0 .../is-well-formed-string/lib/primitive.js | 0 .../{string => assert}/is-well-formed-string/package.json | 0 .../{string => assert}/is-well-formed-string/test/test.js | 0 .../is-well-formed-string/test/test.main.js | 0 .../is-well-formed-string/test/test.object.js | 0 .../is-well-formed-string/test/test.primitive.js | 0 16 files changed, 6 insertions(+), 6 deletions(-) rename lib/node_modules/@stdlib/{string => assert}/is-well-formed-string/README.md (96%) rename lib/node_modules/@stdlib/{string => assert}/is-well-formed-string/benchmark/benchmark.js (100%) rename lib/node_modules/@stdlib/{string => assert}/is-well-formed-string/docs/repl.txt (100%) rename lib/node_modules/@stdlib/{string => assert}/is-well-formed-string/docs/types/index.d.ts (100%) rename lib/node_modules/@stdlib/{string => assert}/is-well-formed-string/docs/types/test.ts (100%) rename lib/node_modules/@stdlib/{string => assert}/is-well-formed-string/examples/index.js (100%) rename lib/node_modules/@stdlib/{string => assert}/is-well-formed-string/lib/index.js (88%) rename lib/node_modules/@stdlib/{string => assert}/is-well-formed-string/lib/iswellformed.js (100%) rename lib/node_modules/@stdlib/{string => assert}/is-well-formed-string/lib/main.js (100%) rename lib/node_modules/@stdlib/{string => assert}/is-well-formed-string/lib/object.js (100%) rename lib/node_modules/@stdlib/{string => assert}/is-well-formed-string/lib/primitive.js (100%) rename lib/node_modules/@stdlib/{string => assert}/is-well-formed-string/package.json (100%) rename lib/node_modules/@stdlib/{string => assert}/is-well-formed-string/test/test.js (100%) rename lib/node_modules/@stdlib/{string => assert}/is-well-formed-string/test/test.main.js (100%) rename lib/node_modules/@stdlib/{string => assert}/is-well-formed-string/test/test.object.js (100%) rename lib/node_modules/@stdlib/{string => assert}/is-well-formed-string/test/test.primitive.js (100%) diff --git a/lib/node_modules/@stdlib/string/is-well-formed-string/README.md b/lib/node_modules/@stdlib/assert/is-well-formed-string/README.md similarity index 96% rename from lib/node_modules/@stdlib/string/is-well-formed-string/README.md rename to lib/node_modules/@stdlib/assert/is-well-formed-string/README.md index 8e39e4f129fc..38f71db5dc00 100644 --- a/lib/node_modules/@stdlib/string/is-well-formed-string/README.md +++ b/lib/node_modules/@stdlib/assert/is-well-formed-string/README.md @@ -27,7 +27,7 @@ limitations under the License. ## Usage ```javascript -var isWellFormedString = require( '@stdlib/string/is-well-formed-string' ); +var isWellFormedString = require( '@stdlib/assert/is-well-formed-string' ); ``` #### isWellFormedString( str ) @@ -89,7 +89,7 @@ bool = isWellFormedString.isObject( new String( '' ) ); ```javascript -var isWellFormedString = require( '@stdlib/string/is-well-formed-string' ); +var isWellFormedString = require( '@stdlib/assert/is-well-formed-string' ); var bool = isWellFormedString( '' ); // returns true bool = isWellFormedString( new String( '' ) ); diff --git a/lib/node_modules/@stdlib/string/is-well-formed-string/benchmark/benchmark.js b/lib/node_modules/@stdlib/assert/is-well-formed-string/benchmark/benchmark.js similarity index 100% rename from lib/node_modules/@stdlib/string/is-well-formed-string/benchmark/benchmark.js rename to lib/node_modules/@stdlib/assert/is-well-formed-string/benchmark/benchmark.js diff --git a/lib/node_modules/@stdlib/string/is-well-formed-string/docs/repl.txt b/lib/node_modules/@stdlib/assert/is-well-formed-string/docs/repl.txt similarity index 100% rename from lib/node_modules/@stdlib/string/is-well-formed-string/docs/repl.txt rename to lib/node_modules/@stdlib/assert/is-well-formed-string/docs/repl.txt diff --git a/lib/node_modules/@stdlib/string/is-well-formed-string/docs/types/index.d.ts b/lib/node_modules/@stdlib/assert/is-well-formed-string/docs/types/index.d.ts similarity index 100% rename from lib/node_modules/@stdlib/string/is-well-formed-string/docs/types/index.d.ts rename to lib/node_modules/@stdlib/assert/is-well-formed-string/docs/types/index.d.ts diff --git a/lib/node_modules/@stdlib/string/is-well-formed-string/docs/types/test.ts b/lib/node_modules/@stdlib/assert/is-well-formed-string/docs/types/test.ts similarity index 100% rename from lib/node_modules/@stdlib/string/is-well-formed-string/docs/types/test.ts rename to lib/node_modules/@stdlib/assert/is-well-formed-string/docs/types/test.ts diff --git a/lib/node_modules/@stdlib/string/is-well-formed-string/examples/index.js b/lib/node_modules/@stdlib/assert/is-well-formed-string/examples/index.js similarity index 100% rename from lib/node_modules/@stdlib/string/is-well-formed-string/examples/index.js rename to lib/node_modules/@stdlib/assert/is-well-formed-string/examples/index.js diff --git a/lib/node_modules/@stdlib/string/is-well-formed-string/lib/index.js b/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/index.js similarity index 88% rename from lib/node_modules/@stdlib/string/is-well-formed-string/lib/index.js rename to lib/node_modules/@stdlib/assert/is-well-formed-string/lib/index.js index eb1b1b8a3e5b..1867e39c09f4 100644 --- a/lib/node_modules/@stdlib/string/is-well-formed-string/lib/index.js +++ b/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/index.js @@ -21,10 +21,10 @@ /** * Test if a string is well-formed. * -* @module @stdlib/string/is-well-formed-string +* @module @stdlib/assert/is-well-formed-string * * @example -* var isWellFormedString = require( '@stdlib/string/is-well-formed-string' ); +* var isWellFormedString = require( '@stdlib/assert/is-well-formed-string' ); * * var bool = isWellFormedString( '' ); * // returns true @@ -43,7 +43,7 @@ * * @example * // Use interface to check for well-formed string primitives... -* var isWellFormedString = require( '@stdlib/string/is-well-formed-string' ).isPrimitive; +* var isWellFormedString = require( '@stdlib/assert/is-well-formed-string' ).isPrimitive; * * var bool = isWellFormedString( '\uDC00' ); * // returns false @@ -53,7 +53,7 @@ * * @example * // Use interface to check for well-formed string objects... -* var isWellFormedString = require( '@stdlib/string/is-well-formed-string' ).isObject; +* var isWellFormedString = require( '@stdlib/assert/is-well-formed-string' ).isObject; * * var bool = isWellFormedString( '\uDC00' ); * // returns false diff --git a/lib/node_modules/@stdlib/string/is-well-formed-string/lib/iswellformed.js b/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js similarity index 100% rename from lib/node_modules/@stdlib/string/is-well-formed-string/lib/iswellformed.js rename to lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js diff --git a/lib/node_modules/@stdlib/string/is-well-formed-string/lib/main.js b/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/main.js similarity index 100% rename from lib/node_modules/@stdlib/string/is-well-formed-string/lib/main.js rename to lib/node_modules/@stdlib/assert/is-well-formed-string/lib/main.js diff --git a/lib/node_modules/@stdlib/string/is-well-formed-string/lib/object.js b/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/object.js similarity index 100% rename from lib/node_modules/@stdlib/string/is-well-formed-string/lib/object.js rename to lib/node_modules/@stdlib/assert/is-well-formed-string/lib/object.js diff --git a/lib/node_modules/@stdlib/string/is-well-formed-string/lib/primitive.js b/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/primitive.js similarity index 100% rename from lib/node_modules/@stdlib/string/is-well-formed-string/lib/primitive.js rename to lib/node_modules/@stdlib/assert/is-well-formed-string/lib/primitive.js diff --git a/lib/node_modules/@stdlib/string/is-well-formed-string/package.json b/lib/node_modules/@stdlib/assert/is-well-formed-string/package.json similarity index 100% rename from lib/node_modules/@stdlib/string/is-well-formed-string/package.json rename to lib/node_modules/@stdlib/assert/is-well-formed-string/package.json diff --git a/lib/node_modules/@stdlib/string/is-well-formed-string/test/test.js b/lib/node_modules/@stdlib/assert/is-well-formed-string/test/test.js similarity index 100% rename from lib/node_modules/@stdlib/string/is-well-formed-string/test/test.js rename to lib/node_modules/@stdlib/assert/is-well-formed-string/test/test.js diff --git a/lib/node_modules/@stdlib/string/is-well-formed-string/test/test.main.js b/lib/node_modules/@stdlib/assert/is-well-formed-string/test/test.main.js similarity index 100% rename from lib/node_modules/@stdlib/string/is-well-formed-string/test/test.main.js rename to lib/node_modules/@stdlib/assert/is-well-formed-string/test/test.main.js diff --git a/lib/node_modules/@stdlib/string/is-well-formed-string/test/test.object.js b/lib/node_modules/@stdlib/assert/is-well-formed-string/test/test.object.js similarity index 100% rename from lib/node_modules/@stdlib/string/is-well-formed-string/test/test.object.js rename to lib/node_modules/@stdlib/assert/is-well-formed-string/test/test.object.js diff --git a/lib/node_modules/@stdlib/string/is-well-formed-string/test/test.primitive.js b/lib/node_modules/@stdlib/assert/is-well-formed-string/test/test.primitive.js similarity index 100% rename from lib/node_modules/@stdlib/string/is-well-formed-string/test/test.primitive.js rename to lib/node_modules/@stdlib/assert/is-well-formed-string/test/test.primitive.js From 6cd7771818b0745a829f7c96d12a2c61229fbe22 Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Tue, 27 Feb 2024 07:12:09 +0530 Subject: [PATCH 03/23] Update lib/node_modules/@stdlib/assert/is-well-formed-string/README.md Co-authored-by: Philipp Burckhardt Signed-off-by: GUNJ JOSHI --- .../@stdlib/assert/is-well-formed-string/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/node_modules/@stdlib/assert/is-well-formed-string/README.md b/lib/node_modules/@stdlib/assert/is-well-formed-string/README.md index 38f71db5dc00..7a5af473c9c4 100644 --- a/lib/node_modules/@stdlib/assert/is-well-formed-string/README.md +++ b/lib/node_modules/@stdlib/assert/is-well-formed-string/README.md @@ -39,12 +39,16 @@ Tests if a `string` is well-formed. ```javascript var bool = isWellFormedString( '' ); // returns true + bool = isWellFormedString( new String( '' ) ); // returns true + bool = isWellFormedString( '\uD800\uD800' ); // returns false + bool = isWellFormedString( '\uDBFF' ); // returns false + bool = isWellFormedString( null ); // returns false ``` From bb2f66aae012b8a8f10ef18c709cfb754c1b56b2 Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Tue, 27 Feb 2024 07:14:16 +0530 Subject: [PATCH 04/23] Update package.json Signed-off-by: GUNJ JOSHI --- .../@stdlib/assert/is-well-formed-string/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/assert/is-well-formed-string/package.json b/lib/node_modules/@stdlib/assert/is-well-formed-string/package.json index 2baaeae6d0a0..f3757e85787d 100644 --- a/lib/node_modules/@stdlib/assert/is-well-formed-string/package.json +++ b/lib/node_modules/@stdlib/assert/is-well-formed-string/package.json @@ -1,7 +1,7 @@ { - "name": "@stdlib/assert/is-negative-number", + "name": "@stdlib/assert/is-well-formed-string", "version": "0.0.0", - "description": "Test if a value is a number having a negative value.", + "description": "Test if a string is a well-formed string.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", From e0c96de5535964667c20bb2f58f571376d46725d Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Tue, 27 Feb 2024 07:15:34 +0530 Subject: [PATCH 05/23] Update lib/node_modules/@stdlib/assert/is-well-formed-string/lib/primitive.js Co-authored-by: Philipp Burckhardt Signed-off-by: GUNJ JOSHI --- .../@stdlib/assert/is-well-formed-string/lib/primitive.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/primitive.js b/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/primitive.js index 020ca652a0fa..da4e82c9aa16 100644 --- a/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/primitive.js +++ b/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/primitive.js @@ -41,7 +41,7 @@ var isWellFormed = require('./iswellformed.js'); */ function isWellFormedString( str ) { return ( - typeof str === 'string' && isWellFormed(str) + typeof str === 'string' && isWellFormed( str ) ); } From 2928ca8316c84da357dc07deca87254c7ef45c55 Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Tue, 27 Feb 2024 07:15:45 +0530 Subject: [PATCH 06/23] Update lib/node_modules/@stdlib/assert/is-well-formed-string/README.md Co-authored-by: Philipp Burckhardt Signed-off-by: GUNJ JOSHI --- lib/node_modules/@stdlib/assert/is-well-formed-string/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/node_modules/@stdlib/assert/is-well-formed-string/README.md b/lib/node_modules/@stdlib/assert/is-well-formed-string/README.md index 7a5af473c9c4..a973e1e6c088 100644 --- a/lib/node_modules/@stdlib/assert/is-well-formed-string/README.md +++ b/lib/node_modules/@stdlib/assert/is-well-formed-string/README.md @@ -76,6 +76,7 @@ Tests if a `string` is a well-formed `String` object. ```javascript var bool = isWellFormedString.isObject( '' ); // returns false + bool = isWellFormedString.isObject( new String( '' ) ); // returns true ``` From bb7cbe4f8f8c58d57d2719d2000fc8de51244572 Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Tue, 27 Feb 2024 07:15:55 +0530 Subject: [PATCH 07/23] Update lib/node_modules/@stdlib/assert/is-well-formed-string/README.md Co-authored-by: Philipp Burckhardt Signed-off-by: GUNJ JOSHI --- .../@stdlib/assert/is-well-formed-string/README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/node_modules/@stdlib/assert/is-well-formed-string/README.md b/lib/node_modules/@stdlib/assert/is-well-formed-string/README.md index a973e1e6c088..814afa32670e 100644 --- a/lib/node_modules/@stdlib/assert/is-well-formed-string/README.md +++ b/lib/node_modules/@stdlib/assert/is-well-formed-string/README.md @@ -95,18 +95,25 @@ bool = isWellFormedString.isObject( new String( '' ) ); ```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 ``` From aa1220a10d0c03de501f657b5d18d2ff5f23eead Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Tue, 27 Feb 2024 07:16:40 +0530 Subject: [PATCH 08/23] Update lib/node_modules/@stdlib/assert/is-well-formed-string/README.md Co-authored-by: Philipp Burckhardt Signed-off-by: GUNJ JOSHI --- .../@stdlib/assert/is-well-formed-string/README.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/node_modules/@stdlib/assert/is-well-formed-string/README.md b/lib/node_modules/@stdlib/assert/is-well-formed-string/README.md index 814afa32670e..ba7fb104c52b 100644 --- a/lib/node_modules/@stdlib/assert/is-well-formed-string/README.md +++ b/lib/node_modules/@stdlib/assert/is-well-formed-string/README.md @@ -126,11 +126,6 @@ bool = isWellFormedString( null ); From 522ae1629f82a511ae0a8613f3904e2790cfef84 Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Tue, 27 Feb 2024 07:16:57 +0530 Subject: [PATCH 09/23] Update lib/node_modules/@stdlib/assert/is-well-formed-string/README.md Co-authored-by: Philipp Burckhardt Signed-off-by: GUNJ JOSHI --- lib/node_modules/@stdlib/assert/is-well-formed-string/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/node_modules/@stdlib/assert/is-well-formed-string/README.md b/lib/node_modules/@stdlib/assert/is-well-formed-string/README.md index ba7fb104c52b..a16243548a70 100644 --- a/lib/node_modules/@stdlib/assert/is-well-formed-string/README.md +++ b/lib/node_modules/@stdlib/assert/is-well-formed-string/README.md @@ -137,7 +137,6 @@ bool = isWellFormedString( null ); -[@stdlib/assert/is-string]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-string From 0de80cc53bb8595291d91a154b814c83315b205b Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Tue, 27 Feb 2024 07:17:31 +0530 Subject: [PATCH 10/23] Update lib/node_modules/@stdlib/assert/is-well-formed-string/docs/types/test.ts Co-authored-by: Philipp Burckhardt Signed-off-by: GUNJ JOSHI --- .../@stdlib/assert/is-well-formed-string/docs/types/test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/assert/is-well-formed-string/docs/types/test.ts b/lib/node_modules/@stdlib/assert/is-well-formed-string/docs/types/test.ts index 4010fd556266..c7c0f00ce6d7 100644 --- a/lib/node_modules/@stdlib/assert/is-well-formed-string/docs/types/test.ts +++ b/lib/node_modules/@stdlib/assert/is-well-formed-string/docs/types/test.ts @@ -47,7 +47,7 @@ import isWellFormedString = require( './index' ); } -// Attached to main export is an isPrimitive method which returns a boolean... +// Attached to main export is an isObject method which returns a boolean... { // eslint-disable-next-line no-new-wrappers isWellFormedString.isObject( new String( '' ) ); // $ExpectType boolean From 7055a64bb4c13a010cd4de7c4a215083713bd2da Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Tue, 27 Feb 2024 07:17:47 +0530 Subject: [PATCH 11/23] Update lib/node_modules/@stdlib/assert/is-well-formed-string/docs/types/test.ts Co-authored-by: Philipp Burckhardt Signed-off-by: GUNJ JOSHI --- .../@stdlib/assert/is-well-formed-string/docs/types/test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/node_modules/@stdlib/assert/is-well-formed-string/docs/types/test.ts b/lib/node_modules/@stdlib/assert/is-well-formed-string/docs/types/test.ts index c7c0f00ce6d7..41f6f5681b4c 100644 --- a/lib/node_modules/@stdlib/assert/is-well-formed-string/docs/types/test.ts +++ b/lib/node_modules/@stdlib/assert/is-well-formed-string/docs/types/test.ts @@ -46,7 +46,6 @@ import isWellFormedString = require( './index' ); isWellFormedString.isPrimitive( '', '\uDBFF' ); // $ExpectError } - // Attached to main export is an isObject method which returns a boolean... { // eslint-disable-next-line no-new-wrappers From f831f8845dc68f9f9b3f1fff433d1a4c41185304 Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Tue, 27 Feb 2024 07:20:38 +0530 Subject: [PATCH 12/23] Update lib/node_modules/@stdlib/assert/is-well-formed-string/examples/index.js Co-authored-by: Philipp Burckhardt Signed-off-by: GUNJ JOSHI --- .../@stdlib/assert/is-well-formed-string/examples/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/assert/is-well-formed-string/examples/index.js b/lib/node_modules/@stdlib/assert/is-well-formed-string/examples/index.js index a0e9cfb68297..bf730ead017e 100644 --- a/lib/node_modules/@stdlib/assert/is-well-formed-string/examples/index.js +++ b/lib/node_modules/@stdlib/assert/is-well-formed-string/examples/index.js @@ -26,7 +26,7 @@ console.log( isWellFormedString( '' ) ); // => true console.log( isWellFormedString( new String( '' ) ) ); -// => false +// => true console.log( isWellFormedString( '\uDBFF' ) ); // => false From 50930f75b8d30cade267ec0a20e203d14204b166 Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Tue, 27 Feb 2024 07:20:58 +0530 Subject: [PATCH 13/23] Update lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js Co-authored-by: Philipp Burckhardt Signed-off-by: GUNJ JOSHI --- .../@stdlib/assert/is-well-formed-string/lib/iswellformed.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js b/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js index b020a29ebaa7..9acd88aeab4f 100644 --- a/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js +++ b/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js @@ -42,7 +42,7 @@ var i = 0; * // returns false */ function isWellFormed(str) { - for ( i = 0; i < str.length; i++) { + for ( i = 0; i < str.length; i++ ) { // Checking if a low surrogate is present at the beginning if (i === 0 && RE_UTF16_LOW_SURROGATE.test(str[i])) { return false; From b458106f408c556e6331aeb09d6b59633651ffa2 Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Tue, 27 Feb 2024 07:21:13 +0530 Subject: [PATCH 14/23] Update lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js Co-authored-by: Philipp Burckhardt Signed-off-by: GUNJ JOSHI --- .../@stdlib/assert/is-well-formed-string/lib/iswellformed.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js b/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js index 9acd88aeab4f..8f7583cd9870 100644 --- a/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js +++ b/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js @@ -48,7 +48,7 @@ function isWellFormed(str) { return false; } - // Checking if a high surrogate is present at the last + // Checking if a high surrogate is present at the last position if (i === str.length - 1 && RE_UTF16_HIGH_SURROGATE.test(str[i])) { return false; } From 2c2c6ea76952a25173c4f4b19d5a8f4cbb5b805b Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Tue, 27 Feb 2024 07:21:24 +0530 Subject: [PATCH 15/23] Update lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js Co-authored-by: Philipp Burckhardt Signed-off-by: GUNJ JOSHI --- .../@stdlib/assert/is-well-formed-string/lib/iswellformed.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js b/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js index 8f7583cd9870..26113f91675e 100644 --- a/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js +++ b/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js @@ -54,7 +54,7 @@ function isWellFormed(str) { } // Checking if there is no low surrogate after a high surrogate - if (i < str.length - 1 && RE_UTF16_HIGH_SURROGATE.test(str[i])) { + if ( i < str.length - 1 && RE_UTF16_HIGH_SURROGATE.test(str[i]) ) { if (RE_UTF16_LOW_SURROGATE.test(str[i + 1])) { i+=1; } From 9710381248e2cee5723d7814afd3b4051b98a3ac Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Tue, 27 Feb 2024 07:21:37 +0530 Subject: [PATCH 16/23] Update lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js Co-authored-by: Philipp Burckhardt Signed-off-by: GUNJ JOSHI --- .../@stdlib/assert/is-well-formed-string/lib/iswellformed.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js b/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js index 26113f91675e..e2bea667bbdd 100644 --- a/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js +++ b/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js @@ -55,7 +55,7 @@ function isWellFormed(str) { // Checking if there is no low surrogate after a high surrogate if ( i < str.length - 1 && RE_UTF16_HIGH_SURROGATE.test(str[i]) ) { - if (RE_UTF16_LOW_SURROGATE.test(str[i + 1])) { + if ( RE_UTF16_LOW_SURROGATE.test(str[i + 1]) ) { i+=1; } else { From a32202813e43cf677e8d806901821f9b3524721f Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Tue, 27 Feb 2024 07:21:50 +0530 Subject: [PATCH 17/23] Update lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js Co-authored-by: Philipp Burckhardt Signed-off-by: GUNJ JOSHI --- .../@stdlib/assert/is-well-formed-string/lib/iswellformed.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js b/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js index e2bea667bbdd..78320caaa9a1 100644 --- a/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js +++ b/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js @@ -56,7 +56,7 @@ function isWellFormed(str) { // Checking if there is no low surrogate after a high surrogate if ( i < str.length - 1 && RE_UTF16_HIGH_SURROGATE.test(str[i]) ) { if ( RE_UTF16_LOW_SURROGATE.test(str[i + 1]) ) { - i+=1; + i += 1; } else { return false; From e887070f4e227f1eb34a77887f617eeee771d560 Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Tue, 27 Feb 2024 07:23:09 +0530 Subject: [PATCH 18/23] Update lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js Co-authored-by: Philipp Burckhardt Signed-off-by: GUNJ JOSHI --- .../@stdlib/assert/is-well-formed-string/lib/iswellformed.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js b/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js index 78320caaa9a1..4f8f04f78dc0 100644 --- a/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js +++ b/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js @@ -64,7 +64,7 @@ function isWellFormed(str) { } // Checking if there is no high surrogate before a low surrogate - if ( i>0 && RE_UTF16_LOW_SURROGATE.test(str[i])) { + if ( i > 0 && RE_UTF16_LOW_SURROGATE.test(str[i]) ) { if (!RE_UTF16_HIGH_SURROGATE.test(str[i - 1])) { return false; } From 8227c939190b0e2caf51892d0a7c1781e35a00cd Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Tue, 27 Feb 2024 07:23:17 +0530 Subject: [PATCH 19/23] Update lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js Co-authored-by: Philipp Burckhardt Signed-off-by: GUNJ JOSHI --- .../@stdlib/assert/is-well-formed-string/lib/iswellformed.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js b/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js index 4f8f04f78dc0..fecee22d9133 100644 --- a/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js +++ b/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js @@ -65,7 +65,7 @@ function isWellFormed(str) { // Checking if there is no high surrogate before a low surrogate if ( i > 0 && RE_UTF16_LOW_SURROGATE.test(str[i]) ) { - if (!RE_UTF16_HIGH_SURROGATE.test(str[i - 1])) { + if ( !RE_UTF16_HIGH_SURROGATE.test(str[i - 1]) ) { return false; } } From f1542e25066058295a0e1ffade73a85049f76635 Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Tue, 27 Feb 2024 07:26:14 +0530 Subject: [PATCH 20/23] Update iswellformed.js Signed-off-by: GUNJ JOSHI --- .../@stdlib/assert/is-well-formed-string/lib/iswellformed.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js b/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js index fecee22d9133..b77cbd8b727b 100644 --- a/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js +++ b/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js @@ -22,7 +22,6 @@ var RE_UTF16_LOW_SURROGATE = /[\uDC00-\uDFFF]/; var RE_UTF16_HIGH_SURROGATE = /[\uD800-\uDBFF]/; -var i = 0; // MAIN // @@ -42,6 +41,7 @@ var i = 0; * // returns false */ function isWellFormed(str) { + var i = 0; for ( i = 0; i < str.length; i++ ) { // Checking if a low surrogate is present at the beginning if (i === 0 && RE_UTF16_LOW_SURROGATE.test(str[i])) { From 32bf6a47bbffbda39b708e822bec909e212068cb Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Tue, 27 Feb 2024 07:30:25 +0530 Subject: [PATCH 21/23] Update iswellformed.js Signed-off-by: GUNJ JOSHI --- .../@stdlib/assert/is-well-formed-string/lib/iswellformed.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js b/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js index b77cbd8b727b..d1bb20f60f12 100644 --- a/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js +++ b/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js @@ -41,7 +41,7 @@ var RE_UTF16_HIGH_SURROGATE = /[\uD800-\uDBFF]/; * // returns false */ function isWellFormed(str) { - var i = 0; + var i; for ( i = 0; i < str.length; i++ ) { // Checking if a low surrogate is present at the beginning if (i === 0 && RE_UTF16_LOW_SURROGATE.test(str[i])) { From 462cda278f21ae0101ddaa02eb99bf51002b7e70 Mon Sep 17 00:00:00 2001 From: GUNJ JOSHI Date: Tue, 27 Feb 2024 21:19:52 +0530 Subject: [PATCH 22/23] feat: added assert/is-well-formed-string This commit adds the assert/is-well-formed-string module for checking well-formed-strings. --- .../assert/is-well-formed-string/README.md | 10 ++++++++-- .../is-well-formed-string/docs/repl.txt | 20 ++++++++++++------- .../docs/types/index.d.ts | 20 +++++++++++++------ .../assert/is-well-formed-string/lib/index.js | 10 ++++++++-- .../assert/is-well-formed-string/lib/main.js | 12 +++++++++-- .../is-well-formed-string/lib/object.js | 3 ++- 6 files changed, 55 insertions(+), 20 deletions(-) diff --git a/lib/node_modules/@stdlib/assert/is-well-formed-string/README.md b/lib/node_modules/@stdlib/assert/is-well-formed-string/README.md index a16243548a70..b667b2a9697c 100644 --- a/lib/node_modules/@stdlib/assert/is-well-formed-string/README.md +++ b/lib/node_modules/@stdlib/assert/is-well-formed-string/README.md @@ -43,12 +43,18 @@ var bool = isWellFormedString( '' ); bool = isWellFormedString( new String( '' ) ); // returns true -bool = isWellFormedString( '\uD800\uD800' ); +bool = isWellFormedString( '\uDBFF' ); // returns false -bool = isWellFormedString( '\uDBFF' ); +bool = isWellFormedString( '\uDBFFFF\uDBFF' ); +// returns false + +bool = isWellFormedString( [] ); // returns false +bool = isWellFormedString( '-5' ); +// returns true + bool = isWellFormedString( null ); // returns false ``` diff --git a/lib/node_modules/@stdlib/assert/is-well-formed-string/docs/repl.txt b/lib/node_modules/@stdlib/assert/is-well-formed-string/docs/repl.txt index 48e489345ed6..cc8c6602a714 100644 --- a/lib/node_modules/@stdlib/assert/is-well-formed-string/docs/repl.txt +++ b/lib/node_modules/@stdlib/assert/is-well-formed-string/docs/repl.txt @@ -14,18 +14,24 @@ Examples -------- - > var bool = {{alias}}( '\uDBFFFFG' ) - false + > var bool = {{alias}}( '' ) + true - > bool = {{alias}}( new String( '0xDFFFFF' ) ) - false + > bool = {{alias}}( new String( '' ) ) + true > bool = {{alias}}( '\uDBFF' ) false - > bool = {{alias}}( '\uDBFF\uDBFF' ) + > bool = {{alias}}( '\uDBFFFF\uDBFF' ) + false + + > bool = {{alias}}( [] ) false + > bool = {{alias}}( '-5' ) + true + > bool = {{alias}}( null ) false @@ -68,8 +74,8 @@ -------- > var bool = {{alias}}.isObject( '' ) false - > bool = {{alias}}.isObject( new String( '0xDFFF' ) ) - false + > bool = {{alias}}.isObject( new String( '' ) ) + true See Also -------- diff --git a/lib/node_modules/@stdlib/assert/is-well-formed-string/docs/types/index.d.ts b/lib/node_modules/@stdlib/assert/is-well-formed-string/docs/types/index.d.ts index da69bb82b320..734f8ae06eef 100644 --- a/lib/node_modules/@stdlib/assert/is-well-formed-string/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/assert/is-well-formed-string/docs/types/index.d.ts @@ -41,10 +41,18 @@ interface isWellFormedString { * // returns false * * @example - * var bool = isWellFormedString( '\uDBFF\uDBFF' ); + * var bool = isWellFormedString( '\uDBFFFF\uDBFF' ); * // returns false * * @example + * var bool = isWellFormedString( [] ); + * // returns false + * + * @example + * var bool = isWellFormedString( '-5' ); + * // returns true + * + * @example * var bool = isWellFormedString( null ); * // returns false */ @@ -106,16 +114,16 @@ interface isWellFormedString { * // returns false * * @example -* var bool = isWellFormedString( null ); +* var bool = isWellFormedString( [] ); * // returns false * * @example -* var bool = isWellFormedString.isPrimitive( new String('') ); -* // returns false +* var bool = isWellFormedString( '-5' ); +* // returns true * * @example -* var bool = isWellFormedString.isObject( new String( '' ) ); -* // returns true +* var bool = isWellFormedString( null ); +* // returns false */ declare var isWellFormedString: isWellFormedString; diff --git a/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/index.js b/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/index.js index 1867e39c09f4..6c84767bf92b 100644 --- a/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/index.js +++ b/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/index.js @@ -32,12 +32,18 @@ * bool = isWellFormedString( new String( '' ) ); * // returns true * -* bool = isWellFormedString( '\uDC00' ); +* bool = isWellFormedString( '\uDBFF' ); * // returns false * -* bool = isWellFormedString( '\uDBFFFFF' ); +* bool = isWellFormedString( '\uDBFFFF\uDBFF' ); * // returns false * +* bool = isWellFormedString( [] ); +* // returns false +* +* bool = isWellFormedString( '-5' ); +* // returns true +* * bool = isWellFormedString( null ); * // returns false * diff --git a/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/main.js b/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/main.js index cc1611c5adf0..5f4e0ec3a21d 100644 --- a/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/main.js +++ b/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/main.js @@ -38,17 +38,25 @@ var isObject = require( './object.js' ); * * @example * var bool = isWellFormedString( new String( '' ) ); +* // returns true +* +* @example +* var bool = isWellFormedString( '\uDBFF' ); * // returns false * * @example -* var bool = isWellFormedString( '\uDC00' ); +* var bool = isWellFormedString( '\uDBFFFF\uDBFF' ); * // returns false * * @example -* var bool = isWellFormedString( '\uDBFFFFF' ); +* var bool = isWellFormedString( [] ); * // returns false * * @example +* var bool = isWellFormedString( '-5' ); +* // returns true +* +* @example * var bool = isWellFormedString( null ); * // returns false */ diff --git a/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/object.js b/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/object.js index c2120eec9f98..1d5a6b674333 100644 --- a/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/object.js +++ b/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/object.js @@ -20,6 +20,7 @@ // MODULES // +var isString = require('@stdlib/assert/is-string'); var isWellFormed = require('./iswellformed.js'); @@ -41,7 +42,7 @@ var isWellFormed = require('./iswellformed.js'); */ function isWellFormedString( str ) { return ( - str instanceof String && + isString.isObject(str) && isWellFormed(str.valueOf()) ); } From cd5fc1f694f6f2e480a4b00ffc5cdd640151dd14 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Tue, 27 Feb 2024 12:15:44 -0500 Subject: [PATCH 23/23] Apply suggestions from code review Signed-off-by: Philipp Burckhardt --- .../@stdlib/assert/is-well-formed-string/lib/iswellformed.js | 4 ++-- .../@stdlib/assert/is-well-formed-string/lib/object.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js b/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js index d1bb20f60f12..11d01f424352 100644 --- a/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js +++ b/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/iswellformed.js @@ -44,12 +44,12 @@ function isWellFormed(str) { var i; for ( i = 0; i < str.length; i++ ) { // Checking if a low surrogate is present at the beginning - if (i === 0 && RE_UTF16_LOW_SURROGATE.test(str[i])) { + if ( i === 0 && RE_UTF16_LOW_SURROGATE.test(str[i]) ) { return false; } // Checking if a high surrogate is present at the last position - if (i === str.length - 1 && RE_UTF16_HIGH_SURROGATE.test(str[i])) { + if ( i === str.length - 1 && RE_UTF16_HIGH_SURROGATE.test(str[i]) ) { return false; } diff --git a/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/object.js b/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/object.js index 1d5a6b674333..34b1999cf095 100644 --- a/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/object.js +++ b/lib/node_modules/@stdlib/assert/is-well-formed-string/lib/object.js @@ -42,8 +42,8 @@ var isWellFormed = require('./iswellformed.js'); */ function isWellFormedString( str ) { return ( - isString.isObject(str) && - isWellFormed(str.valueOf()) + isString.isObject( str ) && + isWellFormed( str.valueOf() ) ); }