-
-
Notifications
You must be signed in to change notification settings - Fork 959
feat: add symbol/match
#8547
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
feat: add symbol/match
#8547
Conversation
|
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:
This acknowledgment confirms that you've read the guidelines, which include:
We can't review or accept contributions without this acknowledgment. Thank you for your understanding and cooperation. We look forward to reviewing your contribution! |
Coverage Report
The above coverage report was generated for the changes in this PR. |
|
|
||
| # MatchSymbol | ||
|
|
||
| > [Symbol][mdn-symbol] which specifies the matching of a regular expression against a string. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| > [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()`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| [`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`. | ||
|
|
There was a problem hiding this comment.
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 ) ); |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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(). |
There was a problem hiding this comment.
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' ); |
There was a problem hiding this comment.
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 ) ); |
There was a problem hiding this comment.
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 ); |
There was a problem hiding this comment.
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.
kgryte
left a comment
There was a problem hiding this 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 All requested changes have been applied. Kindly review when you get a chance. |
Resolves #8478
Description
This pull request adds the new
symbol/matchpackage 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 exportsSymbol.matchwhen available, updates documentation and examples accordingly, and includes the required copyright updates for 2025.Related Issues
symbol/match#8478Questions
No.
Other
No additional notes.
Checklist
AI Assistance