(type, value)
| 1679 | delete config.name; |
| 1680 | } |
| 1681 | resolveValue(type, value) { |
| 1682 | switch (type) { |
| 1683 | case "bool": |
| 1684 | return "true" === value; |
| 1685 | case "nul": |
| 1686 | case "null": |
| 1687 | return null; |
| 1688 | case "date": |
| 1689 | return "Date.now()"; |
| 1690 | case "json": |
| 1691 | if (!value) |
| 1692 | throw new Error("missing value"); |
| 1693 | return value; |
| 1694 | case "num": |
| 1695 | if ("" === value) // historical: https://cookbook.nodered.org/basic/join-streams |
| 1696 | return 0; |
| 1697 | return parseFloat(value); |
| 1698 | case "str": |
| 1699 | return `${JSON.stringify(value ?? "")}`; |
| 1700 | case "re": |
| 1701 | return `/${value}/`; |
| 1702 | case "bin": |
| 1703 | if (!value) |
| 1704 | return `Uint8Array.of()`; |
| 1705 | return `Uint8Array.of(${value.slice(1, value.length - 1)})`; |
| 1706 | case "msg": |
| 1707 | return `msg${this.prepareProp(value)}`; |
| 1708 | case "flow": |
| 1709 | case "global": { |
| 1710 | if (!value) |
| 1711 | throw new Error(`missing name`); |
| 1712 | let suffix = ""; |
| 1713 | let i = value.indexOf("["); |
| 1714 | let j = value.indexOf("."); |
| 1715 | if ((i > 0) || (j > 0)) { |
| 1716 | let first; |
| 1717 | if ((i > 0) && (j < 0)) |
| 1718 | first = i; |
| 1719 | else if ((j > 0) && (i < 0)) |
| 1720 | first = j; |
| 1721 | else |
| 1722 | first = Math.min(i, j); |
| 1723 | suffix = value.slice(first); |
| 1724 | value = value.slice(0, first); //@@ if "." may need to check regexIdentifierNameES6 |
| 1725 | } |
| 1726 | |
| 1727 | suffix = suffix.trim(suffix) |
| 1728 | if (suffix) { |
| 1729 | if (suffix.startsWith("[")) |
| 1730 | suffix = "?." + suffix; |
| 1731 | else |
| 1732 | suffix = "?" + suffix; |
| 1733 | } |
| 1734 | if ("flow" === type) |
| 1735 | return `this.flow.get(${this.makeStorageArgs(value)})${suffix}`; |
| 1736 | return `globalContext.get(${this.makeStorageArgs(value)})${suffix}`; |
| 1737 | } |
| 1738 | case "env": { |
no test coverage detected