@path-tree/collection
TypeScript icon, indicating that this package has built-in type declarations

0.3.2 • Public • Published

@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.

Package Sidebar

Install

npm i @path-tree/collection

Weekly Downloads

7

Version

0.3.2

License

MIT

Unpacked Size

7.06 kB

Total Files

6

Last publish

Collaborators

  • himenoglyph