Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

@es-git/fetch-mixin

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@es-git/fetch-mixin - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

3

es/index.d.ts
import { Constructor, IRawRepo } from '@es-git/core';
import { Fetch } from '@es-git/http-transport';
export interface FetchOptions {

@@ -8,2 +9,2 @@ refspec?: string | string[];

}
export default function fetchMixin<T extends Constructor<IRawRepo>>(repo: T): Constructor<IFetchRepo> & T;
export default function fetchMixin<T extends Constructor<IRawRepo>>(repo: T, fetch: Fetch): Constructor<IFetchRepo> & T;

@@ -1,12 +0,8 @@

import { fetch } from '@es-git/http-transport';
export default function fetchMixin(repo) {
import { fetch as gitFetch } from '@es-git/http-transport';
export default function fetchMixin(repo, fetch) {
return class FetchRepo extends repo {
constructor(fetch, ...args) {
super(...args);
this._fetch = fetch;
}
async fetch(url, options = {}) {
const refNames = await super.listRefs();
const localRefs = await Promise.all(refNames.map(name => super.getRef(name)));
const { objects, refs } = await fetch(url, this._fetch, localRefs, options.refspec || 'refs/heads/*:refs/remotes/origin/*', hash => super.hasObject(hash));
const { objects, refs } = await gitFetch(url, fetch, localRefs, options.refspec || 'refs/heads/*:refs/remotes/origin/*', hash => super.hasObject(hash));
for (const { hash, body } of objects) {

@@ -13,0 +9,0 @@ await super.saveRaw(hash, body);

@@ -6,2 +6,3 @@ 'use strict';

});
exports.default = undefined;

@@ -52,4 +53,2 @@ var _regenerator = require('babel-runtime/regenerator');

exports.default = fetchMixin;
var _httpTransport = require('@es-git/http-transport');

@@ -59,3 +58,3 @@

function fetchMixin(repo) {
function fetchMixin(repo, _fetch) {
var _this2 = this;

@@ -66,15 +65,5 @@

function FetchRepo(fetch) {
var _ref;
function FetchRepo() {
(0, _classCallCheck3.default)(this, FetchRepo);
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
var _this = (0, _possibleConstructorReturn3.default)(this, (_ref = FetchRepo.__proto__ || (0, _getPrototypeOf2.default)(FetchRepo)).call.apply(_ref, [this].concat(args)));
_this._fetch = fetch;
return _this;
return (0, _possibleConstructorReturn3.default)(this, (FetchRepo.__proto__ || (0, _getPrototypeOf2.default)(FetchRepo)).apply(this, arguments));
}

@@ -87,3 +76,3 @@

var _ref2 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(url) {
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(url) {
var _this3 = this;

@@ -93,3 +82,3 @@

var refNames, localRefs, _ref3, objects, refs, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _step$value, hash, body, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, _step2$value, name;
var refNames, localRefs, _ref2, objects, refs, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _step$value, hash, body, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, _step2$value, name;

@@ -113,3 +102,3 @@ return _regenerator2.default.wrap(function _callee$(_context) {

_context.next = 8;
return (0, _httpTransport.fetch)(url, this._fetch, localRefs, options.refspec || 'refs/heads/*:refs/remotes/origin/*', function (hash) {
return (0, _httpTransport.fetch)(url, _fetch, localRefs, options.refspec || 'refs/heads/*:refs/remotes/origin/*', function (hash) {
return (0, _get3.default)(FetchRepo.prototype.__proto__ || (0, _getPrototypeOf2.default)(FetchRepo.prototype), 'hasObject', _this3).call(_this3, hash);

@@ -119,5 +108,5 @@ });

case 8:
_ref3 = _context.sent;
objects = _ref3.objects;
refs = _ref3.refs;
_ref2 = _context.sent;
objects = _ref2.objects;
refs = _ref2.refs;
_iteratorNormalCompletion = true;

@@ -243,3 +232,3 @@ _didIteratorError = false;

function fetch(_x) {
return _ref2.apply(this, arguments);
return _ref.apply(this, arguments);
}

@@ -254,2 +243,4 @@

//# sourceMappingURL=index.js.map
exports.default = fetchMixin;
//# sourceMappingURL=index.js.map
{
"name": "@es-git/fetch-mixin",
"version": "0.1.0",
"version": "0.1.1",
"description": "",

@@ -42,5 +42,5 @@ "main": "js/index.js",

"dependencies": {
"@es-git/core": "^0.1.0",
"@es-git/http-transport": "^0.1.0"
"@es-git/core": "^0.1.1",
"@es-git/http-transport": "^0.1.1"
}
}
import { Type, Mode, Constructor, IRawRepo, Hash, isFile, encode } from '@es-git/core';
import { fetch, Fetch } from '@es-git/http-transport';
import { fetch as gitFetch, Fetch } from '@es-git/http-transport';

@@ -12,17 +12,10 @@ export interface FetchOptions {

export default function fetchMixin<T extends Constructor<IRawRepo>>(repo : T) : Constructor<IFetchRepo> & T {
export default function fetchMixin<T extends Constructor<IRawRepo>>(repo : T, fetch : Fetch) : Constructor<IFetchRepo> & T {
return class FetchRepo extends repo implements IFetchRepo {
private readonly _fetch : Fetch
constructor(...args : any[])
constructor(fetch : Fetch, ...args : any[]){
super(...args);
this._fetch = fetch;
}
async fetch(url : string, options : FetchOptions = {}) : Promise<void>{
const refNames = await super.listRefs();
const localRefs = await Promise.all(refNames.map(name => super.getRef(name) as Promise<string>));
const {objects, refs} = await fetch(
const {objects, refs} = await gitFetch(
url,
this._fetch,
fetch,
localRefs,

@@ -29,0 +22,0 @@ options.refspec || 'refs/heads/*:refs/remotes/origin/*',

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc