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

@es-git/packfile

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@es-git/packfile - npm Package Compare versions

Comparing version 0.2.0 to 0.3.4

20

es/compose-packfile.js

@@ -1,2 +0,2 @@

import { packHash, concat } from '@es-git/core';
import { packHash } from '@es-git/core';
import * as pako from 'pako';

@@ -7,12 +7,14 @@ import sha1 from 'git-sha1';

const hash = sha1();
const chunk = packHeader(items.length);
hash.update(chunk);
yield chunk;
yield update(packHeader(items.length), hash);
for (const item of items) {
const chunk = concat(...packFrame(item));
hash.update(chunk);
yield chunk;
for (const chunk of packFrame(item)) {
yield update(chunk, hash);
}
}
yield packHash(hash.digest());
}
function update(chunk, hash) {
hash.update(chunk);
return chunk;
}
function packHeader(length) {

@@ -48,10 +50,10 @@ return Uint8Array.from([

}
return head;
return new Uint8Array(head);
}
// write BIG_ENDIAN_MODIFIED_BASE_128_NUMBER
function packOfsDelta(ref) {
const head = [];
let offset = ref;
// Calculate how many digits we need in base 128
let i = Math.floor(Math.log(offset) / Math.log(0x80));
const head = new Uint8Array(i + 1);
// Write the last digit

@@ -58,0 +60,0 @@ head[i] = offset & 0x7f;

@@ -5,3 +5,3 @@ import { concat, decode } from '@es-git/core';

export default function (objects) {
return concat(...composePackfile([...toEntry(toRawObject(objects))]));
return concat(...composePackfile([...toEntry(toRawObject(objects))].sort(byType)));
}

@@ -30,2 +30,5 @@ function* toRawObject(objects) {

}
function byType(a, b) {
return a.type - b.type;
}
//# sourceMappingURL=pack.js.map

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

var _toConsumableArray2 = require('babel-runtime/helpers/toConsumableArray');
var _toConsumableArray3 = _interopRequireDefault(_toConsumableArray2);
var _getIterator2 = require('babel-runtime/core-js/get-iterator');

@@ -41,3 +37,3 @@

function composePackfile(items) {
var hash, chunk, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, item, _chunk;
var hash, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, item, _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, chunk;

@@ -49,18 +45,15 @@ return _regenerator2.default.wrap(function composePackfile$(_context) {

hash = (0, _gitSha2.default)();
chunk = packHeader(items.length);
_context.next = 3;
return update(packHeader(items.length), hash);
hash.update(chunk);
_context.next = 5;
return chunk;
case 5:
case 3:
_iteratorNormalCompletion = true;
_didIteratorError = false;
_iteratorError = undefined;
_context.prev = 8;
_context.prev = 6;
_iterator = (0, _getIterator3.default)(items);
case 10:
case 8:
if (_iteratorNormalCompletion = (_step = _iterator.next()).done) {
_context.next = 19;
_context.next = 39;
break;

@@ -70,26 +63,75 @@ }

item = _step.value;
_chunk = _core.concat.apply(undefined, (0, _toConsumableArray3.default)(packFrame(item)));
_iteratorNormalCompletion2 = true;
_didIteratorError2 = false;
_iteratorError2 = undefined;
_context.prev = 13;
_iterator2 = (0, _getIterator3.default)(packFrame(item));
hash.update(_chunk);
_context.next = 16;
return _chunk;
case 15:
if (_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done) {
_context.next = 22;
break;
}
case 16:
chunk = _step2.value;
_context.next = 19;
return update(chunk, hash);
case 19:
_iteratorNormalCompletion2 = true;
_context.next = 15;
break;
case 22:
_context.next = 28;
break;
case 24:
_context.prev = 24;
_context.t0 = _context['catch'](13);
_didIteratorError2 = true;
_iteratorError2 = _context.t0;
case 28:
_context.prev = 28;
_context.prev = 29;
if (!_iteratorNormalCompletion2 && _iterator2.return) {
_iterator2.return();
}
case 31:
_context.prev = 31;
if (!_didIteratorError2) {
_context.next = 34;
break;
}
throw _iteratorError2;
case 34:
return _context.finish(31);
case 35:
return _context.finish(28);
case 36:
_iteratorNormalCompletion = true;
_context.next = 10;
_context.next = 8;
break;
case 19:
_context.next = 25;
case 39:
_context.next = 45;
break;
case 21:
_context.prev = 21;
_context.t0 = _context['catch'](8);
case 41:
_context.prev = 41;
_context.t1 = _context['catch'](6);
_didIteratorError = true;
_iteratorError = _context.t0;
_iteratorError = _context.t1;
case 25:
_context.prev = 25;
_context.prev = 26;
case 45:
_context.prev = 45;
_context.prev = 46;

@@ -100,7 +142,7 @@ if (!_iteratorNormalCompletion && _iterator.return) {

case 28:
_context.prev = 28;
case 48:
_context.prev = 48;
if (!_didIteratorError) {
_context.next = 31;
_context.next = 51;
break;

@@ -111,13 +153,13 @@ }

case 31:
return _context.finish(28);
case 51:
return _context.finish(48);
case 32:
return _context.finish(25);
case 52:
return _context.finish(45);
case 33:
_context.next = 35;
case 53:
_context.next = 55;
return (0, _core.packHash)(hash.digest());
case 35:
case 55:
case 'end':

@@ -127,4 +169,8 @@ return _context.stop();

}
}, _marked[0], this, [[8, 21, 25, 33], [26,, 28, 32]]);
}, _marked[0], this, [[6, 41, 45, 53], [13, 24, 28, 36], [29,, 31, 35], [46,, 48, 52]]);
}
function update(chunk, hash) {
hash.update(chunk);
return chunk;
}
function packHeader(length) {

@@ -184,10 +230,10 @@ return Uint8Array.from([0x50, 0x41, 0x43, 0x4b, 0, 0, 0, 2, length >> 24, length >> 16 & 0xff, length >> 8 & 0xff, length & 0xff]);

}
return head;
return new Uint8Array(head);
}
// write BIG_ENDIAN_MODIFIED_BASE_128_NUMBER
function packOfsDelta(ref) {
var head = [];
var offset = ref;
// Calculate how many digits we need in base 128
var i = Math.floor(Math.log(offset) / Math.log(0x80));
var head = new Uint8Array(i + 1);
// Write the last digit

@@ -194,0 +240,0 @@ head[i] = offset & 0x7f;

@@ -24,3 +24,3 @@ 'use strict';

exports.default = function (objects) {
return _core.concat.apply(undefined, (0, _toConsumableArray3.default)((0, _composePackfile2.default)([].concat((0, _toConsumableArray3.default)(toEntry(toRawObject(objects)))))));
return _core.concat.apply(undefined, (0, _toConsumableArray3.default)((0, _composePackfile2.default)([].concat((0, _toConsumableArray3.default)(toEntry(toRawObject(objects)))).sort(byType))));
};

@@ -188,3 +188,6 @@

}
function byType(a, b) {
return a.type - b.type;
}
//# sourceMappingURL=pack.js.map
//# sourceMappingURL=pack.js.map
{
"name": "@es-git/packfile",
"version": "0.2.0",
"version": "0.3.4",
"description": "",

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

@@ -6,3 +6,3 @@ import {

import * as pako from 'pako';
import sha1 from 'git-sha1';
import sha1, { Sha1 } from 'git-sha1';

@@ -17,10 +17,8 @@ import {

const chunk = packHeader(items.length);
hash.update(chunk);
yield chunk;
yield update(packHeader(items.length), hash);
for(const item of items){
const chunk = concat(...packFrame(item));
hash.update(chunk);
yield chunk;
for(const chunk of packFrame(item)){
yield update(chunk, hash);
}
}

@@ -31,2 +29,7 @@

function update(chunk : Uint8Array, hash : Sha1){
hash.update(chunk);
return chunk;
}
function packHeader(length : number) {

@@ -65,3 +68,3 @@ return Uint8Array.from([

}
return head;
return new Uint8Array(head);
}

@@ -71,6 +74,6 @@

function packOfsDelta(ref : number){
const head = [];
let offset = ref;
// Calculate how many digits we need in base 128
let i = Math.floor(Math.log(offset) / Math.log(0x80));
const head = new Uint8Array(i+1);
// Write the last digit

@@ -77,0 +80,0 @@ head[i] = offset & 0x7f;

@@ -7,4 +7,4 @@ declare module "git-sha1" {

export default function sha1(buffer : Uint8Array | string) : string;
export default function sha1(buffer : Uint8Array | string | number[]) : string;
export default function sha1() : Sha1;
}

@@ -17,3 +17,3 @@ import {

export default function(objects : Iterable<HashBlob>){
return concat(...composePackfile([...toEntry(toRawObject(objects))]));
return concat(...composePackfile([...toEntry(toRawObject(objects))].sort(byType)));
}

@@ -43,2 +43,6 @@

}
}
function byType(a : NormalEntry, b : NormalEntry) {
return a.type - b.type;
}

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

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