ops

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ops writes a commit's operations as JSON for a host that draws them: an array of arrays, each led by its code and the view's ID. It is written by hand, as a batch is built at every commit and reflection would weigh on the host's size and time.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendNum

func AppendNum(b []byte, v float64) []byte

AppendNum appends v rounded to a hundredth, and zero for NaN and the infinities.

func AppendString

func AppendString(b []byte, s string) []byte

AppendString appends s as a JSON string. Invalid UTF-8 becomes the replacement character and the line separators U+2028 and U+2029 are escaped, as both end a JavaScript line the host reads the batch on.

Types

type Object

type Object struct {
	// contains filtered or unexported fields
}

Object builds a JSON object for an operation's argument.

func (*Object) Bool

func (j *Object) Bool(k string, v bool) *Object

Bool adds a boolean member.

func (*Object) Bytes

func (j *Object) Bytes() []byte

Bytes returns the object as JSON.

func (*Object) Key

func (j *Object) Key(k string)

Key starts a member.

func (*Object) Num

func (j *Object) Num(k string, v float64) *Object

Num adds a number member.

func (*Object) Raw

func (j *Object) Raw(k string, v []byte) *Object

Raw adds a member written elsewhere.

func (*Object) Str

func (j *Object) Str(k, v string) *Object

Str adds a string member.

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

Writer builds one batch's operations.

func (*Writer) Bool

func (w *Writer) Bool(v bool) *Writer

Bool appends a boolean.

func (*Writer) Bytes

func (w *Writer) Bytes() []byte

Bytes returns the batch as JSON.

func (*Writer) Empty

func (w *Writer) Empty() bool

Empty reports whether w holds no operation.

func (*Writer) Null

func (w *Writer) Null() *Writer

Null appends null.

func (*Writer) Num

func (w *Writer) Num(v float64) *Writer

Num appends a number, rounded to a hundredth: the render layer's pixels need no more.

func (*Writer) Op

func (w *Writer) Op(code string, id driver.NodeID) *Writer

Op starts an operation on view id; its arguments follow.

func (*Writer) Pt

func (w *Writer) Pt(v driver.Points) *Writer

Pt appends a point.

func (*Writer) Raw

func (w *Writer) Raw(json []byte) *Writer

Raw appends JSON written elsewhere.

func (*Writer) Reset

func (w *Writer) Reset()

Reset empties w for the next batch.

func (*Writer) Str

func (w *Writer) Str(s string) *Writer

Str appends a string.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL