wasm-json-toolkit
Advanced tools
Comparing version 0.2.1 to 0.2.2
23
index.js
/** | ||
* Converts a wasm binary into a json representation | ||
* @param {Buffer} | ||
* @return {Object} | ||
* @return {Array} | ||
*/ | ||
@@ -10,3 +10,3 @@ exports.wasm2json = require('./wasm2json') | ||
* Converts a json representation to a wasm binary | ||
* @param {Object} | ||
* @param {Array} | ||
* @return {Buffer} | ||
@@ -30,21 +30,26 @@ */ | ||
exports.findSections = function * (array, sectionOrder) { | ||
/** | ||
* iterates thourgh an array of sections returning a subset of sections | ||
* @param {Array} | ||
* @param {Sections} | ||
*/ | ||
exports.findSections = function * (array, sections) { | ||
let section = array[0] | ||
let index = 0 | ||
const wantedSections = new Set(sectionOrder) | ||
let nextSection = sectionOrder.shift() | ||
const wantedSections = new Set(sections) | ||
let nextSection = sections.shift() | ||
while (section) { | ||
if (!wantedSections.has(section.name)) { | ||
if (!wantedSections.has(section.sectionName || section.name)) { | ||
section = array[++index] | ||
} else { | ||
if (section.name === nextSection) { | ||
if ((section.sectionName || section.name) === nextSection) { | ||
yield section | ||
section = array[++index] | ||
} else { | ||
yield null | ||
yield | ||
} | ||
nextSection = sectionOrder.shift() | ||
nextSection = sections.shift() | ||
} | ||
} | ||
} |
{ | ||
"name": "wasm-json-toolkit", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "this convertes wasm binaries to json and json to wasm binaries", | ||
@@ -10,3 +10,3 @@ "main": "index.js", | ||
"lint": "standard", | ||
"test": "node --harmony ./test/index.js" | ||
"test": "node ./test/index.js" | ||
}, | ||
@@ -13,0 +13,0 @@ "keywords": [ |
@@ -20,3 +20,3 @@ const fs = require('fs') | ||
t.equals(results.length, 3) | ||
t.equals(results[1], null) | ||
t.equals(results[1], undefined) | ||
t.equals(results[0].name, 'type') | ||
@@ -23,0 +23,0 @@ t.equals(results[2].name, 'export') |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
434531
2156
409