Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bidar

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bidar - npm Package Compare versions

Comparing version 0.3.2 to 0.3.3

6

lib/serial.js

@@ -161,5 +161,5 @@ // Copyright 2012 The Obvious Corporation.

if (!already) {
var replacement = holeFilter(obj);
holes.set(obj, fixReplacement(obj, replacement));
iterate.iterate(replacement, visitor);
var replacement = fixReplacement(obj, holeFilter(obj));
holes.set(obj, replacement);
iterate.iterate(replacement.obj, visitor);
}

@@ -166,0 +166,0 @@ } else if (innerVisitor) {

@@ -33,2 +33,5 @@ // Copyright 2012 The Obvious Corporation.

/** extended type name */
var ERROR = "error";
/** type name */

@@ -52,2 +55,5 @@ var FUNCTION = "function";

/** extended type name */
var REGEXP = "regexp";
/** type name */

@@ -74,6 +80,15 @@ var STRING = "string";

/** the base prototype of error objects */
var ERROR_PROTOTYPE = Error.prototype;
/** the prototype of regexp objects */
var REGEXP_PROTOTYPE = RegExp.prototype;
/** the function object `Object.hasOwnProperty` */
var HAS_OWN_PROPERTY_FUNC = Object.hasOwnProperty;
/** the base `Object.toString()` method */
var objectToString = Object.prototype.toString;
/*

@@ -83,2 +98,15 @@ * Helper functions

/**
* Call the base `Object.toString()` method. This is used as part of
* type determination to help avoid cases where (through ignorance or malice)
* user-defined objects try to abuse the core underlying classes.
*
* The tactic here (that is, how this function is used) was learned
* from the Node `util` module.
*/
function baseToString(value) {
return objectToString.call(value);
}
function extendedTypeOf(value) {

@@ -110,2 +138,6 @@ var type = typeof value;

return DATE;
} else if (isError(value)) {
return ERROR;
} else if (isRegExp(value)) {
return REGEXP;
} else if (isMap(value)) {

@@ -131,3 +163,4 @@ return MAP;

case INT:
case NUMBER:
case NUMBER:
case REGEXP:
case UINT: {

@@ -137,2 +170,8 @@ message += " (" + value + ")";

}
case ERROR: {
if (value.message) {
message += " (" + value.message + ")";
}
break;
}
case FUNCTION: {

@@ -180,3 +219,5 @@ if (value.name) {

function isDate(x) {
return Object.getPrototypeOf(x) === DATE_PROTOTYPE;
return isObject(x) &&
(Object.getPrototypeOf(x) === DATE_PROTOTYPE) &&
(baseToString(x) === '[object Date]');
}

@@ -192,2 +233,24 @@

function isError(x) {
return isObject(x) &&
(baseToString(x) === '[object Error]') &&
hasErrorProto(x);
function hasErrorProto(obj) {
while (obj && (obj !== OBJECT_PROTOTYPE)) {
if (obj === ERROR_PROTOTYPE) {
return true;
}
obj = Object.getPrototypeOf(obj);
}
return false;
}
}
function isRegExp(x) {
return isObject(x) &&
(Object.getPrototypeOf(x) === REGEXP_PROTOTYPE) &&
(baseToString(x) === '[object RegExp]');
}
function isString(x) {

@@ -287,2 +350,8 @@ return (typeof x) === STRING;

function assertError(x) {
if (!isError(x)) {
failType(x, ERROR);
}
}
function assertInt(x) {

@@ -312,2 +381,8 @@ if (!isInt(x)) {

function assertRegExp(x) {
if (!isRegExp(x)) {
failType(x, REGEXP);
}
}
function assertString(x) {

@@ -348,2 +423,3 @@ if (!isString(x)) {

assertDefined: assertDefined,
assertError: assertError,
assertFunction: assertFunction,

@@ -354,2 +430,3 @@ assertInt: assertInt,

assertObject: assertObject,
assertRegExp: assertRegExp,
assertString: assertString,

@@ -367,2 +444,3 @@ assertUint: assertUint,

isDefined: isDefined,
isError: isError,
isInt: isInt,

@@ -373,2 +451,3 @@ isFunction: isFunction,

isObject: isObject,
isRegExp: isRegExp,
isString: isString,

@@ -375,0 +454,0 @@ isUint: isUint,

{
"name": "bidar",
"version": "0.3.2",
"version": "0.3.3",
"keywords":

@@ -5,0 +5,0 @@ ["object", "serialization", "data", "graph"],

@@ -182,3 +182,3 @@ Bidar: Binary Data Representation.

It is possible for a hole replacement to itself have holes in it. this
It is possible for a hole replacement to itself have holes in it. This
is fine, so long as the hole replacer can successfully replace all the

@@ -185,0 +185,0 @@ holes, eventually bottoming out at pure data in some form.

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