utilium
    Preparing search index...

    Function getByString

    • Get a value using a path of property keys.

      Type Parameters

      Parameters

      • object: T
      • path: P

      Returns GetByPath<T, FilterOut<Split<`${P}`, KeySeparator>, "">>

      Translation keys mapping to locale objects

      const locale = {
      preference: {
      theme: {
      label: 'Theme'
      }
      }
      } as const;

      const text = getByString(locale, 'preference.theme.label'); // 'Theme'

      Arrays

      const pascal = {
      triangle: [
      [1],
      [1, 1],
      [1, 2, 1],
      [1, 3, 3, 1],
      [1, 4, 6, 4, 1]
      ]
      } as const;

      const row3 = getByString(pascal, 'triangle[3]'); // readonly [1, 3, 3, 1]
      const r4c3 = getByString(pascal, 'triangle[4][2]'); // 6