14 lines
747 B
JavaScript
14 lines
747 B
JavaScript
|
|
import { Encoder } from "./Encoder.mjs";
|
||
|
|
var defaultEncodeOptions = {};
|
||
|
|
/**
|
||
|
|
* It encodes `value` in the MessagePack format and
|
||
|
|
* returns a byte buffer.
|
||
|
|
*
|
||
|
|
* The returned buffer is a slice of a larger `ArrayBuffer`, so you have to use its `#byteOffset` and `#byteLength` in order to convert it to another typed arrays including NodeJS `Buffer`.
|
||
|
|
*/
|
||
|
|
export function encode(value, options) {
|
||
|
|
if (options === void 0) { options = defaultEncodeOptions; }
|
||
|
|
var encoder = new Encoder(options.extensionCodec, options.context, options.maxDepth, options.initialBufferSize, options.sortKeys, options.forceFloat32, options.ignoreUndefined, options.forceIntegerToFloat);
|
||
|
|
return encoder.encodeSharedRef(value);
|
||
|
|
}
|
||
|
|
//# sourceMappingURL=encode.mjs.map
|