@es-git/save-as-mixin
This is part of the [ES-Git](https://github.com/es-git/es-git) project.
Last updated 2 years ago by mariusgundersen .
MIT · Original npm · Tarball · package.json
$ cnpm install @es-git/save-as-mixin 
SYNC missed versions from official npm registry.

save-as-mixin

This is part of the ES-Git project.

Install

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

Usage

Mix this in with an IObjectRepo.

This mixin makes it easier to save objects to the repo.

import objectsMixin from '@es-git/objects-mixin';
import saveAsMixin from '@es-git/save-as-mixin';
import MemoryRepo from '@es-git/memory-repo';

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

const repo = new Repo();
const hash = await repo.saveText('hello');
const tree = await repo.saveTree({
  'file1.txt': { mode: Mode.File, hash }
});

Interfaces

ISaveAsRepo

interface ISaveAsRepo {
  saveBlob(blob : Uint8Array) : Promise<Hash>
  saveText(text : string) : Promise<Hash>
  saveTree(tree : TreeBody) : Promise<Hash>
  saveCommit(commit : CommitBody) : Promise<Hash>
  saveTag(tag : TagBody) : Promise<Hash>
}

type Hash = string;

type TreeBody = {
  [key : string] : ModeHash
}

type ModeHash = {
  readonly mode : Mode
  readonly hash : string
}

type CommitBody = {
  readonly tree : string
  readonly parents : string[]
  readonly author : Person
  readonly committer : Person
  readonly message : string
}

type Person = {
  readonly name : string
  readonly email : string
  readonly date : Date | SecondsWithOffset
}

type SecondsWithOffset = {
  readonly seconds : number
  readonly offset : number
}

type TagBody = {
  readonly object : string
  readonly type : string
  readonly tag : string
  readonly tagger : Person
  readonly message : string
}

Current Tags

  • 0.9.0                                ...           latest (2 years ago)

11 Versions

  • 0.9.0                                ...           2 years ago
  • 0.8.3                                ...           2 years ago
  • 0.8.2                                ...           2 years ago
  • 0.5.0                                ...           2 years ago
  • 0.4.2                                ...           2 years ago
  • 0.4.0                                ...           2 years ago
  • 0.2.0                                ...           2 years ago
  • 0.1.2                                ...           2 years ago
  • 0.1.1                                ...           2 years ago
  • 0.1.0                                ...           2 years ago
  • 0.0.5                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 13
Last Day 0
Last Week 13
Last Month 38
Dependencies (2)
Dev Dependencies (0)
None
Dependents (1)

Copyright 2014 - 2016 © taobao.org |