From 5af296e52adf72ebdb66da93884230e825931967 Mon Sep 17 00:00:00 2001 From: kaushal-kumar-it Date: Sun, 16 Nov 2025 13:18:06 +0530 Subject: [PATCH 01/14] feat: add symbol/match package --- .../@stdlib/symbol/match/README.md | 121 ++++++++++++++++++ .../@stdlib/symbol/match/docs/repl.txt | 18 +++ .../symbol/match/docs/types/index.d.ts | 31 +++++ .../@stdlib/symbol/match/docs/types/test.ts | 29 +++++ .../@stdlib/symbol/match/examples/index.js | 34 +++++ .../@stdlib/symbol/match/lib/index.js | 43 +++++++ .../@stdlib/symbol/match/lib/main.js | 47 +++++++ .../@stdlib/symbol/match/package.json | 59 +++++++++ .../@stdlib/symbol/match/test/test.js | 52 ++++++++ 9 files changed, 434 insertions(+) create mode 100644 lib/node_modules/@stdlib/symbol/match/README.md create mode 100644 lib/node_modules/@stdlib/symbol/match/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/symbol/match/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/symbol/match/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/symbol/match/examples/index.js create mode 100644 lib/node_modules/@stdlib/symbol/match/lib/index.js create mode 100644 lib/node_modules/@stdlib/symbol/match/lib/main.js create mode 100644 lib/node_modules/@stdlib/symbol/match/package.json create mode 100644 lib/node_modules/@stdlib/symbol/match/test/test.js diff --git a/lib/node_modules/@stdlib/symbol/match/README.md b/lib/node_modules/@stdlib/symbol/match/README.md new file mode 100644 index 000000000000..9b8d59e96624 --- /dev/null +++ b/lib/node_modules/@stdlib/symbol/match/README.md @@ -0,0 +1,121 @@ + + +# MatchSymbol + +> [Symbol][mdn-symbol] which specifies the matching of a regular expression against a string. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var MatchSymbol = require( '@stdlib/symbol/match' ); +``` + +#### MatchSymbol + +[`Symbol`][mdn-symbol] which specifies the matching of a regular expression against a string. Used by `String.prototype.match()`. + +```javascript +var s = typeof MatchSymbol; +// e.g., returns 'symbol' +``` + +
+ + + + + +
+ +## Notes + +- The [symbol][mdn-symbol] is only supported in environments which support [symbols][mdn-symbol]. In non-supporting environments, the value is `null`. + +
+ + + + + +
+ +## Examples + + + +```javascript +var MatchSymbol = require( '@stdlib/symbol/match' ); + +var re = /foo/; +var str = 'football'; + +var v = str.match( re ); +console.log( v ); +// => [ 'foo', index: 0, input: 'football', groups: undefined ] + +// Disable default match behavior: +re[ MatchSymbol ] = false; +v = '/foo/'.startsWith( re ); +console.log( v ); +// => true +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/symbol/match/docs/repl.txt b/lib/node_modules/@stdlib/symbol/match/docs/repl.txt new file mode 100644 index 000000000000..1ddc7082ebf9 --- /dev/null +++ b/lib/node_modules/@stdlib/symbol/match/docs/repl.txt @@ -0,0 +1,18 @@ + +{{alias}} + Match symbol. + + This symbol specifies the matching of a regular expression against a string. + It is used by String.prototype.match(). + + The symbol is only supported in ES6/ES2015+ environments. For non-supporting + environments, the value is `null`. + + Examples + -------- + > var s = {{alias}} + e.g., + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/symbol/match/docs/types/index.d.ts b/lib/node_modules/@stdlib/symbol/match/docs/types/index.d.ts new file mode 100644 index 000000000000..1dae1119dc24 --- /dev/null +++ b/lib/node_modules/@stdlib/symbol/match/docs/types/index.d.ts @@ -0,0 +1,31 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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 + +// EXPORTS // + +/** +* Match symbol. +* +* ## Notes +* +* - This symbol specifies the matching of a regular expression against a string. Used by String.prototype.match(). +* - The symbol is only supported in ES6/ES2015+ environments. For non-supporting environments, the value is `null`. +*/ +export = Symbol.match; diff --git a/lib/node_modules/@stdlib/symbol/match/docs/types/test.ts b/lib/node_modules/@stdlib/symbol/match/docs/types/test.ts new file mode 100644 index 000000000000..e53ff35b7cac --- /dev/null +++ b/lib/node_modules/@stdlib/symbol/match/docs/types/test.ts @@ -0,0 +1,29 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 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 @typescript-eslint/no-unused-expressions */ + +import IsConcatSpreadable = require( './index' ); + + +// TESTS // + +// The exported value is the `isConcatSpreadable` symbol... +{ + IsConcatSpreadable; +} diff --git a/lib/node_modules/@stdlib/symbol/match/examples/index.js b/lib/node_modules/@stdlib/symbol/match/examples/index.js new file mode 100644 index 000000000000..d012a237fc83 --- /dev/null +++ b/lib/node_modules/@stdlib/symbol/match/examples/index.js @@ -0,0 +1,34 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +var MatchSymbol = require( './../lib' ); + +var re = /foo/; +var str = 'football'; + +var v = str.match( re ); +console.log( v ); +// => [ 'foo', index: 0, input: 'football', groups: undefined ] + +// Disable default match behavior: +re[ MatchSymbol ] = false; +v = '/foo/'.startsWith( re ); +console.log( v ); +// => true diff --git a/lib/node_modules/@stdlib/symbol/match/lib/index.js b/lib/node_modules/@stdlib/symbol/match/lib/index.js new file mode 100644 index 000000000000..9d286108cfb1 --- /dev/null +++ b/lib/node_modules/@stdlib/symbol/match/lib/index.js @@ -0,0 +1,43 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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'; + +/** +* Match symbol. +* +* @module @stdlib/symbol/match +* +* @example +* var MatchSymbol = require( '@stdlib/symbol/match' ); +* +* var re = /foo/; +* var str = 'football'; +* +* var v = str.match( re ); +* // returns [ 'foo', index: 0, input: 'football', groups: undefined ] +*/ + +// MAIN // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/symbol/match/lib/main.js b/lib/node_modules/@stdlib/symbol/match/lib/main.js new file mode 100644 index 000000000000..e53de6fde133 --- /dev/null +++ b/lib/node_modules/@stdlib/symbol/match/lib/main.js @@ -0,0 +1,47 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 hasMatchSymbolSupport = require( '@stdlib/assert/has-match-symbol-support' ); // eslint-disable-line id-length + + +// MAIN // + +/** +* Match symbol. +* +* @name MatchSymbol +* @constant +* @type {(symbol|null)} +* +* @example +* var re = /foo/; +* var str = 'football'; +* +* var v = str.match( re ); +* // returns [ 'foo', index: 0, input: 'football', groups: undefined ] +*/ +var MatchSymbol = ( hasMatchSymbolSupport() ) ? Symbol.match : null; // eslint-disable-line max-len + + +// EXPORTS // + +module.exports = MatchSymbol; diff --git a/lib/node_modules/@stdlib/symbol/match/package.json b/lib/node_modules/@stdlib/symbol/match/package.json new file mode 100644 index 000000000000..efd785cb4590 --- /dev/null +++ b/lib/node_modules/@stdlib/symbol/match/package.json @@ -0,0 +1,59 @@ +{ + "name": "@stdlib/symbol/match", + "version": "0.0.0", + "description": "Match symbol.", + "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": { + "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", + "symbol", + "sym", + "match", + "regex", + "regexp", + "string" + ] +} diff --git a/lib/node_modules/@stdlib/symbol/match/test/test.js b/lib/node_modules/@stdlib/symbol/match/test/test.js new file mode 100644 index 000000000000..b472c68e617c --- /dev/null +++ b/lib/node_modules/@stdlib/symbol/match/test/test.js @@ -0,0 +1,52 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 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 hasMatchSymbolSupport = require( '@stdlib/assert/has-match-symbol-support' ); // eslint-disable-line id-length +var isSymbol = require( '@stdlib/assert/is-symbol' ); +var Sym = require( './../lib' ); + + +// VARIABLES // + +var opts = { + 'skip': !hasMatchSymbolSupport() +}; + + +// TESTS // + +tape( 'main export is a symbol in supporting environments (ES6/2015+) or otherwise null', function test( t ) { + t.ok( true, __filename ); + if ( opts.skip ) { + t.strictEqual( Sym, null, 'main export is null' ); + } else { + t.strictEqual( typeof Sym, 'symbol', 'main export is a symbol' ); + t.strictEqual( isSymbol( Sym ), true, 'main export is a symbol' ); + } + t.end(); +}); + +tape( 'the main export is an alias for `Symbol.match`', opts, function test( t ) { + t.strictEqual( Sym, Symbol.match, 'returns expected value' ); + t.end(); +}); From c0500a86fb3ae81981cce9b2d3e873559ce47172 Mon Sep 17 00:00:00 2001 From: kaushal-kumar-it Date: Sun, 16 Nov 2025 13:30:57 +0530 Subject: [PATCH 02/14] feat: add symbol/match package --- .../@stdlib/symbol/match/README.md | 5 +++-- .../@stdlib/symbol/match/examples/index.js | 5 +++-- .../@stdlib/symbol/match/lib/index.js | 18 ++++++++++++++---- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/symbol/match/README.md b/lib/node_modules/@stdlib/symbol/match/README.md index 9b8d59e96624..96bc865243d3 100644 --- a/lib/node_modules/@stdlib/symbol/match/README.md +++ b/lib/node_modules/@stdlib/symbol/match/README.md @@ -74,6 +74,7 @@ var s = typeof MatchSymbol; ```javascript +var startsWith = require( '@stdlib/string/starts-with' ); var MatchSymbol = require( '@stdlib/symbol/match' ); var re = /foo/; @@ -81,11 +82,11 @@ var str = 'football'; var v = str.match( re ); console.log( v ); -// => [ 'foo', index: 0, input: 'football', groups: undefined ] +// => [ 'foo' ] // Disable default match behavior: re[ MatchSymbol ] = false; -v = '/foo/'.startsWith( re ); +v = startsWith( '/foo/', re ); console.log( v ); // => true ``` diff --git a/lib/node_modules/@stdlib/symbol/match/examples/index.js b/lib/node_modules/@stdlib/symbol/match/examples/index.js index d012a237fc83..481d98e81bc6 100644 --- a/lib/node_modules/@stdlib/symbol/match/examples/index.js +++ b/lib/node_modules/@stdlib/symbol/match/examples/index.js @@ -18,6 +18,7 @@ 'use strict'; +var startsWith = require( '@stdlib/string/starts-with' ); var MatchSymbol = require( './../lib' ); var re = /foo/; @@ -25,10 +26,10 @@ var str = 'football'; var v = str.match( re ); console.log( v ); -// => [ 'foo', index: 0, input: 'football', groups: undefined ] +// => [ 'foo' ] // Disable default match behavior: re[ MatchSymbol ] = false; -v = '/foo/'.startsWith( re ); +v = startsWith( '/foo/', re ); console.log( v ); // => true diff --git a/lib/node_modules/@stdlib/symbol/match/lib/index.js b/lib/node_modules/@stdlib/symbol/match/lib/index.js index 9d286108cfb1..5c561a27777b 100644 --- a/lib/node_modules/@stdlib/symbol/match/lib/index.js +++ b/lib/node_modules/@stdlib/symbol/match/lib/index.js @@ -26,11 +26,21 @@ * @example * var MatchSymbol = require( '@stdlib/symbol/match' ); * -* var re = /foo/; -* var str = 'football'; +* var obj = { +* 'toString': function toString() { +* return 'foo'; +* } +* }; +* +* obj[ MatchSymbol ] = function match( str ) { +* if ( str.indexOf( this.toString() ) !== -1 ) { +* return [ this.toString() ]; +* } +* return null; +* }; * -* var v = str.match( re ); -* // returns [ 'foo', index: 0, input: 'football', groups: undefined ] +* var str = 'football'; +* var v = str.match( obj ); */ // MAIN // From d697130c53603d4f657f80de821665816a46490d Mon Sep 17 00:00:00 2001 From: kaushal-kumar-it Date: Sun, 16 Nov 2025 14:20:59 +0530 Subject: [PATCH 03/14] feat: add symbol/match package --- .../@stdlib/symbol/match/README.md | 27 +++++++++++++------ .../@stdlib/symbol/match/examples/index.js | 27 +++++++++++++------ 2 files changed, 38 insertions(+), 16 deletions(-) diff --git a/lib/node_modules/@stdlib/symbol/match/README.md b/lib/node_modules/@stdlib/symbol/match/README.md index 96bc865243d3..219e3847eeff 100644 --- a/lib/node_modules/@stdlib/symbol/match/README.md +++ b/lib/node_modules/@stdlib/symbol/match/README.md @@ -74,21 +74,32 @@ var s = typeof MatchSymbol; ```javascript -var startsWith = require( '@stdlib/string/starts-with' ); +var defineProperty = require( '@stdlib/utils/define-property' ); var MatchSymbol = require( '@stdlib/symbol/match' ); +var obj = {}; var re = /foo/; -var str = 'football'; -var v = str.match( re ); +// Define a custom match behavior: +function customMatch( str ) { + return [ 'custom', 'match', 'result' ]; +} + +defineProperty( obj, MatchSymbol, { + 'configurable': false, + 'enumerable': false, + 'writable': false, + 'value': customMatch +}); + +var v = 'foobar'.match( obj ); console.log( v ); -// => [ 'foo' ] +// => [ 'custom', 'match', 'result' ] -// Disable default match behavior: -re[ MatchSymbol ] = false; -v = startsWith( '/foo/', re ); +// Default match behavior: +v = 'football'.match( re ); console.log( v ); -// => true +// => [ 'foo' ] ``` diff --git a/lib/node_modules/@stdlib/symbol/match/examples/index.js b/lib/node_modules/@stdlib/symbol/match/examples/index.js index 481d98e81bc6..d0f147fc59c0 100644 --- a/lib/node_modules/@stdlib/symbol/match/examples/index.js +++ b/lib/node_modules/@stdlib/symbol/match/examples/index.js @@ -18,18 +18,29 @@ 'use strict'; -var startsWith = require( '@stdlib/string/starts-with' ); +var defineProperty = require( '@stdlib/utils/define-property' ); var MatchSymbol = require( './../lib' ); +var obj = {}; var re = /foo/; -var str = 'football'; -var v = str.match( re ); +// Define a custom match behavior: +function customMatch( str ) { + return [ 'custom', 'match', 'result' ]; +} + +defineProperty( obj, MatchSymbol, { + 'configurable': false, + 'enumerable': false, + 'writable': false, + 'value': customMatch +}); + +var v = 'foobar'.match( obj ); console.log( v ); -// => [ 'foo' ] +// => [ 'custom', 'match', 'result' ] -// Disable default match behavior: -re[ MatchSymbol ] = false; -v = startsWith( '/foo/', re ); +// Default match behavior: +v = 'football'.match( re ); console.log( v ); -// => true +// => [ 'foo' ] From 53451cd30b32a31b0ac5e65e05075b647c7d7f46 Mon Sep 17 00:00:00 2001 From: kaushal-kumar-it Date: Sun, 16 Nov 2025 14:25:20 +0530 Subject: [PATCH 04/14] Fix symbol/match examples and use JSON.stringify for array output --- lib/node_modules/@stdlib/symbol/match/README.md | 4 ++-- lib/node_modules/@stdlib/symbol/match/examples/index.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/symbol/match/README.md b/lib/node_modules/@stdlib/symbol/match/README.md index 219e3847eeff..84fe34be3934 100644 --- a/lib/node_modules/@stdlib/symbol/match/README.md +++ b/lib/node_modules/@stdlib/symbol/match/README.md @@ -98,8 +98,8 @@ console.log( v ); // Default match behavior: v = 'football'.match( re ); -console.log( v ); -// => [ 'foo' ] +console.log( JSON.stringify( v ) ); +// => '["foo"]' ``` diff --git a/lib/node_modules/@stdlib/symbol/match/examples/index.js b/lib/node_modules/@stdlib/symbol/match/examples/index.js index d0f147fc59c0..eeda1c5c393d 100644 --- a/lib/node_modules/@stdlib/symbol/match/examples/index.js +++ b/lib/node_modules/@stdlib/symbol/match/examples/index.js @@ -42,5 +42,5 @@ console.log( v ); // Default match behavior: v = 'football'.match( re ); -console.log( v ); -// => [ 'foo' ] +console.log( JSON.stringify( v ) ); +// => '["foo"]' From 8dc8422f4be5d1cae4bcf8322adb64cd3be8beb3 Mon Sep 17 00:00:00 2001 From: kaushal-kumar-it Date: Sun, 16 Nov 2025 14:44:04 +0530 Subject: [PATCH 05/14] Fix symbol/match examples and use JSON.stringify for array output --- lib/node_modules/@stdlib/symbol/match/lib/main.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/symbol/match/lib/main.js b/lib/node_modules/@stdlib/symbol/match/lib/main.js index e53de6fde133..769bc6235474 100644 --- a/lib/node_modules/@stdlib/symbol/match/lib/main.js +++ b/lib/node_modules/@stdlib/symbol/match/lib/main.js @@ -20,7 +20,7 @@ // MODULES // -var hasMatchSymbolSupport = require( '@stdlib/assert/has-match-symbol-support' ); // eslint-disable-line id-length +var hasMatchSymbolSupport = require( '@stdlib/assert/has-match-symbol-support' ); // MAIN // @@ -37,9 +37,9 @@ var hasMatchSymbolSupport = require( '@stdlib/assert/has-match-symbol-support' ) * var str = 'football'; * * var v = str.match( re ); -* // returns [ 'foo', index: 0, input: 'football', groups: undefined ] +* // returns */ -var MatchSymbol = ( hasMatchSymbolSupport() ) ? Symbol.match : null; // eslint-disable-line max-len +var MatchSymbol = ( hasMatchSymbolSupport() ) ? Symbol.match : null; // EXPORTS // From 17c22fd8407bcc1af8ebb717bc58768ad1e05aba Mon Sep 17 00:00:00 2001 From: kaushal-kumar-it Date: Sun, 16 Nov 2025 14:48:41 +0530 Subject: [PATCH 06/14] Remove unused parameter in customMatch function --- lib/node_modules/@stdlib/symbol/match/README.md | 2 +- lib/node_modules/@stdlib/symbol/match/examples/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/symbol/match/README.md b/lib/node_modules/@stdlib/symbol/match/README.md index 84fe34be3934..2a74150f955c 100644 --- a/lib/node_modules/@stdlib/symbol/match/README.md +++ b/lib/node_modules/@stdlib/symbol/match/README.md @@ -81,7 +81,7 @@ var obj = {}; var re = /foo/; // Define a custom match behavior: -function customMatch( str ) { +function customMatch() { return [ 'custom', 'match', 'result' ]; } diff --git a/lib/node_modules/@stdlib/symbol/match/examples/index.js b/lib/node_modules/@stdlib/symbol/match/examples/index.js index eeda1c5c393d..7ec6ed386f5a 100644 --- a/lib/node_modules/@stdlib/symbol/match/examples/index.js +++ b/lib/node_modules/@stdlib/symbol/match/examples/index.js @@ -25,7 +25,7 @@ var obj = {}; var re = /foo/; // Define a custom match behavior: -function customMatch( str ) { +function customMatch() { return [ 'custom', 'match', 'result' ]; } From 871e4bc6d570a26a281d27ee0605ffea63ee4ebe Mon Sep 17 00:00:00 2001 From: kaushal-kumar-it Date: Sun, 16 Nov 2025 14:51:14 +0530 Subject: [PATCH 07/14] Remove unused parameter in customMatch function --- lib/node_modules/@stdlib/symbol/match/test/test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/symbol/match/test/test.js b/lib/node_modules/@stdlib/symbol/match/test/test.js index b472c68e617c..38fb2e89930a 100644 --- a/lib/node_modules/@stdlib/symbol/match/test/test.js +++ b/lib/node_modules/@stdlib/symbol/match/test/test.js @@ -21,7 +21,7 @@ // MODULES // var tape = require( 'tape' ); -var hasMatchSymbolSupport = require( '@stdlib/assert/has-match-symbol-support' ); // eslint-disable-line id-length +var hasMatchSymbolSupport = require( '@stdlib/assert/has-match-symbol-support' ); var isSymbol = require( '@stdlib/assert/is-symbol' ); var Sym = require( './../lib' ); From 854a7ae636de86235074b09c09d8f7f2c6eb0c9b Mon Sep 17 00:00:00 2001 From: kaushal-kumar-it Date: Tue, 18 Nov 2025 14:17:18 +0530 Subject: [PATCH 08/14] fixed Copy-paste mistake --- lib/node_modules/@stdlib/symbol/match/docs/types/test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/symbol/match/docs/types/test.ts b/lib/node_modules/@stdlib/symbol/match/docs/types/test.ts index e53ff35b7cac..80fde66ae03d 100644 --- a/lib/node_modules/@stdlib/symbol/match/docs/types/test.ts +++ b/lib/node_modules/@stdlib/symbol/match/docs/types/test.ts @@ -18,12 +18,12 @@ /* eslint-disable @typescript-eslint/no-unused-expressions */ -import IsConcatSpreadable = require( './index' ); +import Match = require( './index' ); // TESTS // -// The exported value is the `isConcatSpreadable` symbol... +// The exported value is the `match` symbol... { - IsConcatSpreadable; + Match; } From 35cc300587bfe7abe4729a5b8f0c236edb662cd5 Mon Sep 17 00:00:00 2001 From: kaushal-kumar-it Date: Tue, 18 Nov 2025 14:35:14 +0530 Subject: [PATCH 09/14] corrected notes of readme file --- .../@stdlib/symbol/match/README.md | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/symbol/match/README.md b/lib/node_modules/@stdlib/symbol/match/README.md index 2a74150f955c..d6da8fc4a927 100644 --- a/lib/node_modules/@stdlib/symbol/match/README.md +++ b/lib/node_modules/@stdlib/symbol/match/README.md @@ -20,7 +20,7 @@ limitations under the License. # MatchSymbol -> [Symbol][mdn-symbol] which specifies the matching of a regular expression against a string. +> [Symbol][mdn-symbol] which specifies whether an object should be treated as a regular expression. @@ -42,7 +42,7 @@ var MatchSymbol = require( '@stdlib/symbol/match' ); #### MatchSymbol -[`Symbol`][mdn-symbol] which specifies the matching of a regular expression against a string. Used by `String.prototype.match()`. +[`Symbol`][mdn-symbol] which specifies whether an object should be treated as a regular expression. ```javascript var s = typeof MatchSymbol; @@ -61,6 +61,14 @@ var s = typeof MatchSymbol; - The [symbol][mdn-symbol] is only supported in environments which support [symbols][mdn-symbol]. In non-supporting environments, the value is `null`. +- `String.prototype.match()` uses the following algorithm to determine how to match a string: + + - If the first argument is an object with a `[MatchSymbol]()` method, `String.prototype.match()` calls that method with the string as the first argument and returns the result. + - Otherwise, if the first argument is a [regular expression][mdn-regexp], `String.prototype.match()` performs a standard regular expression match. + - Otherwise, `String.prototype.match()` coerces the first argument to a string and searches for that substring. + +- The symbol is also used to identify whether an object should be treated as a [regular expression][mdn-regexp]. For example, the methods `String.prototype.startsWith()`, `String.prototype.endsWith()`, and `String.prototype.includes()` check if their first argument is a regular expression and will throw a `TypeError` if it is. By setting `[MatchSymbol]` to `false` (or a [falsy][mdn-falsy] value except `undefined`), an object can indicate that it should not be treated as a regular expression object. + @@ -98,7 +106,7 @@ console.log( v ); // Default match behavior: v = 'football'.match( re ); -console.log( JSON.stringify( v ) ); +console.log( v ); // => '["foo"]' ``` @@ -128,6 +136,10 @@ console.log( JSON.stringify( v ) ); [mdn-symbol]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol +[mdn-regexp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp + +[mdn-falsy]: https://developer.mozilla.org/en-US/docs/Glossary/Falsy + From e6235db37c52b3f1ad89eabf25efe4cab6c429f6 Mon Sep 17 00:00:00 2001 From: kaushal-kumar-it Date: Tue, 18 Nov 2025 14:43:27 +0530 Subject: [PATCH 10/14] corrected notes of readme file --- lib/node_modules/@stdlib/symbol/match/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/symbol/match/README.md b/lib/node_modules/@stdlib/symbol/match/README.md index d6da8fc4a927..2112abf68396 100644 --- a/lib/node_modules/@stdlib/symbol/match/README.md +++ b/lib/node_modules/@stdlib/symbol/match/README.md @@ -107,7 +107,7 @@ console.log( v ); // Default match behavior: v = 'football'.match( re ); console.log( v ); -// => '["foo"]' +// => [ 'foo' ] ``` From cf3dac8bab3b5dfa134c94f7a9529706a5c88730 Mon Sep 17 00:00:00 2001 From: kaushal-kumar-it Date: Tue, 18 Nov 2025 14:48:19 +0530 Subject: [PATCH 11/14] corrected index.d.ts file --- lib/node_modules/@stdlib/symbol/match/docs/types/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/symbol/match/docs/types/index.d.ts b/lib/node_modules/@stdlib/symbol/match/docs/types/index.d.ts index 1dae1119dc24..39baabe6cd1c 100644 --- a/lib/node_modules/@stdlib/symbol/match/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/symbol/match/docs/types/index.d.ts @@ -25,7 +25,7 @@ * * ## Notes * -* - This symbol specifies the matching of a regular expression against a string. Used by String.prototype.match(). +* - This symbol is used as a method by `String.prototype.match()` to match an input string against the current object and to determine whether an object should be treated as a regular expression. * - The symbol is only supported in ES6/ES2015+ environments. For non-supporting environments, the value is `null`. */ export = Symbol.match; From 5e9fb1543f96e33541c7e9ad8fdfa35ec117a5a7 Mon Sep 17 00:00:00 2001 From: kaushal-kumar-it Date: Tue, 18 Nov 2025 14:54:06 +0530 Subject: [PATCH 12/14] fixed json and wrong example --- .../@stdlib/symbol/match/examples/index.js | 4 ++-- lib/node_modules/@stdlib/symbol/match/lib/main.js | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/node_modules/@stdlib/symbol/match/examples/index.js b/lib/node_modules/@stdlib/symbol/match/examples/index.js index 7ec6ed386f5a..a63692fb6cd1 100644 --- a/lib/node_modules/@stdlib/symbol/match/examples/index.js +++ b/lib/node_modules/@stdlib/symbol/match/examples/index.js @@ -42,5 +42,5 @@ console.log( v ); // Default match behavior: v = 'football'.match( re ); -console.log( JSON.stringify( v ) ); -// => '["foo"]' +console.log( v ); +// => [ 'foo' ] \ No newline at end of file diff --git a/lib/node_modules/@stdlib/symbol/match/lib/main.js b/lib/node_modules/@stdlib/symbol/match/lib/main.js index 769bc6235474..3536e59453dc 100644 --- a/lib/node_modules/@stdlib/symbol/match/lib/main.js +++ b/lib/node_modules/@stdlib/symbol/match/lib/main.js @@ -33,13 +33,13 @@ var hasMatchSymbolSupport = require( '@stdlib/assert/has-match-symbol-support' ) * @type {(symbol|null)} * * @example -* var re = /foo/; -* var str = 'football'; +* var obj = {}; * -* var v = str.match( re ); -* // returns +* obj[ MatchSymbol ] = function match( str ) { +* return [ 'beep' ]; +* }; */ -var MatchSymbol = ( hasMatchSymbolSupport() ) ? Symbol.match : null; +var MatchSymbol = ( hasMatchSymbolSupport() ) ? Symbol.match : null; // eslint-disable-line max-len // EXPORTS // From 7546e2812c7309bd84341540cc5325b2a34e7833 Mon Sep 17 00:00:00 2001 From: kaushal-kumar-it Date: Tue, 18 Nov 2025 14:57:30 +0530 Subject: [PATCH 13/14] fixed repl.txt --- lib/node_modules/@stdlib/symbol/match/docs/repl.txt | 5 +++-- lib/node_modules/@stdlib/symbol/match/lib/main.js | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/symbol/match/docs/repl.txt b/lib/node_modules/@stdlib/symbol/match/docs/repl.txt index 1ddc7082ebf9..a55f31ea3534 100644 --- a/lib/node_modules/@stdlib/symbol/match/docs/repl.txt +++ b/lib/node_modules/@stdlib/symbol/match/docs/repl.txt @@ -2,8 +2,9 @@ {{alias}} Match symbol. - This symbol specifies the matching of a regular expression against a string. - It is used by String.prototype.match(). + This symbol is used as a method by String.prototype.match() to match an + input string against the current object and to determine whether an object + should be treated as a regular expression. The symbol is only supported in ES6/ES2015+ environments. For non-supporting environments, the value is `null`. diff --git a/lib/node_modules/@stdlib/symbol/match/lib/main.js b/lib/node_modules/@stdlib/symbol/match/lib/main.js index 3536e59453dc..9b534aead438 100644 --- a/lib/node_modules/@stdlib/symbol/match/lib/main.js +++ b/lib/node_modules/@stdlib/symbol/match/lib/main.js @@ -39,7 +39,7 @@ var hasMatchSymbolSupport = require( '@stdlib/assert/has-match-symbol-support' ) * return [ 'beep' ]; * }; */ -var MatchSymbol = ( hasMatchSymbolSupport() ) ? Symbol.match : null; // eslint-disable-line max-len +var MatchSymbol = ( hasMatchSymbolSupport() ) ? Symbol.match : null; // EXPORTS // From 35fc564daddbeaf8d1ce42a7d86295d05f40ec7c Mon Sep 17 00:00:00 2001 From: kaushal-kumar-it Date: Tue, 18 Nov 2025 15:00:16 +0530 Subject: [PATCH 14/14] fixed lint eror --- lib/node_modules/@stdlib/symbol/match/examples/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/symbol/match/examples/index.js b/lib/node_modules/@stdlib/symbol/match/examples/index.js index a63692fb6cd1..b27a8dcc8f2d 100644 --- a/lib/node_modules/@stdlib/symbol/match/examples/index.js +++ b/lib/node_modules/@stdlib/symbol/match/examples/index.js @@ -43,4 +43,4 @@ console.log( v ); // Default match behavior: v = 'football'.match( re ); console.log( v ); -// => [ 'foo' ] \ No newline at end of file +// => [ 'foo' ]