Skip to content

zhl0791/flat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

flat object

import { flat } from '@zhl0791/flat';

const t = {
  key1: {
    key3: 'v1',
  },
  key2: {
    key4: 'v2',
  },
  key3: { a: { b: { c: 2 } } },
};

console.log(flat(t));

output:

{
  'key1.key3': 'v1',
  'key2.key4': 'v2',
  'key3.a.b.c': 2,
}

CommonJS:

import obj from '@zhl0791/flat';

const t = {
  key1: {
    key3: 'v1',
  },
  key2: {
    key4: 'v2',
  },
  key3: { a: { b: { c: 2 } } },
};

console.log(obj.flat(t));

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published