Comparing version 0.0.2 to 0.0.3
@@ -6,3 +6,3 @@ { | ||
"keywords": ["harmony", "collection", "weakmap","ecmascript", "es6", "shim", "garbage collection", "gc"], | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"homepage": "http://benvie.github.com/WeakMap", | ||
@@ -9,0 +9,0 @@ "repository": { |
@@ -58,21 +58,22 @@ /* (The MIT License) | ||
uids = create(null), | ||
globalID = createUID(); | ||
function createUID(){ | ||
var key = Math.random().toString(36).slice(2); | ||
return key in uids ? createUID() : uids[key] = key; | ||
} | ||
createUID = function(){ | ||
var key = Math.random().toString(36).slice(2); | ||
return key in uids ? createUID() : uids[key] = key; | ||
}, | ||
function storage(obj){ | ||
if (hasOwn.call(obj, globalID)) | ||
return obj[globalID]; | ||
globalID = createUID(), | ||
if (!Object.isExtensible(obj)) | ||
throw new TypeError("Object must be extensible"); | ||
storage = function(obj){ | ||
if (hasOwn.call(obj, globalID)) | ||
return obj[globalID]; | ||
var store = create(null); | ||
defProp(obj, globalID, { value: store }); | ||
return store; | ||
} | ||
if (!Object.isExtensible(obj)) | ||
throw new TypeError("Object must be extensible"); | ||
var store = create(null); | ||
defProp(obj, globalID, { value: store }); | ||
return store; | ||
}; | ||
// common per-object storage area made visible by patching getOwnPropertyNames' | ||
@@ -141,3 +142,3 @@ define(Object, function getOwnPropertyNames(obj){ | ||
function WeakMap(iterable){ | ||
if (this === global || this == null || this === prototype) | ||
if (this === global || this == null || this === WeakMap.prototype) | ||
return new WeakMap(iterable); | ||
@@ -180,4 +181,4 @@ | ||
try { | ||
var src = ('return '+delete_).replace('e_', '\\u0065'); | ||
var del = new Function('unwrap', 'validate', src)(unwrap, validate); | ||
var src = ('return '+delete_).replace('e_', '\\u0065'), | ||
del = new Function('unwrap', 'validate', src)(unwrap, validate); | ||
} catch (e) { | ||
@@ -188,7 +189,15 @@ var del = delete_; | ||
var src = (''+Object).split('Object'); | ||
var stringifier = function toString(){ | ||
return src[0] + nameOf(this) + src[1]; | ||
}; | ||
define(stringifier, stringifier); | ||
var prep = { __proto__: [] } instanceof Array | ||
? function(f){ f.__proto__ = stringifier } | ||
: function(f){ define(f, stringifier) }; | ||
[toString, get, set, has, del].forEach(function(method){ | ||
define(WeakMap.prototype, method); | ||
define(method, function toString(){ | ||
return src[0] + nameOf(this) + src[1]; | ||
}); | ||
prep(method); | ||
}); | ||
@@ -195,0 +204,0 @@ |
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
14492
4
186