Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lib/node_modules/@stdlib/symbol/docs/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import IsConcatSpreadableSymbol = require( '@stdlib/symbol/is-concat-spreadable'
import IteratorSymbol = require( '@stdlib/symbol/iterator' );
import ReplaceSymbol = require( '@stdlib/symbol/replace' );
import ToPrimitiveSymbol = require( '@stdlib/symbol/to-primitive' );
import ToStringTagSymbol = require( '@stdlib/symbol/to-string-tag' );

/**
* Interface describing the `symbol` namespace.
Expand Down Expand Up @@ -103,6 +104,16 @@ interface Namespace {
* - The symbol is only supported in ES6/ES2015+ environments. For non-supporting environments, the value is `null`.
*/
ToPrimitiveSymbol: typeof ToPrimitiveSymbol;

/**
* To string tag symbol.
*
* ## Notes
*
* - This symbol is used to customize the default string description of an object.
* - The symbol is only supported in ES6/ES2015+ environments. For non-supporting environments, the value is `null`.
*/
ToStringTagSymbol: typeof ToStringTagSymbol;
}

/**
Expand Down
9 changes: 9 additions & 0 deletions lib/node_modules/@stdlib/symbol/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,15 @@ setReadOnly( ns, 'ReplaceSymbol', require( '@stdlib/symbol/replace' ) );
*/
setReadOnly( ns, 'ToPrimitiveSymbol', require( '@stdlib/symbol/to-primitive' ) );

/**
* @name ToStringTagSymbol
* @memberof ns
* @readonly
* @type {(symbol|null)}
* @see {@link module:@stdlib/symbol/to-string-tag}
*/
setReadOnly( ns, 'ToStringTagSymbol', require( '@stdlib/symbol/to-string-tag' ) );


// EXPORTS //

Expand Down
103 changes: 103 additions & 0 deletions lib/node_modules/@stdlib/symbol/to-string-tag/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<!--

@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.

-->

# ToStringTagSymbol

> To string tag [symbol][mdn-symbol] which is used to customize the default string description of an object.

<section class="intro">

</section>

<!-- /.intro -->

<section class="usage">

## Usage

```javascript
var ToStringTagSymbol = require( '@stdlib/symbol/to-string-tag' );
```

#### ToStringTagSymbol

To string tag [`symbol`][mdn-symbol] which is used to customize the default string description of an object.

```javascript
var s = typeof ToStringTagSymbol;
// e.g., returns 'symbol'
```

</section>

<!-- /.usage -->

<section class="notes">

## Notes

- The [symbol][mdn-symbol] is only supported in environments which support [symbols][mdn-symbol]. In non-supporting environments, the value is `null`.
- When an object has a property keyed by `[ToStringTagSymbol]` whose value is a string, that string is used as the "tag" in the object's default string description; e.g., `Object.prototype.toString.call( obj )` returns `'[object <tag>]'`.

</section>

<!-- /.notes -->

<section class="examples">

## Examples

<!-- eslint no-undef: "error" -->

```javascript
var ToStringTagSymbol = require( '@stdlib/symbol/to-string-tag' );

var obj = {};

obj[ ToStringTagSymbol ] = 'MyObject';

var str = Object.prototype.toString.call( obj );
console.log( str );
// => '[object MyObject]'
```

</section>

<!-- /.examples -->

<section class="references">

</section>

<!-- /.references -->

<section class="related">

</section>

<!-- /.related -->

<section class="links">

[mdn-symbol]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol

</section>

<!-- /.links -->
18 changes: 18 additions & 0 deletions lib/node_modules/@stdlib/symbol/to-string-tag/docs/repl.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

{{alias}}
To string tag symbol.

This symbol is used to customize the default string description of an
object, as returned by `Object.prototype.toString`.

The symbol is only supported in ES6/ES2015+ environments. For non-supporting
environments, the value is `null`.

Examples
--------
> var s = {{alias}}
e.g., <symbol>

See Also
--------

Original file line number Diff line number Diff line change
@@ -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 //

/**
* To string tag symbol.
*
* ## Notes
*
* - This symbol is used to customize the default string description of an object.
* - The symbol is only supported in ES6/ES2015+ environments. For non-supporting environments, the value is `null`.
*/
export = Symbol.toStringTag;
29 changes: 29 additions & 0 deletions lib/node_modules/@stdlib/symbol/to-string-tag/docs/types/test.ts
Original file line number Diff line number Diff line change
@@ -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 ToStringTag = require( './index' );


// TESTS //

// The exported value is the `toStringTag` symbol...
{
ToStringTag;
}
32 changes: 32 additions & 0 deletions lib/node_modules/@stdlib/symbol/to-string-tag/examples/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* @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 ToStringTagSymbol = require( './../lib' );

// Create an object:
var obj = {};

// Assign a custom string tag:
obj[ ToStringTagSymbol ] = 'MyObject';

// Retrieve the object's default string description:
var str = Object.prototype.toString.call( obj );
console.log( str );
// => '[object MyObject]'
40 changes: 40 additions & 0 deletions lib/node_modules/@stdlib/symbol/to-string-tag/lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* @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';

/**
* Symbol used to customize the default string description of an object.
*
* @module @stdlib/symbol/to-string-tag
*
* @example
* var ToStringTagSymbol = require( '@stdlib/symbol/to-string-tag' );
*
* var o = {};
* o[ ToStringTagSymbol ] = 'Foo';
*/

// MAIN //

var main = require( './main.js' );


// EXPORTS //

module.exports = main;
46 changes: 46 additions & 0 deletions lib/node_modules/@stdlib/symbol/to-string-tag/lib/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* @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 hasToStringTagSupport = require( '@stdlib/assert/has-tostringtag-support' );
var Symbol = require( '@stdlib/symbol/ctor' );


// MAIN //

/**
* To string tag symbol.
*
* @name ToStringTagSymbol
* @constant
* @type {(symbol|null)}
*
* @example
* var o = {};
*
* o[ ToStringTagSymbol ] = 'Foo';
*/
var ToStringTagSymbol = ( hasToStringTagSupport() ) ? Symbol.toStringTag : null;


// EXPORTS //

module.exports = ToStringTagSymbol;
Loading