Skip to main content
Module

x/obsidian/src/normalize.ts>normalizeObject

GraphQL, built for Deno - a native GraphQL caching client and server module
Latest
variable normalizeObject
import { normalizeObject } from "https://deno.land/x/obsidian@v8.0.0/src/normalize.ts";

Recursively flattens an arbitrarily nested object into an objects with hash key and hashable object pairs

For each key in object (typeof === 'object', meaning it can be array):

  1. If current object contains hashable object and if it hasn't printed already, it prints a hashable object and makes its associated hash. If hash doesn't exist in normalizedHashableObjects, it adds hash key and hashable object pair.

  2. If the value at the current key is an object (typeof === 'object', meaning it can be array), it recursively calls normalizeObject with the value passed in. This recursive calls goes inside arbitrary nesting.

  3. Return normalizedHashableObjects. In the outer most execution context, this will return the output of the function. In inner execution contexts, this will return that execution context's normalizedHashableObjects.

type

(
nestedObject: GenericObject,
hashableKeys: Array<string>,
normalizedHashableObjects?: GenericObject,
) => GenericObject