package/package.json000644 0000002705 3560116604 011552 0ustar00000000 000000 { "name": "is-symbol", "version": "1.0.2", "description": "Determine if a value is an ES6 Symbol or not.", "main": "index.js", "scripts": { "prepublish": "safe-publish-latest", "pretest": "npm run lint", "tests-only": "node --es-staging --harmony test", "test": "npm run tests-only", "posttest": "npm run security", "coverage": "covert test", "lint": "npm run jscs && npm run eslint", "jscs": "jscs *.js */*.js", "eslint": "eslint *.js */*.js", "security": "nsp check" }, "repository": { "type": "git", "url": "git://github.com/ljharb/is-symbol.git" }, "keywords": [ "symbol", "es6", "is", "Symbol" ], "author": "Jordan Harband", "license": "MIT", "bugs": { "url": "https://github.com/ljharb/is-symbol/issues" }, "dependencies": { "has-symbols": "^1.0.0" }, "devDependencies": { "@ljharb/eslint-config": "^12.2.1", "covert": "^1.1.0", "eslint": "^4.19.1", "jscs": "^3.0.7", "nsp": "^3.2.1", "object-inspect": "^1.6.0", "safe-publish-latest": "^1.1.2", "semver": "^5.5.0", "tape": "^4.9.0" }, "testling": { "files": "test/index.js", "browsers": [ "iexplore/6.0..latest", "firefox/3.0..6.0", "firefox/15.0..latest", "firefox/nightly", "chrome/4.0..10.0", "chrome/20.0..latest", "chrome/canary", "opera/10.0..latest", "opera/next", "safari/4.0..latest", "ipad/6.0..latest", "iphone/6.0..latest", "android-browser/4.2" ] }, "engines": { "node": ">= 0.4" } } package/.editorconfig000644 0000000424 3560116604 011735 0ustar00000000 000000 root = true [*] indent_style = tab; insert_final_newline = true; quote_type = auto; space_after_anonymous_functions = true; space_after_control_statements = true; spaces_around_operators = true; trim_trailing_whitespace = true; spaces_in_brackets = false; end_of_line = lf; package/.eslintrc000644 0000000127 3560116604 011104 0ustar00000000 000000 { "root": true, "extends": "@ljharb", "rules": { "max-statements": [2, 14] } } package/.jscs.json000644 0000010040 3560116604 011166 0ustar00000000 000000 { "es3": true, "additionalRules": [], "requireSemicolons": true, "disallowMultipleSpaces": true, "disallowIdentifierNames": [], "requireCurlyBraces": { "allExcept": [], "keywords": ["if", "else", "for", "while", "do", "try", "catch"] }, "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch", "function"], "disallowSpaceAfterKeywords": [], "disallowSpaceBeforeComma": true, "disallowSpaceAfterComma": false, "disallowSpaceBeforeSemicolon": true, "disallowNodeTypes": [ "DebuggerStatement", "ForInStatement", "LabeledStatement", "SwitchCase", "SwitchStatement", "WithStatement" ], "requireObjectKeysOnNewLine": { "allExcept": ["sameLine"] }, "requireSpacesInAnonymousFunctionExpression": { "beforeOpeningRoundBrace": true, "beforeOpeningCurlyBrace": true }, "requireSpacesInNamedFunctionExpression": { "beforeOpeningCurlyBrace": true }, "disallowSpacesInNamedFunctionExpression": { "beforeOpeningRoundBrace": true }, "requireSpacesInFunctionDeclaration": { "beforeOpeningCurlyBrace": true }, "disallowSpacesInFunctionDeclaration": { "beforeOpeningRoundBrace": true }, "requireSpaceBetweenArguments": true, "disallowSpacesInsideParentheses": true, "disallowSpacesInsideArrayBrackets": true, "disallowQuotedKeysInObjects": { "allExcept": ["reserved"] }, "disallowSpaceAfterObjectKeys": true, "requireCommaBeforeLineBreak": true, "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"], "requireSpaceAfterPrefixUnaryOperators": [], "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], "requireSpaceBeforePostfixUnaryOperators": [], "disallowSpaceBeforeBinaryOperators": [], "requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], "requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!=="], "disallowSpaceAfterBinaryOperators": [], "disallowImplicitTypeConversion": ["binary", "string"], "disallowKeywords": ["with", "eval"], "requireKeywordsOnNewLine": [], "disallowKeywordsOnNewLine": ["else"], "requireLineFeedAtFileEnd": true, "disallowTrailingWhitespace": true, "disallowTrailingComma": true, "excludeFiles": ["node_modules/**", "vendor/**"], "disallowMultipleLineStrings": true, "requireDotNotation": { "allExcept": ["keywords"] }, "requireParenthesesAroundIIFE": true, "validateLineBreaks": "LF", "validateQuoteMarks": { "escape": true, "mark": "'" }, "disallowOperatorBeforeLineBreak": [], "requireSpaceBeforeKeywords": [ "do", "for", "if", "else", "switch", "case", "try", "catch", "finally", "while", "with", "return" ], "validateAlignedFunctionParameters": { "lineBreakAfterOpeningBraces": true, "lineBreakBeforeClosingBraces": true }, "requirePaddingNewLinesBeforeExport": true, "validateNewlineAfterArrayElements": { "maximum": 1 }, "requirePaddingNewLinesAfterUseStrict": true, "disallowArrowFunctions": true, "disallowMultiLineTernary": true, "validateOrderInObjectKeys": "asc-insensitive", "disallowIdenticalDestructuringNames": true, "disallowNestedTernaries": { "maxLevel": 1 }, "requireSpaceAfterComma": { "allExcept": ["trailing"] }, "requireAlignedMultilineParams": false, "requireSpacesInGenerator": { "afterStar": true }, "disallowSpacesInGenerator": { "beforeStar": true }, "disallowVar": false, "requireArrayDestructuring": false, "requireEnhancedObjectLiterals": false, "requireObjectDestructuring": false, "requireEarlyReturn": false, "requireCapitalizedConstructorsNew": { "allExcept": ["Function", "String", "Object", "Symbol", "Number", "Date", "RegExp", "Error", "Boolean", "Array"] }, "requireImportAlphabetized": false, "requireSpaceBeforeObjectValues": true, "requireSpaceBeforeDestructuredValues": true, "disallowSpacesInsideTemplateStringPlaceholders": true, "disallowArrayDestructuringReturn": false, "requireNewlineBeforeSingleStatementsInIf": false, "disallowUnusedVariables": true, "requireSpacesInsideImportedObjectBraces": true, "requireUseStrict": true } package/.nvmrc000644 0000000005 3560116604 010401 0ustar00000000 000000 node package/.travis.yml000644 0000016104 3560116604 011373 0ustar00000000 000000 language: node_js os: - linux node_js: - "10.11" - "9.11" - "8.12" - "7.10" - "6.14" - "5.12" - "4.9" - "iojs-v3.3" - "iojs-v2.5" - "iojs-v1.8" - "0.12" - "0.10" - "0.8" before_install: - 'case "${TRAVIS_NODE_VERSION}" in 0.*) export NPM_CONFIG_STRICT_SSL=false ;; esac' - 'nvm install-latest-npm' install: - 'if [ "${TRAVIS_NODE_VERSION}" = "0.6" ] || [ "${TRAVIS_NODE_VERSION}" = "0.9" ]; then nvm install --latest-npm 0.8 && npm install && nvm use "${TRAVIS_NODE_VERSION}"; else npm install; fi;' script: - 'if [ -n "${PRETEST-}" ]; then npm run pretest ; fi' - 'if [ -n "${POSTTEST-}" ]; then npm run posttest ; fi' - 'if [ -n "${COVERAGE-}" ]; then npm run coverage ; fi' - 'if [ -n "${TEST-}" ]; then npm run tests-only ; fi' sudo: false env: - TEST=true matrix: fast_finish: true include: - node_js: "lts/*" env: PRETEST=true - node_js: "lts/*" env: POSTTEST=true - node_js: "4" env: COVERAGE=true - node_js: "10.10" env: TEST=true ALLOW_FAILURE=true - node_js: "10.9" env: TEST=true ALLOW_FAILURE=true - node_js: "10.8" env: TEST=true ALLOW_FAILURE=true - node_js: "10.7" env: TEST=true ALLOW_FAILURE=true - node_js: "10.6" env: TEST=true ALLOW_FAILURE=true - node_js: "10.5" env: TEST=true ALLOW_FAILURE=true - node_js: "10.4" env: TEST=true ALLOW_FAILURE=true - node_js: "10.3" env: TEST=true ALLOW_FAILURE=true - node_js: "10.2" env: TEST=true ALLOW_FAILURE=true - node_js: "10.1" env: TEST=true ALLOW_FAILURE=true - node_js: "10.0" env: TEST=true ALLOW_FAILURE=true - node_js: "9.10" env: TEST=true ALLOW_FAILURE=true - node_js: "9.9" env: TEST=true ALLOW_FAILURE=true - node_js: "9.8" env: TEST=true ALLOW_FAILURE=true - node_js: "9.7" env: TEST=true ALLOW_FAILURE=true - node_js: "9.6" env: TEST=true ALLOW_FAILURE=true - node_js: "9.5" env: TEST=true ALLOW_FAILURE=true - node_js: "9.4" env: TEST=true ALLOW_FAILURE=true - node_js: "9.3" env: TEST=true ALLOW_FAILURE=true - node_js: "9.2" env: TEST=true ALLOW_FAILURE=true - node_js: "9.1" env: TEST=true ALLOW_FAILURE=true - node_js: "9.0" env: TEST=true ALLOW_FAILURE=true - node_js: "8.11" env: TEST=true ALLOW_FAILURE=true - node_js: "8.10" env: TEST=true ALLOW_FAILURE=true - node_js: "8.9" env: TEST=true ALLOW_FAILURE=true - node_js: "8.8" env: TEST=true ALLOW_FAILURE=true - node_js: "8.7" env: TEST=true ALLOW_FAILURE=true - node_js: "8.6" env: TEST=true ALLOW_FAILURE=true - node_js: "8.5" env: TEST=true ALLOW_FAILURE=true - node_js: "8.4" env: TEST=true ALLOW_FAILURE=true - node_js: "8.3" env: TEST=true ALLOW_FAILURE=true - node_js: "8.2" env: TEST=true ALLOW_FAILURE=true - node_js: "8.1" env: TEST=true ALLOW_FAILURE=true - node_js: "8.0" env: TEST=true ALLOW_FAILURE=true - node_js: "7.9" env: TEST=true ALLOW_FAILURE=true - node_js: "7.8" env: TEST=true ALLOW_FAILURE=true - node_js: "7.7" env: TEST=true ALLOW_FAILURE=true - node_js: "7.6" env: TEST=true ALLOW_FAILURE=true - node_js: "7.5" env: TEST=true ALLOW_FAILURE=true - node_js: "7.4" env: TEST=true ALLOW_FAILURE=true - node_js: "7.3" env: TEST=true ALLOW_FAILURE=true - node_js: "7.2" env: TEST=true ALLOW_FAILURE=true - node_js: "7.1" env: TEST=true ALLOW_FAILURE=true - node_js: "7.0" env: TEST=true ALLOW_FAILURE=true - node_js: "6.13" env: TEST=true ALLOW_FAILURE=true - node_js: "6.12" env: TEST=true ALLOW_FAILURE=true - node_js: "6.11" env: TEST=true ALLOW_FAILURE=true - node_js: "6.10" env: TEST=true ALLOW_FAILURE=true - node_js: "6.9" env: TEST=true ALLOW_FAILURE=true - node_js: "6.8" env: TEST=true ALLOW_FAILURE=true - node_js: "6.7" env: TEST=true ALLOW_FAILURE=true - node_js: "6.6" env: TEST=true ALLOW_FAILURE=true - node_js: "6.5" env: TEST=true ALLOW_FAILURE=true - node_js: "6.4" env: TEST=true ALLOW_FAILURE=true - node_js: "6.3" env: TEST=true ALLOW_FAILURE=true - node_js: "6.2" env: TEST=true ALLOW_FAILURE=true - node_js: "6.1" env: TEST=true ALLOW_FAILURE=true - node_js: "6.0" env: TEST=true ALLOW_FAILURE=true - node_js: "5.11" env: TEST=true ALLOW_FAILURE=true - node_js: "5.10" env: TEST=true ALLOW_FAILURE=true - node_js: "5.9" env: TEST=true ALLOW_FAILURE=true - node_js: "5.8" env: TEST=true ALLOW_FAILURE=true - node_js: "5.7" env: TEST=true ALLOW_FAILURE=true - node_js: "5.6" env: TEST=true ALLOW_FAILURE=true - node_js: "5.5" env: TEST=true ALLOW_FAILURE=true - node_js: "5.4" env: TEST=true ALLOW_FAILURE=true - node_js: "5.3" env: TEST=true ALLOW_FAILURE=true - node_js: "5.2" env: TEST=true ALLOW_FAILURE=true - node_js: "5.1" env: TEST=true ALLOW_FAILURE=true - node_js: "5.0" env: TEST=true ALLOW_FAILURE=true - node_js: "4.8" env: TEST=true ALLOW_FAILURE=true - node_js: "4.7" env: TEST=true ALLOW_FAILURE=true - node_js: "4.6" env: TEST=true ALLOW_FAILURE=true - node_js: "4.5" env: TEST=true ALLOW_FAILURE=true - node_js: "4.4" env: TEST=true ALLOW_FAILURE=true - node_js: "4.3" env: TEST=true ALLOW_FAILURE=true - node_js: "4.2" env: TEST=true ALLOW_FAILURE=true - node_js: "4.1" env: TEST=true ALLOW_FAILURE=true - node_js: "4.0" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v3.2" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v3.1" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v3.0" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v2.4" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v2.3" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v2.2" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v2.1" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v2.0" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v1.7" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v1.6" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v1.5" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v1.4" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v1.3" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v1.2" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v1.1" env: TEST=true ALLOW_FAILURE=true - node_js: "iojs-v1.0" env: TEST=true ALLOW_FAILURE=true - node_js: "0.11" env: TEST=true ALLOW_FAILURE=true - node_js: "0.9" env: TEST=true ALLOW_FAILURE=true - node_js: "0.6" env: TEST=true ALLOW_FAILURE=true - node_js: "0.4" env: TEST=true ALLOW_FAILURE=true allow_failures: - os: osx - env: TEST=true ALLOW_FAILURE=true - env: COVERAGE=true package/CHANGELOG.md000644 0000000405 3560116604 011070 0ustar00000000 000000 1.0.2 / 2018-09-20 ================= * [Refactor] use `has-symbols` and `object-inspect` * [Tests] test on all the node minor versions 1.0.1 / 2015-01-26 ================= * Corrected description 1.0.0 / 2015-01-24 ================= * Initial release package/index.js000644 0000001377 3560116604 010735 0ustar00000000 000000 'use strict'; var toStr = Object.prototype.toString; var hasSymbols = require('has-symbols')(); if (hasSymbols) { var symToStr = Symbol.prototype.toString; var symStringRegex = /^Symbol\(.*\)$/; var isSymbolObject = function isRealSymbolObject(value) { if (typeof value.valueOf() !== 'symbol') { return false; } return symStringRegex.test(symToStr.call(value)); }; module.exports = function isSymbol(value) { if (typeof value === 'symbol') { return true; } if (toStr.call(value) !== '[object Symbol]') { return false; } try { return isSymbolObject(value); } catch (e) { return false; } }; } else { module.exports = function isSymbol(value) { // this environment does not support Symbols. return false && value; }; } package/LICENSE000644 0000002072 3560116604 010266 0ustar00000000 000000 The MIT License (MIT) Copyright (c) 2015 Jordan Harband Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. package/Makefile000644 0000007372 3560116604 010731 0ustar00000000 000000 # Since we rely on paths relative to the makefile location, abort if make isn't being run from there. $(if $(findstring /,$(MAKEFILE_LIST)),$(error Please only invoke this makefile from the directory it resides in)) # The files that need updating when incrementing the version number. VERSIONED_FILES := *.js *.json README* # Add the local npm packages' bin folder to the PATH, so that `make` can find them, when invoked directly. # Note that rather than using `$(npm bin)` the 'node_modules/.bin' path component is hard-coded, so that invocation works even from an environment # where npm is (temporarily) unavailable due to having deactivated an nvm instance loaded into the calling shell in order to avoid interference with tests. export PATH := $(shell printf '%s' "$$PWD/node_modules/.bin:$$PATH") UTILS := semver # Make sure that all required utilities can be located. UTIL_CHECK := $(or $(shell PATH="$(PATH)" which $(UTILS) >/dev/null && echo 'ok'),$(error Did you forget to run `npm install` after cloning the repo? At least one of the required supporting utilities not found: $(UTILS))) # Default target (by virtue of being the first non '.'-prefixed in the file). .PHONY: _no-target-specified _no-target-specified: $(error Please specify the target to make - `make list` shows targets. Alternatively, use `npm test` to run the default tests; `npm run` shows all tests) # Lists all targets defined in this makefile. .PHONY: list list: @$(MAKE) -pRrn : -f $(MAKEFILE_LIST) 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | command grep -v -e '^[^[:alnum:]]' -e '^$@$$command ' | sort # All-tests target: invokes the specified test suites for ALL shells defined in $(SHELLS). .PHONY: test test: @npm test .PHONY: _ensure-tag _ensure-tag: ifndef TAG $(error Please invoke with `make TAG= release`, where is either an increment specifier (patch, minor, major, prepatch, preminor, premajor, prerelease), or an explicit major.minor.patch version number) endif CHANGELOG_ERROR = $(error No CHANGELOG specified) .PHONY: _ensure-changelog _ensure-changelog: @ (git status -sb --porcelain | command grep -E '^( M|[MA] ) CHANGELOG.md' > /dev/null) || (echo no CHANGELOG.md specified && exit 2) # Ensures that the git workspace is clean. .PHONY: _ensure-clean _ensure-clean: @[ -z "$$((git status --porcelain --untracked-files=no || echo err) | command grep -v 'CHANGELOG.md')" ] || { echo "Workspace is not clean; please commit changes first." >&2; exit 2; } # Makes a release; invoke with `make TAG= release`. .PHONY: release release: _ensure-tag _ensure-changelog _ensure-clean @old_ver=`git describe --abbrev=0 --tags --match 'v[0-9]*.[0-9]*.[0-9]*'` || { echo "Failed to determine current version." >&2; exit 1; }; old_ver=$${old_ver#v}; \ new_ver=`echo "$(TAG)" | sed 's/^v//'`; new_ver=$${new_ver:-patch}; \ if printf "$$new_ver" | command grep -q '^[0-9]'; then \ semver "$$new_ver" >/dev/null || { echo 'Invalid version number specified: $(TAG) - must be major.minor.patch' >&2; exit 2; }; \ semver -r "> $$old_ver" "$$new_ver" >/dev/null || { echo 'Invalid version number specified: $(TAG) - must be HIGHER than current one.' >&2; exit 2; } \ else \ new_ver=`semver -i "$$new_ver" "$$old_ver"` || { echo 'Invalid version-increment specifier: $(TAG)' >&2; exit 2; } \ fi; \ printf "=== Bumping version **$$old_ver** to **$$new_ver** before committing and tagging:\n=== TYPE 'proceed' TO PROCEED, anything else to abort: " && read response && [ "$$response" = 'proceed' ] || { echo 'Aborted.' >&2; exit 2; }; \ replace "$$old_ver" "$$new_ver" -- $(VERSIONED_FILES) && \ git commit -m "v$$new_ver" $(VERSIONED_FILES) CHANGELOG.md && \ git tag -a -m "v$$new_ver" "v$$new_ver" package/README.md000644 0000002676 3560116604 010552 0ustar00000000 000000 #is-symbol [![Version Badge][2]][1] [![Build Status][3]][4] [![dependency status][5]][6] [![dev dependency status][7]][8] [![License][license-image]][license-url] [![Downloads][downloads-image]][downloads-url] [![npm badge][11]][1] [![browser support][9]][10] Is this an ES6 Symbol value? ## Example ```js var isSymbol = require('is-symbol'); assert(!isSymbol(function () {})); assert(!isSymbol(null)); assert(!isSymbol(function* () { yield 42; return Infinity; }); assert(isSymbol(Symbol.iterator)); assert(isSymbol(Symbol('foo'))); assert(isSymbol(Symbol.for('foo'))); assert(isSymbol(Object(Symbol('foo')))); ``` ## Tests Simply clone the repo, `npm install`, and run `npm test` [1]: https://npmjs.org/package/is-symbol [2]: http://versionbadg.es/ljharb/is-symbol.svg [3]: https://travis-ci.org/ljharb/is-symbol.svg [4]: https://travis-ci.org/ljharb/is-symbol [5]: https://david-dm.org/ljharb/is-symbol.svg [6]: https://david-dm.org/ljharb/is-symbol [7]: https://david-dm.org/ljharb/is-symbol/dev-status.svg [8]: https://david-dm.org/ljharb/is-symbol#info=devDependencies [9]: https://ci.testling.com/ljharb/is-symbol.png [10]: https://ci.testling.com/ljharb/is-symbol [11]: https://nodei.co/npm/is-symbol.png?downloads=true&stars=true [license-image]: http://img.shields.io/npm/l/is-symbol.svg [license-url]: LICENSE [downloads-image]: http://img.shields.io/npm/dm/is-symbol.svg [downloads-url]: http://npm-stat.com/charts.html?package=is-symbol package/test/.eslintrc000644 0000000177 3560116604 012070 0ustar00000000 000000 { "rules": { "max-statements-per-line": [2, { "max": 2 }], "no-restricted-properties": 0, "symbol-description": 0, } } package/test/index.js000644 0000005033 3560116604 011705 0ustar00000000 000000 'use strict'; var test = require('tape'); var isSymbol = require('../index'); var forEach = function (arr, func) { var i; for (i = 0; i < arr.length; ++i) { func(arr[i], i, arr); } }; var hasSymbols = require('has-symbols')(); var inspect = require('object-inspect'); var debug = function (v, m) { return inspect(v) + ' ' + m; }; test('non-symbol values', function (t) { var nonSymbols = [ true, false, Object(true), Object(false), null, undefined, {}, [], /a/g, 'string', 42, new Date(), function () {}, NaN ]; t.plan(nonSymbols.length); forEach(nonSymbols, function (nonSymbol) { t.equal(false, isSymbol(nonSymbol), debug(nonSymbol, 'is not a symbol')); }); t.end(); }); test('faked symbol values', function (t) { t.test('real symbol valueOf', { skip: !hasSymbols }, function (st) { var fakeSymbol = { valueOf: function () { return Symbol('foo'); } }; st.equal(false, isSymbol(fakeSymbol), 'object with valueOf returning a symbol is not a symbol'); st.end(); }); t.test('faked @@toStringTag', { skip: !hasSymbols || !Symbol.toStringTag }, function (st) { var fakeSymbol = { valueOf: function () { return Symbol('foo'); } }; fakeSymbol[Symbol.toStringTag] = 'Symbol'; st.equal(false, isSymbol(fakeSymbol), 'object with fake Symbol @@toStringTag and valueOf returning a symbol is not a symbol'); var notSoFakeSymbol = { valueOf: function () { return 42; } }; notSoFakeSymbol[Symbol.toStringTag] = 'Symbol'; st.equal(false, isSymbol(notSoFakeSymbol), 'object with fake Symbol @@toStringTag and valueOf not returning a symbol is not a symbol'); st.end(); }); var fakeSymbolString = { toString: function () { return 'Symbol(foo)'; } }; t.equal(false, isSymbol(fakeSymbolString), 'object with toString returning Symbol(foo) is not a symbol'); t.end(); }); test('Symbol support', { skip: !hasSymbols }, function (t) { t.test('well-known Symbols', function (st) { var isWellKnown = function filterer(name) { return name !== 'for' && name !== 'keyFor' && !(name in filterer); }; var wellKnownSymbols = Object.getOwnPropertyNames(Symbol).filter(isWellKnown); wellKnownSymbols.forEach(function (name) { var sym = Symbol[name]; st.equal(true, isSymbol(sym), debug(sym, ' is a symbol')); }); st.end(); }); t.test('user-created symbols', function (st) { var symbols = [ Symbol(), Symbol('foo'), Symbol['for']('foo'), Object(Symbol('object')) ]; symbols.forEach(function (sym) { st.equal(true, isSymbol(sym), debug(sym, ' is a symbol')); }); st.end(); }); t.end(); });