* * @description Encode metadata fields based on incoming value. * If array, escape as color_id=[\"green\",\"red\"] * If string/number, escape as in_stock_id=50 * * Joins resulting values with a pipe: * in_stock_id=50|color_id=[\"green\",\"re
(metadataObj)
| 458 | * @return {string} |
| 459 | */ |
| 460 | function encode_context(metadataObj) { |
| 461 | if (!isObject(metadataObj)) { |
| 462 | return metadataObj; |
| 463 | } |
| 464 | |
| 465 | return entries(metadataObj).map(([key, value]) => { |
| 466 | // if string, simply parse the value and move on |
| 467 | if (isString(value)) { |
| 468 | return `${key}=${escapeMetadataValue(value)}`; |
| 469 | |
| 470 | // If array, parse each item individually |
| 471 | } else if (isArray(value)) { |
| 472 | let values = value.map((innerVal) => { |
| 473 | return `\"${escapeMetadataValue(innerVal)}\"` |
| 474 | }).join(','); |
| 475 | return `${key}=[${values}]` |
| 476 | // if number, convert to string |
| 477 | } else if (Number.isInteger(value)) { |
| 478 | return `${key}=${escapeMetadataValue(String(value))}`; |
| 479 | // if unknown, return the value as string |
| 480 | } else { |
| 481 | return value.toString(); |
| 482 | } |
| 483 | }).join('|'); |
| 484 | } |
| 485 | |
| 486 | function build_eager(transformations) { |
| 487 | return toArray(transformations) |
nothing calls this directly
no test coverage detected