New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

manyfest

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

manyfest - npm Package Compare versions

Comparing version 1.0.6 to 1.0.7

test/Manyfest_Object_ReadSets_tests.js

2

.config/configstore/update-notifier-npm.json
{
"optOut": false,
"lastUpdateCheck": 1665932798321
"lastUpdateCheck": 1666021392557
}
{
"name": "manyfest",
"version": "1.0.6",
"version": "1.0.7",
"description": "JSON Object Manifest for Data Description and Parsing",

@@ -5,0 +5,0 @@ "main": "source/Manyfest.js",

@@ -96,3 +96,3 @@ /**

// 3) There is data
&& (tmpBracketStopIndex - tmpBracketStartIndex > 0))
&& (tmpBracketStopIndex - tmpBracketStartIndex > 1))
{

@@ -171,3 +171,3 @@ // The "Name" of the Object contained too the left of the bracket

// 3) There is data
&& (tmpBracketStopIndex - tmpBracketStartIndex > 0))
&& (tmpBracketStopIndex - tmpBracketStartIndex > 1))
{

@@ -242,3 +242,3 @@ let tmpBoxedPropertyName = tmpSubObjectName.substring(0, tmpBracketStartIndex).trim();

// Get the value of an element at an address
getValueAtAddress (pObject, pAddress)
getValueAtAddress (pObject, pAddress, pParentAddress)
{

@@ -249,2 +249,7 @@ // Make sure pObject is an object

if (typeof(pAddress) != 'string') return undefined;
let tmpParentAddress = "";
if (typeof(pParentAddress) == 'string')
{
tmpParentAddress = pParentAddress;
}

@@ -260,2 +265,7 @@ // TODO: Make this work for things like SomeRootObject.Metadata["Some.People.Use.Bad.Object.Property.Names"]

let tmpBracketStopIndex = pAddress.indexOf(']');
// Check for the Object Set Type marker.
// Note this will not work with a bracket in the same address box set
let tmpObjectTypeMarkerIndex = pAddress.indexOf('{}');
// Boxed elements look like this:

@@ -274,3 +284,3 @@ // MyValues[10]

// 3) There is data
&& (tmpBracketStopIndex - tmpBracketStartIndex > 0))
&& (tmpBracketStopIndex - tmpBracketStartIndex > 1))
{

@@ -320,2 +330,33 @@ // The "Name" of the Object contained too the left of the bracket

}
// The requirements to detect a boxed set element are:
// 1) The start bracket is after character 0
else if ((tmpBracketStartIndex > 0)
// 2) The end bracket is after the start bracket
&& (tmpBracketStopIndex > tmpBracketStartIndex)
// 3) There is nothing in the brackets
&& (tmpBracketStopIndex - tmpBracketStartIndex == 1))
{
let tmpBoxedPropertyName = pAddress.substring(0, tmpBracketStartIndex).trim();
if (!Array.isArray(pObject[tmpBoxedPropertyName]))
{
// We asked for a set from an array but it isnt' an array.
return false;
}
return pObject[tmpBoxedPropertyName];
}
// The object has been flagged as an object set, so treat it as such
else if (tmpObjectTypeMarkerIndex > 0)
{
let tmpObjectPropertyName = pAddress.substring(0, tmpObjectTypeMarkerIndex).trim();
if (typeof(pObject[tmpObjectPropertyName]) != 'object')
{
// We asked for a set from an array but it isnt' an array.
return false;
}
return pObject[tmpObjectPropertyName];
}
else

@@ -332,2 +373,3 @@ {

// BOXED ELEMENTS
// Test if the tmpNewAddress is an array or object

@@ -350,3 +392,3 @@ // Check if it's a boxed property

// 3) There is data
&& (tmpBracketStopIndex - tmpBracketStartIndex > 0))
&& (tmpBracketStopIndex - tmpBracketStartIndex > 1))
{

@@ -388,12 +430,77 @@ let tmpBoxedPropertyName = tmpSubObjectName.substring(0, tmpBracketStartIndex).trim();

// Continue to manage the parent address for recursion
tmpParentAddress = `${tmpParentAddress}${(tmpParentAddress.length > 0) ? '.' : ''}${tmpSubObjectName}`;
// Recurse directly into the subobject
return this.getValueAtAddress(pObject[tmpBoxedPropertyName][tmpBoxedPropertyReference], tmpNewAddress);
return this.getValueAtAddress(pObject[tmpBoxedPropertyName][tmpBoxedPropertyReference], tmpNewAddress, tmpParentAddress);
}
else
{
// Continue to manage the parent address for recursion
tmpParentAddress = `${tmpParentAddress}${(tmpParentAddress.length > 0) ? '.' : ''}${tmpSubObjectName}`;
// We parsed a valid number out of the boxed property name, so recurse into the array
return this.getValueAtAddress(pObject[tmpBoxedPropertyName][tmpBoxedPropertyNumber], tmpNewAddress);
return this.getValueAtAddress(pObject[tmpBoxedPropertyName][tmpBoxedPropertyNumber], tmpNewAddress, tmpParentAddress);
}
}
// The requirements to detect a boxed set element are:
// 1) The start bracket is after character 0
else if ((tmpBracketStartIndex > 0)
// 2) The end bracket is after the start bracket
&& (tmpBracketStopIndex > tmpBracketStartIndex)
// 3) There is nothing in the brackets
&& (tmpBracketStopIndex - tmpBracketStartIndex == 1))
{
let tmpBoxedPropertyName = pAddress.substring(0, tmpBracketStartIndex).trim();
if (!Array.isArray(pObject[tmpBoxedPropertyName]))
{
// We asked for a set from an array but it isnt' an array.
return false;
}
// We need to enumerate the array and grab the addresses from there.
let tmpArrayProperty = pObject[tmpBoxedPropertyName];
// Managing the parent address is a bit more complex here -- the box will be added for each element.
tmpParentAddress = `${tmpParentAddress}${(tmpParentAddress.length > 0) ? '.' : ''}${tmpBoxedPropertyName}`;
// The container object is where we have the "Address":SOMEVALUE pairs
let tmpContainerObject = {};
for (let i = 0; i < tmpArrayProperty.length; i++)
{
let tmpPropertyParentAddress = `${tmpParentAddress}[${i}]`;
let tmpValue = this.getValueAtAddress(pObject[tmpBoxedPropertyName][i], tmpNewAddress, tmpPropertyParentAddress);;
tmpContainerObject[`${tmpPropertyParentAddress}.${tmpNewAddress}`] = tmpValue;
}
return tmpContainerObject;
}
// OBJECT SET
// Note this will not work with a bracket in the same address box set
let tmpObjectTypeMarkerIndex = pAddress.indexOf('{}');
if (tmpObjectTypeMarkerIndex > 0)
{
let tmpObjectPropertyName = pAddress.substring(0, tmpObjectTypeMarkerIndex).trim();
if (typeof(pObject[tmpObjectPropertyName]) != 'object')
{
// We asked for a set from an array but it isnt' an array.
return false;
}
// We need to enumerate the Object and grab the addresses from there.
let tmpObjectProperty = pObject[tmpObjectPropertyName];
let tmpObjectPropertyKeys = Object.keys(tmpObjectProperty);
// Managing the parent address is a bit more complex here -- the box will be added for each element.
tmpParentAddress = `${tmpParentAddress}${(tmpParentAddress.length > 0) ? '.' : ''}${tmpObjectPropertyName}`;
// The container object is where we have the "Address":SOMEVALUE pairs
let tmpContainerObject = {};
for (let i = 0; i < tmpObjectPropertyKeys.length; i++)
{
let tmpPropertyParentAddress = `${tmpParentAddress}.${tmpObjectPropertyKeys[i]}`;
let tmpValue = this.getValueAtAddress(pObject[tmpObjectPropertyName][tmpObjectPropertyKeys[i]], tmpNewAddress, tmpPropertyParentAddress);;
tmpContainerObject[`${tmpPropertyParentAddress}.${tmpNewAddress}`] = tmpValue;
}
return tmpContainerObject;
}
// If there is an object property already named for the sub object, but it isn't an object

@@ -408,3 +515,5 @@ // then the system can't set the value in there. Error and abort!

// If there is already a subobject pass that to the recursive thingy
return this.getValueAtAddress(pObject[tmpSubObjectName], tmpNewAddress);
// Continue to manage the parent address for recursion
tmpParentAddress = `${tmpParentAddress}${(tmpParentAddress.length > 0) ? '.' : ''}${tmpSubObjectName}`;
return this.getValueAtAddress(pObject[tmpSubObjectName], tmpNewAddress, tmpParentAddress);
}

@@ -414,4 +523,6 @@ else

// Create a subobject and then pass that
// Continue to manage the parent address for recursion
tmpParentAddress = `${tmpParentAddress}${(tmpParentAddress.length > 0) ? '.' : ''}${tmpSubObjectName}`;
pObject[tmpSubObjectName] = {};
return this.getValueAtAddress(pObject[tmpSubObjectName], tmpNewAddress);
return this.getValueAtAddress(pObject[tmpSubObjectName], tmpNewAddress, tmpParentAddress);
}

@@ -449,3 +560,3 @@ }

// 3) There is data
&& (tmpBracketStopIndex - tmpBracketStartIndex > 0))
&& (tmpBracketStopIndex - tmpBracketStartIndex > 1))
{

@@ -526,3 +637,3 @@ // The "Name" of the Object contained too the left of the bracket

// 3) There is data
&& (tmpBracketStopIndex - tmpBracketStartIndex > 0))
&& (tmpBracketStopIndex - tmpBracketStartIndex > 1))
{

@@ -529,0 +640,0 @@ let tmpBoxedPropertyName = tmpSubObjectName.substring(0, tmpBracketStartIndex).trim();

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