Back
vendored
has-symbols
v1.1.0
MIT

hasSymbols

The published has-symbols package as a vendorable file. Useful when you want the exact symbol support probe locally without keeping the npm dependency.

Why copy this?

This page ships the published has-symbols file in both raw and normalized forms. The value is to keep a tiny, inspectable symbol support probe local instead of carrying another npm dependency.

Native alternative: There is no direct native helper that replaces the package's exact feature probe contract.

Note: Raw and normalized views are both available. Use normalized when you want an ESM and TypeScript-friendly file, and raw when you want the original published package shape.

This copy is your responsibility once you adopt it. It does not automatically receive upstream bug fixes or security updates.

Snippet
Copy-first distribution
Normalized
ESM / TS / normalized
Runtime: node, bun
/**
 * Derived from has-symbols@1.1.0
 * Rule-based normalized variant generated by this repository.
 * Preserve the upstream license and attribution notices when copying this file.
 */
/**
 * Derived from has-symbols@1.1.0
 * Rule-based normalized variant generated by this repository.
 * See THIRD_PARTY_NOTICES.md for upstream license and attribution details.
 */
"use strict";
export default function hasSymbols() {
  if (typeof Symbol !== "function" || typeof Object.getOwnPropertySymbols !== "function") {
    return false;
  }
  if (typeof Symbol.iterator === "symbol") {
    return true;
  }

  var obj = {};
  var sym = Symbol("test");
  var symObj = Object(sym);
  if (typeof sym === "string") {
    return false;
  }

  if (Object.prototype.toString.call(sym) !== "[object Symbol]") {
    return false;
  }
  if (Object.prototype.toString.call(symObj) !== "[object Symbol]") {
    return false;
  }

  var symVal = 42;
  obj[sym] = symVal;
  for (var _ in obj) {
    return false;
  }
  if (typeof Object.keys === "function" && Object.keys(obj).length !== 0) {
    return false;
  }

  if (
    typeof Object.getOwnPropertyNames === "function" &&
    Object.getOwnPropertyNames(obj).length !== 0
  ) {
    return false;
  }

  var syms = Object.getOwnPropertySymbols(obj);
  if (syms.length !== 1 || syms[0] !== sym) {
    return false;
  }

  if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) {
    return false;
  }

  if (typeof Object.getOwnPropertyDescriptor === "function") {
    var descriptor = Object.getOwnPropertyDescriptor(obj, sym);
    if (descriptor.value !== symVal || descriptor.enumerable !== true) {
      return false;
    }
  }

  return true;
}
Variant note: Rule-based normalization for modern TS projects. The goal is easier import and build compatibility, not changed behavior.
Transforms: module.exports-to-export-default, js-extension-to-ts-extension
Validation: This normalized variant is intended to stay oxlint and oxfmt clean in this repo.
Raw
CJS / JS / raw
Runtime: node, bun
'use strict';

module.exports = function hasSymbols() {
  if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; }
  if (typeof Symbol.iterator === 'symbol') { return true; }

  var obj = {};
  var sym = Symbol('test');
  var symObj = Object(sym);
  if (typeof sym === 'string') { return false; }

  if (Object.prototype.toString.call(sym) !== '[object Symbol]') { return false; }
  if (Object.prototype.toString.call(symObj) !== '[object Symbol]') { return false; }

  var symVal = 42;
  obj[sym] = symVal;
  for (var _ in obj) { return false; }
  if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; }

  if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; }

  var syms = Object.getOwnPropertySymbols(obj);
  if (syms.length !== 1 || syms[0] !== sym) { return false; }

  if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; }

  if (typeof Object.getOwnPropertyDescriptor === 'function') {
    var descriptor = Object.getOwnPropertyDescriptor(obj, sym);
    if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; }
  }

  return true;
};
Variant note: Published package file kept as-is for older teams or repos that still prefer the original CommonJS distribution.