Skip to content

Conversation

@adity1raut
Copy link

@adity1raut adity1raut commented Nov 10, 2025

Description

Purpose of this pull request:

This PR adds a new package modeled after existing symbol utilities in the repository, including:

  • symbol/has-instance
  • symbol/iterator
  • symbol/async-iterator
  • symbol/is-concat-spreadable

The new package exports Symbol.match when available in the current environment.

Implementation details:

  • Copied one of the existing symbol packages as a template.
  • Renamed the package directory and files accordingly.
  • Replaced identifiers throughout the package
    (e.g., has-instancematch, HasInstanceSymbolMatchSymbol).
  • Updated the copyright year to 2025.
  • Revised descriptions based on [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/match) for Symbol.match.
  • Updated examples to reflect the symbol’s intended usage.
  • Ran tests, benchmarks, and examples to verify correctness.
  • Checked for any copy-paste errors.

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

This pull request is related to the following issue:

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

No.

Checklist

Please ensure the following tasks are completed before submitting this pull request.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Disclosure

If you answered "yes" to using AI assistance, please provide a short disclosure indicating how you used AI assistance. This helps reviewers determine how much scrutiny to apply when reviewing your contribution. Example disclosures: "This PR was written primarily by Claude Code." or "I consulted ChatGPT to understand the codebase, but the proposed changes were fully authored manually by myself.".

{{TODO: add disclosure if applicable}}


@stdlib-js/reviewers

@stdlib-bot stdlib-bot added First-time Contributor A pull request from a contributor who has never previously committed to the project repository. Needs Review A pull request which needs code review. labels Nov 10, 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
Copy link
Contributor

stdlib-bot commented Nov 10, 2025

Coverage Report

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

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

@stdlib-bot stdlib-bot added the Good First PR A pull request resolving a Good First Issue. label Nov 10, 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!

Signed-off-by: Saloni Tarone <taronesaloni@gamil.com>

---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: passed
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: passed
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: na
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: passed
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: na
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
@adity1raut
Copy link
Author

/cc @kgryte


# MatchSymbol

> Match [symbol][mdn-symbol] which is used to determine if a constructor object recognizes an object as its instance.
Copy link
Member

Choose a reason for hiding this comment

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

Description is incorrect.


#### MatchSymbol

Match [`symbol`][mdn-symbol] which is used to determine if a constructor object recognizes an object as its instance.
Copy link
Member

Choose a reason for hiding this comment

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

Description is incorrect.

Comment on lines +64 to +67
- The `instanceof` operator uses the following algorithm to determine the return value of `object instanceof constructor`:

- If `constructor` has a `[MatchSymbol]()` method, the `instanceof` operator calls the method with `object` as the first argument and returns the result (coerced to a boolean). If `constructor` is not an object or if `constructor[MatchSymbol]` is neither `null`, `undefined`, nor a function, the `instanceof` operator raises an exception.
- Otherwise, if `constructor` does not have a `[MatchSymbol]()` method (i.e., `constructor[MatchSymbol]` is `null` or `undefined`), the `instanceof` operator determines the result using the same algorithm as `Function.prototype[MatchSymbol]()`. If `constructor` is not a function, the `instanceof` operator raises an exception.
Copy link
Member

Choose a reason for hiding this comment

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

This is all incorrect. You need to update to reflect the actual usage of the match symbol.

var isArray = require( '@stdlib/assert/is-array' );
var instanceOf = require( '@stdlib/assert/instance-of' );
var defineProperty = require( '@stdlib/utils/define-property' );
var MatchSymbol = require( '@stdlib/symbol/match' );
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 is not correct. You need to update to reflect the actual use case for the match symbol.

*
* ## Notes
*
* - This symbol is used to determine whether a constructor object recognizes an object as its instance.
Copy link
Member

Choose a reason for hiding this comment

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

Description is incorrect.

var isArray = require( '@stdlib/assert/is-array' );
var instanceOf = require( '@stdlib/assert/instance-of' );
var defineProperty = require( '@stdlib/utils/define-property' );
var MatchSymbol = require( './../lib' );
Copy link
Member

Choose a reason for hiding this comment

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

Example needs updating.

'use strict';

/**
* Symbol used to determine if a constructor object recognizes an object as its instance.
Copy link
Member

Choose a reason for hiding this comment

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

Description is incorrect.


// MODULES //

var matchSymbolSupport = require( '@stdlib/assert/has-has-instance-symbol-support' ); // eslint-disable-line id-length
Copy link
Member

Choose a reason for hiding this comment

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

Import statement is incorrect.

* @type {(symbol|null)}
*
* @example
* var isArray = require( '@stdlib/assert/is-array' );
Copy link
Member

Choose a reason for hiding this comment

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

Example is not correct.

// MODULES //

var tape = require( 'tape' );
var hasMatchSymbolSupport = require( '@stdlib/assert/has-has-instance-symbol-support' ); // eslint-disable-line id-length
Copy link
Member

Choose a reason for hiding this comment

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

Import path is incorrect.

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 Needs Changes Pull request which needs changes before being merged. and removed Needs Review A pull request which needs code review. labels Nov 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

First-time Contributor A pull request from a contributor who has never previously committed to the project repository. 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.

3 participants