Socket
Socket
Sign inDemoInstall

protoblast

Package Overview
Dependencies
1
Maintainers
1
Versions
101
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.5.10 to 0.5.11

lib/symbol.js

10

CHANGELOG.md

@@ -0,1 +1,11 @@

## 0.5.11 (2018-07-14)
* `Object.checksum(mixed)` will now treat Dates & Numbers differently
* `Object.checksum(mixed)` will now correctly hash node Buffers
* Add `Buffer` support to `Object.alike(a, b)`
* Make `Object.alike(a, b)` not sort arrays when doing a checksum
* Fix `Object.alike(a, b)` treating null as regular objects
* Add a very basic Symbol polyfill for IE11
* Add `Blast.alikeSymbol` property, which `Object.alike` uses for comparing likeness
## 0.5.10 (2018-07-11)

@@ -2,0 +12,0 @@

1

lib/init.js

@@ -212,2 +212,3 @@ module.exports = function BlastInitLoader(modifyPrototype) {

'Function',
'Symbol',
'Object',

@@ -214,0 +215,0 @@ 'Array',

module.exports = function BlastObject(Blast, Collection, Bound, Obj) {
var libcrypto;
/**

@@ -1280,4 +1282,12 @@ * Get the property descriptor of the given object,

if (temp != obj) {
obj = temp;
type = typeof obj;
// Test for String, Number of Boolean instances
if (Obj.isPrimitiveObject(obj)) {
obj = temp;
type = typeof obj;
} else {
// Things like dates should not be handled as JUST numbers
type = 'date';
obj = temp;
}
}

@@ -1303,2 +1313,4 @@ }

return 'U';
} else if (type == 'date') {
return 'D' + obj;
} else if (obj == null) {

@@ -1323,2 +1335,9 @@ return 'L';

result = 'A';
} else if (Blast.isNode && Buffer.isBuffer(obj)) {
if (!libcrypto) {
libcrypto = require('crypto');
}
return 'BUF' + libcrypto.createHash('md5').update(obj).digest('hex');
} else {

@@ -1382,2 +1401,13 @@ // Get all the keys of the object and sort them alphabetically

/**
* Create the alike comparer symbol
*
* @author Jelle De Loecker <jelle@develry.be>
* @since 0.5.11
* @version 0.5.11
*
* @type {Symbol}
*/
Blast.defineStatic(Blast, 'alikeSymbol', Symbol('alike'));
/**
* Loosely compare 2 variables, ignoring undefined variables

@@ -1387,3 +1417,3 @@ *

* @since 0.1.3
* @version 0.4.0
* @version 0.5.11
*

@@ -1400,2 +1430,4 @@ * @param {Object} a

index_b,
type_a,
type_b,
id_a,

@@ -1415,2 +1447,27 @@ id_b,

type_a = a === null ? 'null' : typeof a;
type_b = b === null ? 'null' : typeof b;
// Both types should match
if (type_a != type_b) {
return false;
}
// From this point on, both values should be objects
if (type_a !== 'object') {
return false;
}
if (Blast.isNode && Buffer.isBuffer(a) && Buffer.isBuffer(b)) {
return a.equals(b);
}
if (typeof a[Blast.alikeSymbol] == 'function') {
return a[Blast.alikeSymbol](b);
}
if (typeof b[Blast.alikeSymbol] == 'function') {
return b[Blast.alikeSymbol](a);
}
// Do primitive values first

@@ -1461,3 +1518,3 @@ for (key in a) {

// If any of the 2 objects have been seen before,
// we'll have to do a more expensive check
// we'll have to do a more expensive check (for recursiveness)
if (index_a > -1 || index_b > -1) {

@@ -1474,3 +1531,3 @@ id_a = null;

if (!id_a) {
id_a = Bound.Object.checksum(a[key]);
id_a = Bound.Object.checksum(a[key], false);
seen.ids[index_a] = id_a;

@@ -1486,3 +1543,3 @@ }

if (!id_b) {
id_b = Bound.Object.checksum(b[key]);
id_b = Bound.Object.checksum(b[key], false);
seen.ids[index_b] = id_b;

@@ -1489,0 +1546,0 @@ }

2

package.json
{
"name": "protoblast",
"description": "Native object expansion library",
"version": "0.5.10",
"version": "0.5.11",
"author": "Jelle De Loecker <jelle@develry.be>",

@@ -6,0 +6,0 @@ "keywords": [

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc