get-own-property-symbols
Advanced tools
Comparing version 0.9.3 to 0.9.4
/*! (C) WebReflection Mit Style License */ | ||
(function(Object,GOPS){"use strict";if(GOPS in Object)return;var setDescriptor,G=typeof global===typeof G?window:global,id=0,random=""+Math.random(),prefix="__symbol:",prefixLength=prefix.length,internalSymbol="__symbol@@"+random,DP="defineProperty",DPies="defineProperties",GOPN="getOwnPropertyNames",GOPD="getOwnPropertyDescriptor",PIE="propertyIsEnumerable",gOPN=Object[GOPN],gOPD=Object[GOPD],create=Object.create,keys=Object.keys,freeze=Object.freeze||Object,defineProperty=Object[DP],$defineProperties=Object[DPies],descriptor=gOPD(Object,GOPN),ObjectProto=Object.prototype,hOP=ObjectProto.hasOwnProperty,pIE=ObjectProto[PIE],toString=ObjectProto.toString,addInternalIfNeeded=function(o,uid,enumerable){if(!hOP.call(o,internalSymbol)){defineProperty(o,internalSymbol,{enumerable:false,configurable:false,writable:false,value:{}})}o[internalSymbol]["@@"+uid]=enumerable},createWithSymbols=function(proto,descriptors){var self=create(proto);gOPN(descriptors).forEach(function(key){if(propertyIsEnumerable.call(descriptors,key)){$defineProperty(self,key,descriptors[key])}});return self},copyAsNonEnumerable=function(descriptor){var newDescriptor=create(descriptor);newDescriptor.enumerable=false;return newDescriptor},get=function get(){},onlyNonSymbols=function(name){return name!=internalSymbol&&!hOP.call(source,name)},onlySymbols=function(name){return name!=internalSymbol&&hOP.call(source,name)},propertyIsEnumerable=function propertyIsEnumerable(key){var uid=""+key;return onlySymbols(uid)?hOP.call(this,uid)&&this[internalSymbol]["@@"+uid]:pIE.call(this,key)},setAndGetSymbol=function(uid){var descriptor={enumerable:false,configurable:true,get:get,set:function(value){setDescriptor(this,uid,{enumerable:false,configurable:true,writable:true,value:value});addInternalIfNeeded(this,uid,true)}};defineProperty(ObjectProto,uid,descriptor);return freeze(source[uid]=defineProperty(Object(uid),"constructor",sourceConstructor))},Symbol=function Symbol(description){if(this&&this!==G){throw new TypeError("Symbol is not a constructor")}return setAndGetSymbol(prefix.concat(description||"",random,++id))},source=create(null),sourceConstructor={value:Symbol},sourceMap=function(uid){return source[uid]},$defineProperty=function defineProp(o,key,descriptor){var uid=""+key;if(onlySymbols(uid)){setDescriptor(o,uid,descriptor.enumerable?copyAsNonEnumerable(descriptor):descriptor);addInternalIfNeeded(o,uid,!!descriptor.enumerable)}else{defineProperty(o,key,descriptor)}return o},$getOwnPropertySymbols=function getOwnPropertySymbols(o){return gOPN(o).filter(onlySymbols).map(sourceMap)};descriptor.value=$defineProperty;defineProperty(Object,DP,descriptor);descriptor.value=$getOwnPropertySymbols;defineProperty(Object,GOPS,descriptor);descriptor.value=function getOwnPropertyNames(o){return gOPN(o).filter(onlyNonSymbols)};defineProperty(Object,GOPN,descriptor);descriptor.value=function defineProperties(o,descriptors){var symbols=$getOwnPropertySymbols(descriptors);if(symbols.length){keys(descriptors).concat(symbols).forEach(function(uid){if(propertyIsEnumerable.call(descriptors,uid)){$defineProperty(o,uid,descriptors[uid])}})}else{$defineProperties(o,descriptors)}return o};defineProperty(Object,DPies,descriptor);descriptor.value=propertyIsEnumerable;defineProperty(ObjectProto,PIE,descriptor);descriptor.value=Symbol;defineProperty(G,"Symbol",descriptor);descriptor.value=function(key){var uid=prefix.concat(prefix,key,random);return uid in ObjectProto?source[uid]:setAndGetSymbol(uid)};defineProperty(Symbol,"for",descriptor);descriptor.value=function(symbol){if(onlyNonSymbols(symbol))throw new TypeError(symbol+" is not a symbol");if(!hOP.call(source,symbol)){return void 0}var label=symbol.slice(prefixLength);if(label.slice(0,prefixLength)!==prefix){return void 0}label=label.slice(prefixLength);if(label===random){return void 0}label=label.slice(0,label.length-random.length);return label.length>0?label:void 0};defineProperty(Symbol,"keyFor",descriptor);descriptor.value=function getOwnPropertyDescriptor(o,key){var descriptor=gOPD(o,key);if(descriptor&&onlySymbols(key)){descriptor.enumerable=propertyIsEnumerable.call(o,key)}return descriptor};defineProperty(Object,GOPD,descriptor);descriptor.value=function(proto,descriptors){return arguments.length===1||typeof descriptors==="undefined"?create(proto):createWithSymbols(proto,descriptors)};defineProperty(Object,"create",descriptor);descriptor.value=function(){var str=toString.call(this);return str==="[object String]"&&onlySymbols(this)?"[object Symbol]":str};defineProperty(ObjectProto,"toString",descriptor);try{if(true===create(defineProperty({},prefix,{get:function(){return defineProperty(this,prefix,{value:true})[prefix]}}))[prefix]){setDescriptor=defineProperty}else{throw"IE11"}}catch(o_O){setDescriptor=function(o,key,descriptor){var protoDescriptor=gOPD(ObjectProto,key);delete ObjectProto[key];defineProperty(o,key,descriptor);defineProperty(ObjectProto,key,protoDescriptor)}}})(Object,"getOwnPropertySymbols");(function(O,Symbol){"use strict";var dP=O.defineProperty,ObjectProto=O.prototype,toString=ObjectProto.toString,toStringTag="toStringTag",descriptor;["iterator","match","replace","search","split","hasInstance","isConcatSpreadable","unscopables","species","toPrimitive",toStringTag].forEach(function(name){if(!(name in Symbol)){dP(Symbol,name,{value:Symbol(name)});switch(name){case toStringTag:descriptor=O.getOwnPropertyDescriptor(ObjectProto,"toString");descriptor.value=function(){var str=toString.call(this),tst=this!=null?this[Symbol.toStringTag]:this;return tst==null?str:"[object "+tst+"]"};dP(ObjectProto,"toString",descriptor);break}}})})(Object,Symbol);(function(Si,AP,SP){function returnThis(){return this}if(!AP[Si])AP[Si]=function(){var i=0,self=this,iterator={next:function next(){var done=self.length<=i;return done?{done:done}:{done:done,value:self[i++]}}};iterator[Si]=returnThis;return iterator};if(!SP[Si])SP[Si]=function(){var fromCodePoint=String.fromCodePoint,self=this,i=0,length=self.length,iterator={next:function next(){var done=length<=i,c=done?"":fromCodePoint(self.codePointAt(i));i+=c.length;return done?{done:done}:{done:done,value:c}}};iterator[Si]=returnThis;return iterator}})(Symbol.iterator,Array.prototype,String.prototype); | ||
(function(Object,GOPS){"use strict";if(GOPS in Object)return;var setDescriptor,G=typeof global===typeof G?window:global,id=0,random=""+Math.random(),prefix="__symbol:",prefixLength=prefix.length,internalSymbol="__symbol@@"+random,DP="defineProperty",DPies="defineProperties",GOPN="getOwnPropertyNames",GOPD="getOwnPropertyDescriptor",PIE="propertyIsEnumerable",gOPN=Object[GOPN],gOPD=Object[GOPD],create=Object.create,keys=Object.keys,freeze=Object.freeze||Object,defineProperty=Object[DP],$defineProperties=Object[DPies],descriptor=gOPD(Object,GOPN),ObjectProto=Object.prototype,hOP=ObjectProto.hasOwnProperty,pIE=ObjectProto[PIE],toString=ObjectProto.toString,addInternalIfNeeded=function(o,uid,enumerable){if(!hOP.call(o,internalSymbol)){defineProperty(o,internalSymbol,{enumerable:false,configurable:false,writable:false,value:{}})}o[internalSymbol]["@@"+uid]=enumerable},createWithSymbols=function(proto,descriptors){var self=create(proto);gOPN(descriptors).forEach(function(key){if(propertyIsEnumerable.call(descriptors,key)){$defineProperty(self,key,descriptors[key])}});return self},copyAsNonEnumerable=function(descriptor){var newDescriptor=create(descriptor);newDescriptor.enumerable=false;return newDescriptor},get=function get(){},onlyNonSymbols=function(name){return name!=internalSymbol&&!hOP.call(source,name)},onlySymbols=function(name){return name!=internalSymbol&&hOP.call(source,name)},propertyIsEnumerable=function propertyIsEnumerable(key){var uid=""+key;return onlySymbols(uid)?hOP.call(this,uid)&&this[internalSymbol]["@@"+uid]:pIE.call(this,key)},setAndGetSymbol=function(uid){var descriptor={enumerable:false,configurable:true,get:get,set:function(value){setDescriptor(this,uid,{enumerable:false,configurable:true,writable:true,value:value});addInternalIfNeeded(this,uid,true)}};defineProperty(ObjectProto,uid,descriptor);return freeze(source[uid]=defineProperty(Object(uid),"constructor",sourceConstructor))},Symbol=function Symbol(description){if(this instanceof Symbol){throw new TypeError("Symbol is not a constructor")}return setAndGetSymbol(prefix.concat(description||"",random,++id))},source=create(null),sourceConstructor={value:Symbol},sourceMap=function(uid){return source[uid]},$defineProperty=function defineProp(o,key,descriptor){var uid=""+key;if(onlySymbols(uid)){setDescriptor(o,uid,descriptor.enumerable?copyAsNonEnumerable(descriptor):descriptor);addInternalIfNeeded(o,uid,!!descriptor.enumerable)}else{defineProperty(o,key,descriptor)}return o},$getOwnPropertySymbols=function getOwnPropertySymbols(o){return gOPN(o).filter(onlySymbols).map(sourceMap)};descriptor.value=$defineProperty;defineProperty(Object,DP,descriptor);descriptor.value=$getOwnPropertySymbols;defineProperty(Object,GOPS,descriptor);descriptor.value=function getOwnPropertyNames(o){return gOPN(o).filter(onlyNonSymbols)};defineProperty(Object,GOPN,descriptor);descriptor.value=function defineProperties(o,descriptors){var symbols=$getOwnPropertySymbols(descriptors);if(symbols.length){keys(descriptors).concat(symbols).forEach(function(uid){if(propertyIsEnumerable.call(descriptors,uid)){$defineProperty(o,uid,descriptors[uid])}})}else{$defineProperties(o,descriptors)}return o};defineProperty(Object,DPies,descriptor);descriptor.value=propertyIsEnumerable;defineProperty(ObjectProto,PIE,descriptor);descriptor.value=Symbol;defineProperty(G,"Symbol",descriptor);descriptor.value=function(key){var uid=prefix.concat(prefix,key,random);return uid in ObjectProto?source[uid]:setAndGetSymbol(uid)};defineProperty(Symbol,"for",descriptor);descriptor.value=function(symbol){if(onlyNonSymbols(symbol))throw new TypeError(symbol+" is not a symbol");if(!hOP.call(source,symbol)){return void 0}var label=symbol.slice(prefixLength);if(label.slice(0,prefixLength)!==prefix){return void 0}label=label.slice(prefixLength);if(label===random){return void 0}label=label.slice(0,label.length-random.length);return label.length>0?label:void 0};defineProperty(Symbol,"keyFor",descriptor);descriptor.value=function getOwnPropertyDescriptor(o,key){var descriptor=gOPD(o,key);if(descriptor&&onlySymbols(key)){descriptor.enumerable=propertyIsEnumerable.call(o,key)}return descriptor};defineProperty(Object,GOPD,descriptor);descriptor.value=function(proto,descriptors){return arguments.length===1||typeof descriptors==="undefined"?create(proto):createWithSymbols(proto,descriptors)};defineProperty(Object,"create",descriptor);descriptor.value=function(){var str=toString.call(this);return str==="[object String]"&&onlySymbols(this)?"[object Symbol]":str};defineProperty(ObjectProto,"toString",descriptor);try{if(true===create(defineProperty({},prefix,{get:function(){return defineProperty(this,prefix,{value:true})[prefix]}}))[prefix]){setDescriptor=defineProperty}else{throw"IE11"}}catch(o_O){setDescriptor=function(o,key,descriptor){var protoDescriptor=gOPD(ObjectProto,key);delete ObjectProto[key];defineProperty(o,key,descriptor);defineProperty(ObjectProto,key,protoDescriptor)}}})(Object,"getOwnPropertySymbols");(function(O,Symbol){"use strict";var dP=O.defineProperty,ObjectProto=O.prototype,toString=ObjectProto.toString,toStringTag="toStringTag",descriptor;["iterator","match","replace","search","split","hasInstance","isConcatSpreadable","unscopables","species","toPrimitive",toStringTag].forEach(function(name){if(!(name in Symbol)){dP(Symbol,name,{value:Symbol(name)});switch(name){case toStringTag:descriptor=O.getOwnPropertyDescriptor(ObjectProto,"toString");descriptor.value=function(){var str=toString.call(this),tst=this!=null?this[Symbol.toStringTag]:this;return tst==null?str:"[object "+tst+"]"};dP(ObjectProto,"toString",descriptor);break}}})})(Object,Symbol);(function(Si,AP,SP){function returnThis(){return this}if(!AP[Si])AP[Si]=function(){var i=0,self=this,iterator={next:function next(){var done=self.length<=i;return done?{done:done}:{done:done,value:self[i++]}}};iterator[Si]=returnThis;return iterator};if(!SP[Si])SP[Si]=function(){var fromCodePoint=String.fromCodePoint,self=this,i=0,length=self.length,iterator={next:function next(){var done=length<=i,c=done?"":fromCodePoint(self.codePointAt(i));i+=c.length;return done?{done:done}:{done:done,value:c}}};iterator[Si]=returnThis;return iterator}})(Symbol.iterator,Array.prototype,String.prototype); |
@@ -118,3 +118,3 @@ /*! | ||
Symbol = function Symbol(description) { | ||
if (this && this !== G) { | ||
if (this instanceof Symbol) { | ||
throw new TypeError('Symbol is not a constructor'); | ||
@@ -121,0 +121,0 @@ } |
@@ -118,3 +118,3 @@ /*! | ||
Symbol = function Symbol(description) { | ||
if (this && this !== G) { | ||
if (this instanceof Symbol) { | ||
throw new TypeError('Symbol is not a constructor'); | ||
@@ -121,0 +121,0 @@ } |
{ | ||
"version": "0.9.3", | ||
"version": "0.9.4", | ||
"license": "MIT", | ||
@@ -4,0 +4,0 @@ "name": "get-own-property-symbols", |
get-own-property-symbols | ||
======================== | ||
[![build status](https://secure.travis-ci.org/WebReflection/get-own-property-symbols.svg)](http://travis-ci.org/WebReflection/get-own-property-symbols) | ||
[![build status](https://travis-ci.com/es-shims/get-own-property-symbols.svg?branch=master)](http://travis-ci.com/es-shims/get-own-property-symbols) | ||
This is a widely compatible, Mobile friendly, and zero dependencies polyfill for `Object.getOwnPropertySymbols`. | ||
This is a widely compatible, mobile-friendly, and zero dependencies polyfill for `Object.getOwnPropertySymbols`. | ||
```js | ||
@@ -8,0 +8,0 @@ var getOwnPropertySymbols = require('get-own-property-symbols'); |
@@ -96,3 +96,3 @@ (function (Object, GOPS) {'use strict'; | ||
Symbol = function Symbol(description) { | ||
if (this && this !== G) { | ||
if (this instanceof Symbol) { | ||
throw new TypeError('Symbol is not a constructor'); | ||
@@ -99,0 +99,0 @@ } |
@@ -160,2 +160,13 @@ //remove: | ||
}, { | ||
name: 'can use Symbol via Function.prototype.bind', | ||
test: function () { | ||
try { | ||
Symbol.bind(Array)(); | ||
Symbol.call(Symbol()); | ||
wru.assert(true); | ||
} catch(e) { | ||
wru.assert(false); | ||
} | ||
} | ||
}, { | ||
name: 'Symbol name', | ||
@@ -162,0 +173,0 @@ test: function () { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
61555
1363
1
21