Sha256: ffe4d933084cbeed8f2a174b73dc7360b37a95db9dd6614ef45c3779596b95f5
Contents?: true
Size: 1.54 KB
Versions: 16
Compression:
Stored size: 1.54 KB
Contents
'use strict'; var d = require('d') , create = Object.create, defineProperties = Object.defineProperties , generateName, Symbol; generateName = (function () { var created = create(null); return function (desc) { var postfix = 0; while (created[desc + (postfix || '')]) ++postfix; desc += (postfix || ''); created[desc] = true; return '@@' + desc; }; }()); module.exports = Symbol = function (description) { var symbol; if (this instanceof Symbol) { throw new TypeError('TypeError: Symbol is not a constructor'); } symbol = create(Symbol.prototype); description = (description === undefined ? '' : String(description)); return defineProperties(symbol, { __description__: d('', description), __name__: d('', generateName(description)) }); }; Object.defineProperties(Symbol, { create: d('', Symbol('create')), hasInstance: d('', Symbol('hasInstance')), isConcatSpreadable: d('', Symbol('isConcatSpreadable')), isRegExp: d('', Symbol('isRegExp')), iterator: d('', Symbol('iterator')), toPrimitive: d('', Symbol('toPrimitive')), toStringTag: d('', Symbol('toStringTag')), unscopables: d('', Symbol('unscopables')) }); defineProperties(Symbol.prototype, { properToString: d(function () { return 'Symbol (' + this.__description__ + ')'; }), toString: d('', function () { return this.__name__; }) }); Object.defineProperty(Symbol.prototype, Symbol.toPrimitive, d('', function (hint) { throw new TypeError("Conversion of symbol objects is not allowed"); })); Object.defineProperty(Symbol.prototype, Symbol.toStringTag, d('c', 'Symbol'));
Version data entries
16 entries across 9 versions & 2 rubygems