Skip to content

Commit a4cbaa6

Browse files
committed
update lzjb-pack and use without magic string
1 parent 8704712 commit a4cbaa6

File tree

7 files changed

+48
-89
lines changed

7 files changed

+48
-89
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![npm](https://img.shields.io/badge/npm-1.0.0%E2%80%93beta.14-blue.svg)](https://www.npmjs.com/package/@jcubic/lips)
44
![1.0.0 Complete](https://img.shields.io/github/milestones/progress-percent/jcubic/lips/1?label=1.0.0%20Complete)
5-
[![travis](https://travis-ci.com/jcubic/lips.svg?branch=devel&4685021d4e0b63e15946271410f5412a4883aa3d)](https://travis-ci.com/jcubic/lips)
5+
[![travis](https://travis-ci.com/jcubic/lips.svg?branch=devel&8704712179d6035f8f70d366e9be1fb72029e564)](https://travis-ci.com/jcubic/lips)
66
[![Coverage Status](https://coveralls.io/repos/github/jcubic/lips/badge.svg?branch=devel&8c3211ada49521a8f2c41c9cc2095a91)](https://coveralls.io/github/jcubic/lips?branch=devel)
77
[![Join Gitter Chat](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/jcubic/lips)
88
[![GitHub license](https://img.shields.io/github/license/jcubic/lips.svg)](https://github.com/jcubic/lips/blob/master/LICENSE)

dist/lips.js

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* Copyright (c) 2014-present, Facebook, Inc.
3232
* released under MIT license
3333
*
34-
* build: Wed, 27 Oct 2021 10:22:54 +0000
34+
* build: Wed, 27 Oct 2021 10:47:38 +0000
3535
*/
3636
(function (global, factory) {
3737
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -4669,12 +4669,12 @@
46694669

46704670
/**@license
46714671
*
4672-
* No Dependency fast LZJB Compression for Browser and Node
4672+
* No Dependency fast and small LZJB Compression for Browser and Node
46734673
*
46744674
* Copyright (c) 2021 Jakub T. Jankiewicz https://jcubic.pl/me
46754675
* Released under BSD-3-Clause License
46764676
*
4677-
* build: Tue, 26 Oct 2021 18:34:12 GMT
4677+
* build: Wed, 27 Oct 2021 10:43:10 GMT
46784678
*/
46794679

46804680
Object.defineProperty(lzjbPack, '__esModule', { value: true });
@@ -4922,27 +4922,33 @@
49224922
return result;
49234923
}
49244924

4925-
function pack(input) {
4925+
function pack(input, { magic = true } = {}) {
49264926
const out = new Uint8Array(Math.max(input.length * 1.5 | 0, 16 * 1024));
49274927
const len = compress(input, out);
49284928
const len_array = number_to_bytes(input.length);
4929-
return merge_uint8_array$1(
4930-
MAGIC,
4929+
const payload = [
49314930
Uint8Array.of(len_array.length),
49324931
len_array,
49334932
out.slice(0, len)
4934-
);
4933+
];
4934+
if (magic) {
4935+
payload.unshift(MAGIC);
4936+
}
4937+
return merge_uint8_array$1(...payload);
49354938
}
49364939

4937-
function unpack(input) {
4938-
const decoder = new TextDecoder('utf-8');
4939-
const magic = decoder.decode(input.slice(0, MAGIC.length));
4940-
if (magic !== MAGIC_STRING) {
4941-
throw new Error('Invalid magic value');
4940+
function unpack(input, { magic = true } = {}) {
4941+
if (magic) {
4942+
const decoder = new TextDecoder('utf-8');
4943+
const magic_prefix = decoder.decode(input.slice(0, MAGIC.length));
4944+
if (magic_prefix !== MAGIC_STRING) {
4945+
throw new Error('Invalid magic value');
4946+
}
49424947
}
4943-
const size = input[MAGIC.length];
4944-
const start = MAGIC.length + 1;
4945-
const end = MAGIC.length + size + 1;
4948+
const magic_length = magic ? MAGIC.length : 0;
4949+
const size = input[magic_length];
4950+
const start = magic_length + 1;
4951+
const end = magic_length + size + 1;
49464952
const len = bytes_to_number(input.slice(start, end));
49474953
input = input.slice(end);
49484954
const out = new Uint8Array(len);
@@ -4989,7 +4995,7 @@
49894995
* The rationalize algorithm is by Per M.A. Bothner, Alan Bawden and Marc Feeley.
49904996
* source: Kawa, C-Gambit
49914997
*
4992-
* Build time: Wed, 27 Oct 2021 10:22:54 +0000
4998+
* Build time: Wed, 27 Oct 2021 10:47:38 +0000
49934999
*/
49945000
var _excluded = ["token"],
49955001
_excluded2 = ["stderr", "stdin", "stdout"];
@@ -18396,7 +18402,9 @@
1839618402
function serialize_bin(obj) {
1839718403
var magic = encode_magic();
1839818404
var payload = cbor.encode(obj);
18399-
return merge_uint8_array(magic, pack_1(payload));
18405+
return merge_uint8_array(magic, pack_1(payload, {
18406+
magic: false
18407+
}));
1840018408
} // -------------------------------------------------------------------------
1840118409

1840218410

@@ -18408,7 +18416,9 @@
1840818416
if (type === 'CBOR' && version === 1) {
1840918417
return cbor.decode(data.slice(MAGIC_LENGTH));
1841018418
} else if (type === 'CBRZ' && version === 1) {
18411-
var arr = unpack_1(data.slice(MAGIC_LENGTH));
18419+
var arr = unpack_1(data.slice(MAGIC_LENGTH), {
18420+
magic: false
18421+
});
1841218422
return cbor.decode(arr);
1841318423
} else {
1841418424
throw new Error("Invalid file format ".concat(type));
@@ -18509,10 +18519,10 @@
1850918519

1851018520
var banner = function () {
1851118521
// Rollup tree-shaking is removing the variable if it's normal string because
18512-
// obviously 'Wed, 27 Oct 2021 10:22:54 +0000' == '{{' + 'DATE}}'; can be removed
18522+
// obviously 'Wed, 27 Oct 2021 10:47:38 +0000' == '{{' + 'DATE}}'; can be removed
1851318523
// but disablig Tree-shaking is adding lot of not used code so we use this
1851418524
// hack instead
18515-
var date = LString('Wed, 27 Oct 2021 10:22:54 +0000').valueOf();
18525+
var date = LString('Wed, 27 Oct 2021 10:47:38 +0000').valueOf();
1851618526

1851718527
var _date = date === '{{' + 'DATE}}' ? new Date() : new Date(date);
1851818528

@@ -18557,7 +18567,7 @@
1855718567
var lips = {
1855818568
version: 'DEV',
1855918569
banner: banner,
18560-
date: 'Wed, 27 Oct 2021 10:22:54 +0000',
18570+
date: 'Wed, 27 Oct 2021 10:47:38 +0000',
1856118571
exec: exec,
1856218572
// unwrap async generator into Promise<Array>
1856318573
parse: compose(uniterate_async, parse),

dist/lips.min.js

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/std.xcb

-5 Bytes
Binary file not shown.

package-lock.json

Lines changed: 7 additions & 57 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,7 @@
249249
"dependencies": {
250250
"@jcubic/lily": "^0.1.0",
251251
"cbor-x": "^0.8.3",
252-
"lzjb": "^0.0.4",
253-
"lzjb-pack": "^0.1.0",
252+
"lzjb-pack": "^0.2.0",
254253
"prism-cli": "^0.5.3",
255254
"prismjs": "^1.25.0",
256255
"unfetch": "^4.2.0"

src/lips.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10281,7 +10281,7 @@ function decode_magic(obj) {
1028110281
function serialize_bin(obj) {
1028210282
const magic = encode_magic();
1028310283
const payload = cbor.encode(obj);
10284-
return merge_uint8_array(magic, pack(payload));
10284+
return merge_uint8_array(magic, pack(payload, { magic: false }));
1028510285
}
1028610286

1028710287
// -------------------------------------------------------------------------
@@ -10290,7 +10290,7 @@ function unserialize_bin(data) {
1029010290
if (type === 'CBOR' && version === 1) {
1029110291
return cbor.decode(data.slice(MAGIC_LENGTH));
1029210292
} else if (type === 'CBRZ' && version === 1) {
10293-
const arr = unpack(data.slice(MAGIC_LENGTH));
10293+
const arr = unpack(data.slice(MAGIC_LENGTH), { magic: false });
1029410294
return cbor.decode(arr);
1029510295
} else {
1029610296
throw new Error(`Invalid file format ${type}`);

0 commit comments

Comments
 (0)