Huge News!Announcing our $40M Series B led by Abstract Ventures.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.4 to 1.0.5

2

package.json
{
"name": "manyfest",
"version": "1.0.4",
"version": "1.0.5",
"description": "JSON Object Manifest for Data Description and Parsing",

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

@@ -186,11 +186,3 @@ /**

{
if (this.elementHashes.hasOwnProperty(pHash) || this.hashTranslations.translationTable.hasOwnProperty(pHash))
{
return this.getDescriptor(this.elementHashes[this.hashTranslations.translate(pHash)]);
}
else
{
this.logError(`(${this.scope}) Error in getDescriptorByHash; the Hash ${pHash} doesn't exist in the schema.`);
return undefined;
}
return this.getDescriptor(this.resolveHashAddress(pHash));
}

@@ -209,11 +201,3 @@

{
if (this.elementHashes.hasOwnProperty(pHash) || this.hashTranslations.translationTable.hasOwnProperty(pHash))
{
return this.checkAddressExists(pObject, this.elementHashes[this.hashTranslations.translate(pHash)]);
}
else
{
this.logError(`(${this.scope}) Error in checkAddressExistsByHash; the Hash ${pHash} doesn't exist in the schema.`);
return undefined;
}
return this.checkAddressExists(pObject,this.resolveHashAddress(pHash));
}

@@ -227,17 +211,41 @@

// Turn a hash into an address, factoring in the translation table.
resolveHashAddress(pHash)
{
let tmpAddress = undefined;
// Get the value of an element by its hash
getValueByHash (pObject, pHash)
{
if (this.elementHashes.hasOwnProperty(pHash) || this.hashTranslations.translationTable.hasOwnProperty(pHash))
let tmpInElementHashTable = this.elementHashes.hasOwnProperty(pHash);
let tmpInTranslationTable = this.hashTranslations.translationTable.hasOwnProperty(pHash);
// The most straightforward: the hash exists, no translations.
if (tmpInElementHashTable && !tmpInTranslationTable)
{
return this.getValueAtAddress(pObject, this.elementHashes[this.hashTranslations.translate(pHash)]);
tmpAddress = this.elementHashes[pHash];
}
// There is a translation from one hash to another, and, the elementHashes contains the pointer end
else if (tmpInTranslationTable && this.elementHashes.hasOwnProperty(this.hashTranslations.translate(pHash)))
{
tmpAddress = this.elementHashes[this.hashTranslations.translate(pHash)];
}
// Use the level of indirection only in the Translation Table
else if (tmpInTranslationTable)
{
tmpAddress = this.hashTranslations.translate(pHash);
}
// Just treat the hash as an address.
// TODO: Discuss this ... it is magic but controversial
else
{
this.logError(`(${this.scope}) Error in getValueByHash; the Hash ${pHash} doesn't exist in the schema.`);
return undefined;
tmpAddress = pHash;
}
return tmpAddress;
}
// Get the value of an element by its hash
getValueByHash (pObject, pHash)
{
return this.getValueAtAddress(pObject, this.resolveHashAddress(pHash));
}
// Get the value of an element at an address

@@ -252,11 +260,3 @@ getValueAtAddress (pObject, pAddress)

{
if (this.elementHashes.hasOwnProperty(pHash) || this.hashTranslations.translationTable.hasOwnProperty(pHash))
{
return this.setValueAtAddress(pObject, this.elementHashes[this.hashTranslations.translate(pHash)], pValue);
}
else
{
this.logError(`(${this.scope}) Error in setValueByHash; the Hash ${pHash} doesn't exist in the schema. Value ${pValue} will not be written!`);
return undefined;
}
return this.setValueAtAddress(pObject, this.resolveHashAddress(pHash), pValue);
}

@@ -263,0 +263,0 @@

@@ -151,2 +151,18 @@ /**

(
'Translate to a value not in the hashes, falling back to address.',
(fTestComplete)=>
{
let _Manyfest = new libManyfest({ Scope:'Archive.org', Descriptors: {'metadata.creator': {Name:'Creator', Hash:'Creator'}}});
// Create a translation between "Creator" and "metadata.identifier", which isn't in the manifest in any way
_Manyfest.hashTranslations.addTranslation({"Creator":"metadata.identifier"});
// This address is not in the descriptor address list or the hash list
Expect(_Manyfest.getValueAtAddress(_SampleDataArchiveOrgFrankenberry, 'metadata.identifier')).to.equal('FrankenberryCountChoculaTevevisionCommercial1971');
// But now we've pointed the Creator hash to it!
Expect(_Manyfest.getValueByHash(_SampleDataArchiveOrgFrankenberry, 'Creator')).to.equal('FrankenberryCountChoculaTevevisionCommercial1971');
fTestComplete();
}
);
test
(
'Add a bogus translation.',

@@ -153,0 +169,0 @@ (fTestComplete)=>

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