@es-git/load-as-mixin
Advanced tools
Comparing version 0.0.3 to 0.0.4
import { Constructor, Hash } from '@es-git/core'; | ||
import { IObjectRepo, BlobObject, TextObject, TreeObject, CommitObject, TagObject } from '@es-git/object-mixin'; | ||
import { IObjectRepo, TreeBody, CommitBody, TagBody } from '@es-git/object-mixin'; | ||
export interface ILoadAsRepo { | ||
loadBlob(hash: Hash): Promise<BlobObject>; | ||
loadText(hash: Hash): Promise<TextObject>; | ||
loadTree(hash: Hash): Promise<TreeObject>; | ||
loadCommit(hash: Hash): Promise<CommitObject>; | ||
loadTag(hash: Hash): Promise<TagObject>; | ||
loadBlob(hash: Hash): Promise<Uint8Array>; | ||
loadText(hash: Hash): Promise<string>; | ||
loadTree(hash: Hash): Promise<TreeBody>; | ||
loadCommit(hash: Hash): Promise<CommitBody>; | ||
loadTag(hash: Hash): Promise<TagBody>; | ||
} | ||
export default function loadAsMixin<T extends Constructor<IObjectRepo>>(repo: T): T & Constructor<ILoadAsRepo>; |
@@ -11,3 +11,3 @@ import { Type } from '@es-git/core'; | ||
throw new Error(`Expected object with hash ${hash} to be blob but it was ${object.type}`); | ||
return object; | ||
return object.body; | ||
} | ||
@@ -20,6 +20,3 @@ async loadText(hash) { | ||
throw new Error(`Expected object with hash ${hash} to be blob but it was ${object.type}`); | ||
return { | ||
type: 'text', | ||
body: blobToText(object.body) | ||
}; | ||
return blobToText(object.body); | ||
} | ||
@@ -32,3 +29,3 @@ async loadTree(hash) { | ||
throw new Error(`Expected object with hash ${hash} to be tree but it was ${object.type}`); | ||
return object; | ||
return object.body; | ||
} | ||
@@ -41,3 +38,3 @@ async loadCommit(hash) { | ||
throw new Error(`Expected object with hash ${hash} to be commit but it was ${object.type}`); | ||
return object; | ||
return object.body; | ||
} | ||
@@ -50,3 +47,3 @@ async loadTag(hash) { | ||
throw new Error(`Expected object with hash ${hash} to be tag but it was ${object.type}`); | ||
return object; | ||
return object.body; | ||
} | ||
@@ -53,0 +50,0 @@ }; |
@@ -95,3 +95,3 @@ 'use strict'; | ||
case 7: | ||
return _context.abrupt('return', object); | ||
return _context.abrupt('return', object.body); | ||
@@ -145,6 +145,3 @@ case 8: | ||
case 7: | ||
return _context2.abrupt('return', { | ||
type: 'text', | ||
body: (0, _objectMixin.blobToText)(object.body) | ||
}); | ||
return _context2.abrupt('return', (0, _objectMixin.blobToText)(object.body)); | ||
@@ -198,3 +195,3 @@ case 8: | ||
case 7: | ||
return _context3.abrupt('return', object); | ||
return _context3.abrupt('return', object.body); | ||
@@ -248,3 +245,3 @@ case 8: | ||
case 7: | ||
return _context4.abrupt('return', object); | ||
return _context4.abrupt('return', object.body); | ||
@@ -298,3 +295,3 @@ case 8: | ||
case 7: | ||
return _context5.abrupt('return', object); | ||
return _context5.abrupt('return', object.body); | ||
@@ -301,0 +298,0 @@ case 8: |
{ | ||
"name": "@es-git/load-as-mixin", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "js/index.js", |
import { Constructor, Hash, Type } from '@es-git/core'; | ||
import { IObjectRepo, GitObject, BlobObject, TextObject, TreeObject, CommitObject, TagObject, blobToText } from '@es-git/object-mixin'; | ||
import { IObjectRepo, TreeBody, CommitBody, TagBody, blobToText } from '@es-git/object-mixin'; | ||
export interface ILoadAsRepo { | ||
loadBlob(hash : Hash) : Promise<BlobObject> | ||
loadText(hash : Hash) : Promise<TextObject> | ||
loadTree(hash : Hash) : Promise<TreeObject> | ||
loadCommit(hash : Hash) : Promise<CommitObject> | ||
loadTag(hash : Hash) : Promise<TagObject> | ||
loadBlob(hash : Hash) : Promise<Uint8Array> | ||
loadText(hash : Hash) : Promise<string> | ||
loadTree(hash : Hash) : Promise<TreeBody> | ||
loadCommit(hash : Hash) : Promise<CommitBody> | ||
loadTag(hash : Hash) : Promise<TagBody> | ||
} | ||
@@ -19,3 +19,3 @@ | ||
if(object.type !== Type.blob) throw new Error(`Expected object with hash ${hash} to be blob but it was ${object.type}`); | ||
return object; | ||
return object.body; | ||
} | ||
@@ -27,6 +27,3 @@ | ||
if(object.type !== Type.blob) throw new Error(`Expected object with hash ${hash} to be blob but it was ${object.type}`); | ||
return { | ||
type: 'text' as 'text', | ||
body: blobToText(object.body) | ||
}; | ||
return blobToText(object.body); | ||
} | ||
@@ -38,3 +35,3 @@ | ||
if(object.type !== Type.tree) throw new Error(`Expected object with hash ${hash} to be tree but it was ${object.type}`); | ||
return object; | ||
return object.body; | ||
} | ||
@@ -46,3 +43,3 @@ | ||
if(object.type !== Type.commit) throw new Error(`Expected object with hash ${hash} to be commit but it was ${object.type}`); | ||
return object; | ||
return object.body; | ||
} | ||
@@ -54,5 +51,5 @@ | ||
if(object.type !== Type.tag) throw new Error(`Expected object with hash ${hash} to be tag but it was ${object.type}`); | ||
return object; | ||
return object.body; | ||
} | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
35600
341