parenter

Recurse parents and children for your embedded objects.

Usage no npm install needed!

<script type="module">
  import parenter from 'https://cdn.skypack.dev/parenter';
</script>

README

QA monorepo

JavaScript Style Guide CircleCI Maintainability Test Coverage FOSSA Statuslerna

Installation

npm install parenting

Motivation

Getting parent and children shall be as easy drinking water (yes there are people hate drinking water).

Early release

The current API will work as is but will be extended soon. Soon the parent and children tags will be redefinable, and optional.

Examples

For now the current tests will do it:

const {expect} = require('chai')
const partenting = require('../../src')

describe('Basic Test Suite', function () {
  exampleObject = {
    a:{
      b:{
        c:1,
        c1:2,
        c3:{
          deep:{
            deeper:{
              whatCouldGoWrong: 1
            }
          }
        },
        c4:4
      },
      d:{
        e:2
      }
    },
    f: 'g',
    array:[
      {a:{b:'c'}}
    ]
  }

  it('checking default results', function () {
    const parented = partenting(exampleObject)()
    expect(parented.a.b.c3.parent()).to.deep.equal(parented.a.b)
    expect(parented.a.parent()).to.deep.equal(parented)
    expect(parented.a.children()[0].parent()).to.deep.equal(parented)
  })
})