ixfx
    Preparing search index...
    • Creates a wrapper for working with 'pathed' trees. An example is a filesystem.

      const t = create();
      // Store a value. Path implies a structure of
      // c -> users -> admin
      // ...which is autoatically created
      t.add({x:10}, `c.users.admin`);

      t.add({x:20}, `c.users.guest`);
      // Tree will now be:
      // c-> users -> admin
      // -> guest

      t.getValue(`c.users.guest`); // { x:20 }

      By default only a single value can be stored at a path. Set options to allow this:

      const t = create({ duplicates: `allow` });
      t.add({x:10}, `c.users.admin`);
      t.add({x:20}, `c.users.admin`);
      t.getValue(`c.users.admin`); // Throws an error because there are multiple values
      t.getValues(`c.users.admin`); // [ {x:10}, {x:20 } ]

      Type Parameters

      • T

      Parameters

      • pathOpts: Partial<
            Readonly<
                { duplicates: "ignore"
                | "allow"
                | "overwrite"; separator: string },
            >,
        > = {}

      Returns {
          add: (value: T, path: string) => void;
          childrenLength: (path: string) => number;
          clearValues: (path: string) => boolean;
          getNode: (path: string) => undefined | LabelledNode<T>;
          getRoot: () => undefined | TreeNode<LabelledValue<T>>;
          getValue: (path: string) => undefined | T;
          getValues: (path: string) => T[];
          hasPath: (path: string) => boolean;
          prettyPrint: () => string;
          remove: (path: string) => boolean;
      }