es-set-tostringtag <sup>Version Badge</sup>

github actions coverage License Downloads

npm badge

A helper to optimistically set Symbol.toStringTag, when possible.

Example

Most common usage:

var assert = require('assert');
var setToStringTag = require('es-set-tostringtag');

var obj = {};

assert.equal(Object.prototype.toString.call(obj), '[object Object]');

setToStringTag(obj, 'tagged!');

assert.equal(Object.prototype.toString.call(obj), '[object tagged!]');

Options

An optional options argument can be provided as the third argument. The available options are:

force

If the force option is set to true, the toStringTag will be set even if it is already set.

nonConfigurable

If the nonConfigurable option is set to true, the toStringTag will be defined as non-configurable when possible.

Tests

Simply clone the repo, npm install, and run npm test

es-set-tostringtag - Installation

To install es-set-tostringtag via this registry, you'll need to install via the --registry parameter with your package manager.

n

NPM

npm install es-set-tostringtag --registry https://js.registry.sudovanilla.org

Learn more about the --registry parameter.

Yarn

yarn config set registry https://js.registry.sudovanilla.org
yarn install es-set-tostringtag

Learn more about the config option.

PNPM

pnpm install es-set-tostringtag --registry https://js.registry.sudovanilla.org

Learn more about the --registry parameter.

Bun Logo

Bun

bun install es-set-tostringtag --registry https://js.registry.sudovanilla.org

Learn more about the --registry parameter.

Learn more about setting this up in your bunfig.toml configuration.


For Deno, add the following to your .npmrc file in your directory:

registry="https://js.registry.sudovanilla.org"

Then run the deno install command.

es-set-tostringtag - Download

Download Tarball (v2.1.0)

Integrity sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==
SHASUM f31dbbe0c183b00a6d26eb6325c810c0fd18bd4d
Tarball https://js.registry.sudovanilla.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz