jsyaml

package
v6.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package jsyaml writes YAML and JSON exactly as the TypeScript CLI did with js-yaml's dump and JSON.stringify. Users keep the files `get` writes in Git; any difference in formatting would show up as a change to every one of them after upgrading.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clone

func Clone(value any) any

Clone copies a value deeply, so that one copy can be trimmed for a request while the other is written back to its file intact.

func CompactJSON

func CompactJSON(value any) string

CompactJSON renders like JSON.stringify(value).

func Dump

func Dump(value any) string

Dump renders a value as js-yaml's dump did, trailing newline included.

func JSON

func JSON(value any) string

JSON renders like JSON.stringify(value, undefined, 2).

func NumberString

func NumberString(f float64) string

NumberString formats a float64 as JavaScript's Number.prototype.toString does.

Types

type Map

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

Map is a JavaScript object: string keys in JavaScript's iteration order.

func NewMap

func NewMap() *Map

func (*Map) Delete

func (m *Map) Delete(key string)

func (*Map) Get

func (m *Map) Get(key string) (any, bool)

func (*Map) Keys

func (m *Map) Keys() []string

Keys in JavaScript's order: keys that are array indices first, ascending, then the rest in insertion order. JSON.parse and js-yaml both see objects this way.

func (*Map) Len

func (m *Map) Len() int

func (*Map) Set

func (m *Map) Set(key string, value any)

Set keeps a key's first position when it is set again, as assigning to a JavaScript object property does.

func (*Map) SetFirst

func (m *Map) SetFirst(key string, value any)

SetFirst puts a key at the start, as the spread `{ key, ...experiment }` did.

type Timestamp

type Timestamp time.Time

Timestamp is a YAML timestamp read from a file, a JavaScript Date in the TypeScript CLI.

func (Timestamp) ISO

func (t Timestamp) ISO() string

Jump to

Keyboard shortcuts

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