Socket
Socket
Sign inDemoInstall

weak-ref-collections

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

weak-ref-collections - npm Package Compare versions

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",

@@ -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)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc