1.1.0 • Published 6 years ago

array-to-archy v1.1.0

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

Build Status version downloads

Table of Contents

Installation

This module is distributed via npm which is bundled with node and should be installed as one of your project's devDependencies:

npm install --save-dev array-to-archy

Usage

const arrayToArchy = require("array-to-archy")

const _array = [
  1,
  2,
  [3, 4, ["city", "country", ["abc", "xyz"]]],
  5,
  ["foo", "bar"],
  "baz",
  6
]

arrayToArchy(_array, 'X')

Output

{
  "label": "X",
  "nodes": [
    "1",
    "2",
    {
      "label": "X",
      "nodes": [
        "3",
        "4",
        {
          "label": "X",
          "nodes": [
            "city",
            "country",
            {
              "label": "X",
              "nodes": [
                "abc",
                "xyz"
              ]
            }
          ]
        }
      ]
    },
    "5",
    {
      "label": "X",
      "nodes": [
        "foo",
        "bar"
      ]
    },
    " baz",
    "6"
  ]
}

API

arrayToArchy(data , label)

Returns a object.

label

Type: string Default: --

Joydip Roy (rjoydip)💻 📖 🚇 ⚠️

Contributions of any kind welcome!

LICENSE

MIT