Primitives

Python equivalents of JavaScript primitives that don’t have a natural Python analogue.

jstypes.JSUndefined

jstypes.JSUndefined

Represents the JavaScript value undefined.

jstypes.JSPrimitiveObject

jstypes.JSPrimitiveObject(self, value, tag=None)

Python equivalent of a wrapped/boxed JavaScript primitive.

Tip

This is a low-level type that won’t occur in decoded data by default, and can be ignored.

JavaScript primitives like string and number have object wrapper types like String and Number which are used when calling methods on primitives. JSPrimitiveObject represents primitives wrapped in this way.

In JavaScript, the difference between a wrapped and plain primitive is not visible, and the same is the case by default with v8serialize, as the default decoding behaviour is to unwrap wrapped primitive objects. So users of v8serialize shouldn’t encounter this type in decoded values, and don’t need to handle it.

JSPrimitiveObject has two main uses:

  • It allows primitive values to be serialized once and referenced multiple times in a V8 serialized data stream. This could be used to de-duplicate strings or bigints.
  • It allows data streams to be round-tripped exactly.

Attributes

Name Description
tag The type of primitive wrapped in this object.
value The primitive value.