web-auto-extractor
Advanced tools
Comparing version 0.3.0 to 0.3.1
@@ -52,2 +52,3 @@ 'use strict'; | ||
var idList = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1]; | ||
var path = arguments.length <= 2 || arguments[2] === undefined ? ['$'] : arguments[2]; | ||
@@ -58,10 +59,29 @@ if (idList.length === 0) { | ||
}); | ||
// START SIDE EFFECT: ITEM PATH INFO | ||
idList.forEach(function (id, index) { | ||
items[id].path = path.concat(index); | ||
}); | ||
// END SIDE EFFECT: ITEM PATH INFO | ||
} | ||
return idList.map(function (id) { | ||
return idList.map(function (id, index) { | ||
var _items$id = items[id]; | ||
var context = _items$id.context; | ||
var type = _items$id.type; | ||
var name = _items$id.name; | ||
var value = _items$id.value; | ||
var properties = _items$id.properties; | ||
// START SIDE EFFECT: ITEM PATH INFO | ||
if (!items[id].path) { | ||
if (idList.length > 1) { | ||
idList.forEach(function (id, index) { | ||
items[id].path = path.concat([name, index]); | ||
}); | ||
} else { | ||
idList.forEach(function (id, index) { | ||
items[id].path = path.concat(name); | ||
}); | ||
} | ||
} | ||
// END: ITEM PATH INFO | ||
if (!type) { | ||
@@ -72,3 +92,3 @@ return value; | ||
Object.keys(properties).map(function (key) { | ||
var propValue = normalize(items, properties[key]); | ||
var propValue = normalize(items, properties[key], items[id].path); | ||
if (propValue.length === 1) { | ||
@@ -75,0 +95,0 @@ normalizedProperties[key] = propValue[0]; |
{ | ||
"name": "web-auto-extractor", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "Automatically extracts structured information from webpages", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
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
18285
320