onix-parser
Version:
Parse ONIX 3.0 XML files and extract structured product data for publishing and digital books
29 lines (21 loc) • 707 B
JavaScript
const { getJSONfromFile, getByValue } = require('../lib/utils')
const ProductIdentifierTypeList = getJSONfromFile('CodeLists/productIdentifierType.json')
const identifier = ProductIdentifier => {
if (!ProductIdentifier) return []
const identifierList = []
for (let i = 0; i < ProductIdentifier.length; i++) {
const {
b221: ProductIDType,
b244: IDValue
} = ProductIdentifier[i];
identifierList.push({
productIDTypeCode: ProductIDType.$t,
productIDType: getByValue(ProductIdentifierTypeList, 'Value', ProductIDType.$t, 'Description'),
iDValue: IDValue.$t
})
}
return identifierList
}
module.exports = {
identifier
}