1.0.9 • Published 5 years ago

@kingjs/descriptor.nested.to-array v1.0.9

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

@kingjs/descriptor.nested.to-array

Returns an array of leaf values that correspond to as set of paths.

Usage

Return an array of pet names like this:

var toArray = require('@kingjs/descriptor.nested.to-array');

var people = {
  alice: { 
    pet: 'tiger' 
  },
  bob: { 
    pet: 'snuggles' 
  },
  chris: {
    pet: 'spike'
  }
}

var tree = {
  '*': { pet: null }
}

toArray(people, tree);

result:

[ 'tiger', 'snuggles', 'spike' ]

API

declare function toArray(
  tree: NestedDescriptor,
  paths: NestedDescriptor
): array

Interfaces

Parameters

  • tree: A tree whose leaf values that correspond to a path in paths are returned in an array.
  • paths: Paths to search in tree. If the path is found, then it's value is included in the result array. Any property named '*' found in paths is replicated with properties whose names correspond to properties of tree not already present as siblings of '*'.

Returns

Returns an array of values or null if no values are found.

Install

With npm installed, run

$ npm install @kingjs/descriptor.nested.to-array

License

MIT

Analytics

1.0.9

5 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago