@es-git/walkers-mixin

This is part of the [ES-Git](https://github.com/es-git/es-git) project.

Stats

stars 🌟issues ⚠️updated 🛠created 🐣size 🏋️‍♀️
@es-git/walkers-mixin
Minified + gzip package size for @es-git/walkers-mixin in KB

Readme

walkers-mixin

This is part of the ES-Git project.

Install

npm install --save @es-git/walkers-mixin

Usage

Mix this in with an IObjectRepo.

This mixin provides ways to walk the repo, either along it's history or in the tree of one commit. This mixin uses async iterables

import objectsMixin from '@es-git/objects-mixin';
import walkersMixin from '@es-git/walkers-mixin';
import MemoryRepo from '@es-git/memory-repo';

const Repo = mix(MemoryRepo)
            .with(objectsMixin)
            .with(walkersMixin);

const repo = new Repo();
for await(const commit of repo.walkComits(await repo.getRef('refs/heads/master'))){
  console.log(commit.message);
}
for await(const fileOrFolder of repo.walkTree(await repo.getRef('refs/heads/master'))){
  console.log(fileOrFolder.path.join('/'));
}
for await(const file of repo.listFiles(await repo.getRef('refs/heads/master'))){
  console.log(file.path.join('/'));
}

Interfaces

IWalkersRepo

interface IWalkersRepo {
  walkCommits(...hash : Hash[]) : AsyncIterableIterator<HashAndCommitObject>
  walkTree(hash : Hash) : AsyncIterableIterator<HashModePath>
  listFiles(hash: Hash): AsyncIterableIterator<HashModePath>
}

type Hash = string;

type HashAndCommitObject = {
  readonly hash : Hash
  readonly commit : CommitObject
}

type HashModePath = {
  readonly hash : Hash
  readonly mode : Mode
  readonly path : string[]
}

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.