(val, key)
| 849 | valueSubtype = subtypes[1]; |
| 850 | } |
| 851 | function addItem(val, key) { |
| 852 | if (key === null || typeof key === 'undefined' || key === types.unset) { |
| 853 | throw new TypeError('A map can\'t contain null or unset keys'); |
| 854 | } |
| 855 | if (val === null || typeof val === 'undefined' || val === types.unset) { |
| 856 | throw new TypeError('A map can\'t contain null or unset values'); |
| 857 | } |
| 858 | const keyBuffer = self.encode(key, keySubtype); |
| 859 | //include item byte length |
| 860 | parts.push(self.getLengthBuffer(keyBuffer)); |
| 861 | //include item |
| 862 | parts.push(keyBuffer); |
| 863 | //value |
| 864 | const valueBuffer = self.encode(val, valueSubtype); |
| 865 | //include item byte length |
| 866 | parts.push(self.getLengthBuffer(valueBuffer)); |
| 867 | //include item |
| 868 | if (valueBuffer !== null) { |
| 869 | parts.push(valueBuffer); |
| 870 | } |
| 871 | propCounter++; |
| 872 | } |
| 873 | if (this.encodingOptions.map && value instanceof this.encodingOptions.map) { |
| 874 | //Use Map#forEach() method to iterate |
| 875 | value.forEach(addItem); |
no test coverage detected