weak-ref-collections
Advanced tools
Comparing version 1.2.0 to 1.2.1
33
index.js
@@ -39,5 +39,4 @@ // In Node.js this is packaged into a module | ||
return super.set(key, ref) | ||
} | ||
// If its not an object just set it directly | ||
else { | ||
// If its not an object just set it directly | ||
} else { | ||
return super.set(key, value) | ||
@@ -48,3 +47,3 @@ } | ||
get (key) { | ||
let value = super.get(key); | ||
let value = super.get(key) | ||
// If its a weakRef then unwrap it first | ||
@@ -57,3 +56,3 @@ // No need to check for GCd stuff because its meant to be undefined anyway | ||
has (key) { | ||
let value = super.get(key); | ||
let value = super.get(key) | ||
// If its a weakRef then unwrap it first | ||
@@ -81,7 +80,6 @@ if (value instanceof WeakRef) { | ||
else return true | ||
} | ||
// Getting here means it is a valid primitive | ||
// return the super.delete call to account for | ||
// return the super.delete call to account for | ||
// edge case of valid undefined value | ||
else { | ||
} else { | ||
return super.delete(key) | ||
@@ -145,4 +143,6 @@ } | ||
super() | ||
if (iterable) for (const value of iterable) { | ||
this.add(value) | ||
if (iterable) { | ||
for (const value of iterable) { | ||
this.add(value) | ||
} | ||
} | ||
@@ -163,5 +163,4 @@ } | ||
return super.add(ref) | ||
} | ||
// For primitives then just process it normally | ||
else { | ||
} else { | ||
return super.add(value) | ||
@@ -178,8 +177,6 @@ } | ||
return true | ||
} | ||
// If it's a primitive then do a normal has check | ||
else { | ||
} else { | ||
return super.has(value) | ||
} | ||
} | ||
@@ -199,4 +196,3 @@ | ||
return true | ||
} | ||
else { | ||
} else { | ||
return super.delete(value) | ||
@@ -229,4 +225,3 @@ } | ||
if (typeof value !== 'undefined') yield value | ||
} | ||
else { yield value } | ||
} else { yield value } | ||
} | ||
@@ -233,0 +228,0 @@ } |
{ | ||
"name": "weak-ref-collections", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "Iterable WeakMaps and WeakSets. Provides WeakRefMap and WeakRefSet which store values using WeakRefs and clean themselves up when garbage collected.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
13
test.js
@@ -44,3 +44,3 @@ /* global describe, it */ | ||
if('can set a value to undefined', () => { | ||
it('can set a value to undefined', () => { | ||
weakRefMap.set('beep', undefined) | ||
@@ -58,3 +58,3 @@ regularMap.set('beep', undefined) | ||
assert(weakRefDeleteReturn === regularDeleteReturn) | ||
}); | ||
}) | ||
@@ -103,7 +103,7 @@ it('can have a value gotten', () => { | ||
regularMap.set('weakRef', dummyWeakRef) | ||
const weakRefResult = weakRefMap.get('weakRef'); | ||
const regularResult = regularMap.get('weakRef'); | ||
const weakRefResult = weakRefMap.get('weakRef') | ||
const regularResult = regularMap.get('weakRef') | ||
assert(weakRefResult instanceof WeakRef) | ||
assert(weakRefResult === regularResult) | ||
}); | ||
}) | ||
@@ -182,3 +182,2 @@ it('can be iterated over', () => { | ||
}) | ||
}) | ||
@@ -259,3 +258,3 @@ | ||
it('can forEach', () => { | ||
const seedData = [{ foo: 1 }, { bar: 2 }, { baz: 3 }, "boop", "undefined"] | ||
const seedData = [{ foo: 1 }, { bar: 2 }, { baz: 3 }, 'boop', 'undefined'] | ||
weakRefSet = new WeakRefSet(seedData) | ||
@@ -262,0 +261,0 @@ regularSet = new Set(seedData) |
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
20439
499