Package detail

es-set-tostringtag

es-shims180.8mMIT2.1.0

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

readme

es-set-tostringtag Version Badge

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

changelog

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

v2.1.0 - 2025-01-01

Commits

  • [actions] split out node 10-20, and 20+ ede033c
  • [types] use shared config 28ef164
  • [New] add nonConfigurable option 3bee3f0
  • [Fix] validate boolean option argument 3c8a609
  • [Dev Deps] update @arethetypeswrong/cli, @ljharb/eslint-config, @ljharb/tsconfig, @types/get-intrinsic, @types/tape, auto-changelog, tape 501a969
  • [Tests] add coverage 18af289
  • [readme] document force option bd446a1
  • [Tests] use @arethetypeswrong/cli 7c2c2fa
  • [Tests] replace aud with npm audit 9e372d7
  • [Deps] update get-intrinsic 7df1216
  • [Deps] update hasown 993a7d2
  • [Dev Deps] add missing peer dep 148ed8d

v2.0.3 - 2024-02-20

Commits

  • add types d538513
  • [Deps] update get-intrinsic, has-tostringtag, hasown d129b29
  • [Dev Deps] update aud, npmignore, tape 132ed23
  • [Tests] fix hasOwn require f89c831

v2.0.2 - 2023-10-20

Commits

  • [Refactor] use hasown instead of has 0cc6c4e
  • [Dev Deps] update @ljharb/eslint-config, aud, tape 70e447c
  • [Deps] update get-intrinsic 826aab7

v2.0.1 - 2023-01-05

Fixed

  • [Fix] move has to prod deps #2

Commits

  • [Dev Deps] update @ljharb/eslint-config b9eecd2

v2.0.0 - 2022-12-21

Commits

  • [Tests] refactor tests 168dcfb
  • [Breaking] do not set toStringTag if it is already set 226ab87
  • [New] add force option to set even if already set 1abd4ec

v1.0.0 - 2022-12-21

Commits