/tinypath

⚙️ A tiny utility for generate chains of object property paths

Primary LanguageTypeScriptMIT LicenseMIT

tinypath CI codecov

A tiny utility for generating chains of object property paths. logo

Usage

import { getPaths } from 'tinypath'

getPaths({
  root: 'root',
  lvl1: {
    propLvl1: 'propLvl1',
    lvl2: {
      propLvl2: 'propLvl2'
    }
  }
})
// =>
// {
//   "root": "root",
//   "lvl1": {
//     "propLvl1": "lvl1.propLvl1",
//     "lvl2": {
//       "propLvl2": "lvl1.lvl2.propLvl2",
//       "self": "lvl1.lvl2"
//     },
//     "self": "lvl1"
//    }
// }

API: getPaths(object[, options])

  • object: Object
  • options?: TinyPathOptions

TinyPathOptions

depth?: number

Default: 0

base?: string

Default: ''

separator?: string

Default: '.'


licence