lodash#Object TypeScript Examples

The following examples show how to use lodash#Object. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: i18next-electron-fs-backend.ts    From TidGi-Desktop with Mozilla Public License 2.0 6 votes vote down vote up
// Merges objects together
function mergeNestedI18NObject<T extends Object<any>>(object: T, path: string, split: string, value: any): T {
  const tokens = path.split(split);
  let temporary: T = {} as T;
  let temporary2: T;
  (temporary as any)[`${tokens[tokens.length - 1]}`] = value;
  for (let index = tokens.length - 2; index >= 0; index--) {
    temporary2 = {} as T;
    (temporary2 as any)[`${tokens[index]}`] = temporary;
    temporary = temporary2;
  }
  return merge(object, temporary);
}