MCPcopy Create free account
hub / github.com/mapbox/pbf / compileFieldWrite

Function compileFieldWrite

compile.js:185–196  ·  view source on GitHub ↗
(ctx, field, name)

Source from the content-addressed store, hash-verified

183}
184
185function compileFieldWrite(ctx, field, name) {
186 const sub = getSubMessage(ctx, field);
187 if (sub) return `pbf.writeMessage(${field.tag}, write${sub._name}, ${name})`;
188
189 if (fieldShouldUseStringAsNumber(field)) {
190 name = field.type === 'float' || field.type === 'double' ?
191 `parseFloat(${name})` : `parseInt(${name}, 10)`;
192 }
193 const {m} = getMethod(ctx, field);
194 const fn = isPacked(field) ? `writePacked${m}` : `write${m}Field`;
195 return `pbf.${fn}(${field.tag}, ${name})`;
196}
197
198function getMapMessage(field) {
199 const f = (name, type, tag) => ({name, type, tag, oneof: null, repeated: false, options: {}});

Callers 1

compileFieldWriteLineFunction · 0.85

Calls 4

getSubMessageFunction · 0.85
getMethodFunction · 0.85
isPackedFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…