Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/localekit/util/flatten.ts>Flattened

A translation plugin for Deno
Go to Latest
class Flattened
import { Flattened } from "https://deno.land/x/localekit@0.9.0/util/flatten.ts";

Constructors

new
Flattened(flattened?: FlattenedObject | Flattened)

Properties

__data: Record<string, unknown>
__map: Record<string, string>

Methods

getKey<T = unknown>(key: string): T

Retrieves the value associated with the specified key from the data object.

getMappedKey(key: string): string

Retrieves the mapped value for the given key.

hasKey(key: string): boolean

Checks if the specified key exists in the flattened object.

Merges the provided flattened object into the current Flattened object.

mergeObject(obj: Record<string, unknown>): Flattened

Merges the provided object into a flattened structure.

toObject<T = Record<string, unknown>>(): T

Converts the Flattened object to a nested object that should match the original object.

toString(): string

Returns a string representation of the object.

Static Properties

private
flatten: { encodeKeyPart(
part: string,
val_type: ValueType,
secondary_val_type?: ValueType,
): string; getType(
key: string,
value: unknown,
manual_value_type?: ValueType,
): { key: string; raw_key: string; value_type: ValueType; invalid: boolean; }; setProperty(unnamed 0: { obj: Flattened; key: string; value: unknown; value_type: ValueType; raw_key: string; visited?: Map<object, string>; }): void; flattenObject(unnamed 0: { to_flatten: object; parent_key?: string; raw_parent_key?: string; result?: Flattened; visited?: Map<object, string>; }): Flattened; }

Utility class for flattening objects.

private
unflatten: { decodeKeyPart(part: string): { key: string; value_type: ValueType; secondary_value_type?: ValueType; }; setProperty(unnamed 0: { obj: Record<string, unknown> | unknown[]; key: string; value: unknown; value_type: ValueType; raw_key: string; }): void; unflattenObject(unnamed 0: { flattened: Flattened; }): Record<string, unknown>; }

Utility class for unflattening data.

private
utils: { generateMap(data: Record<string, unknown>): Record<string, string>; }
key_postfix

A mapping of value types to their corresponding postfix strings.

key_postfix_rev

Mapping of key postfixes to their corresponding value types.

Static Methods

fromFlattened(flattened: Flattened | FlattenedObject): Flattened

Creates a new Flattened instance from a flattened object.

toFlattened(obj: Record<string, unknown>): Flattened

Converts an object into a flattened representation.