0.3.2 • Published 4 years ago

@path-tree/collection v0.3.2

Weekly downloads
1
License
MIT
Repository
-
Last release
4 years ago

@path-tree/collection

npm version

Usage

Install

yarn add @path-tree/collection

Basic Usage

import { collect } from "@path-tree/collection";

collect([
  {
    type: "file",
    path: "a/b/index.js",
  },
  {
    type: "file",
    path: "a/b/c/index.js",
  },
]);

The results above are as follows.

{
  "nodes": ["dir:a", "dir:a/b", "dir:a/b/c", "file:a/b/c/index.js", "file:a/b/index.js"],
  "edges": {
    "dir:.": ["dir:a"],
    "dir:a": ["dir:a/b"],
    "dir:a/b": ["dir:a/b/c", "file:a/b/index.js"],
    "dir:a/b/c": ["file:a/b/c/index.js"]
  },
  "data": {
    "dir:a": {
      "type": "dir",
      "path": "a"
    },
    "dir:a/b": {
      "type": "dir",
      "path": "a/b"
    },
    "dir:a/b/c": {
      "type": "dir",
      "path": "a/b/c"
    },
    "file:a/b/c/index.js": {
      "type": "file",
      "path": "a/b/c/index.js"
    },
    "file:a/b/index.js": {
      "type": "file",
      "path": "a/b/index.js"
    }
  }
}

LICENSE

@path-tree/collection is MIT licensed.