Skip to content

Conversation

@kaushal-kumar-it
Copy link
Contributor

@kaushal-kumar-it kaushal-kumar-it commented Nov 16, 2025

Resolves #8478

Description

This pull request adds the new symbol/match package as described in RFC #8478.

The implementation is based on the structure and conventions of the existing symbol packages (e.g., symbol/iterator, symbol/has-instance, etc.). The package exports Symbol.match when available, updates documentation and examples accordingly, and includes the required copyright updates for 2025.

Related Issues

Questions

No.

Other

No additional notes.

Checklist

AI Assistance

  • Yes
  • No

@stdlib-bot stdlib-bot added the Good First PR A pull request resolving a Good First Issue. label Nov 16, 2025
@stdlib-bot
Copy link
Contributor

Hello! Thank you for your contribution to stdlib.

We noticed that the contributing guidelines acknowledgment is missing from your pull request. Here's what you need to do:

  1. Please read our contributing guidelines.

  2. Update your pull request description to include this checked box:

    - [x] Read, understood, and followed the [contributing guidelines](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md)

This acknowledgment confirms that you've read the guidelines, which include:

  • The developer's certificate of origin
  • Your agreement to license your contributions under the project's terms

We can't review or accept contributions without this acknowledgment.

Thank you for your understanding and cooperation. We look forward to reviewing your contribution!

@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Nov 16, 2025
@stdlib-bot
Copy link
Contributor

stdlib-bot commented Nov 16, 2025

Coverage Report

Package Statements Branches Functions Lines
symbol/match $\color{green}100/100$
$color{green}+100.00%$
$\color{red}2/3$
$color{green}+66.67%$
$\color{green}0/0$
$color{green}+100.00%$
$\color{green}100/100$
$color{green}+100.00%$

The above coverage report was generated for the changes in this PR.

@kgryte kgryte changed the title feat: add symbol/match package feat: add symbol/match Nov 18, 2025
@kgryte kgryte added Feature Issue or pull request for adding a new feature. and removed Needs Review A pull request which needs code review. labels Nov 18, 2025

# MatchSymbol

> [Symbol][mdn-symbol] which specifies the matching of a regular expression against a string.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
> [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.


#### MatchSymbol

[`Symbol`][mdn-symbol] which specifies the matching of a regular expression against a string. Used by `String.prototype.match()`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[`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.

## Notes

- The [symbol][mdn-symbol] is only supported in environments which support [symbols][mdn-symbol]. In non-supporting environments, the value is `null`.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Describe how MatchSymbol is used here. 1) As a method used by String.prototype.match to match an input string against the current object. This method is provided a single argument: a string. 2) To determine whether an object should be treated as a regular expression.

This is discussed in more depth on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/match


// Default match behavior:
v = 'football'.match( re );
console.log( JSON.stringify( v ) );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need JSON.stringify.

{{alias}}
Match symbol.

This symbol specifies the matching of a regular expression against a string.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be updated once the README is updated.

*
* ## Notes
*
* - This symbol specifies the matching of a regular expression against a string. Used by String.prototype.match().
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be updated once README is updated.


/* eslint-disable @typescript-eslint/no-unused-expressions */

import IsConcatSpreadable = require( './index' );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy-paste mistake.


// Default match behavior:
v = 'football'.match( re );
console.log( JSON.stringify( v ) );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No JSON.stringify.

* var re = /foo/;
* var str = 'football';
*
* var v = str.match( re );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example doesn't actually demonstrate symbol.match usage.

Copy link
Member

@kgryte kgryte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left initial comments.

@kgryte kgryte added the Needs Changes Pull request which needs changes before being merged. label Nov 18, 2025
@kaushal-kumar-it
Copy link
Contributor Author

@kgryte All requested changes have been applied. Kindly review when you get a chance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature Issue or pull request for adding a new feature. Good First PR A pull request resolving a Good First Issue. Needs Changes Pull request which needs changes before being merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RFC]: add symbol/match

3 participants