Skip to content

Commit 7a83d4c

Browse files
🔨 config(build): Configure microbundle to produce build.
1 parent 25e2edc commit 7a83d4c

File tree

9 files changed

+3413
-2860
lines changed

9 files changed

+3413
-2860
lines changed

.codeclimate.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
exclude_patterns:
22
- doc/**
3-
- lib/**
3+
- dist/**
44
- test/**

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
!yarn.lock
33

44
# Generated files
5-
/lib
5+
/dist
66

77
# Dependency directory
88
node_modules

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ See [docs](https://compression-algorithm.github.io/lempel-ziv/index.html).
88
> [regenerator-runtime/runtime](https://www.npmjs.com/package/regenerator-runtime).
99
1010
```js
11-
import {dict, encode, decode} from '@compression-algorithm/lempel-ziv/lz78' ;
11+
import {lz78} from '@compression-algorithm/lempel-ziv' ;
12+
const {dict, encode, decode} = lz78;
13+
1214
[...decode(dict(), encode(dict(), 'abcd'))].join(''); // abcd
1315
```
1416

package.json

+23-6
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,25 @@
2020
"ziv"
2121
],
2222
"sideEffects": false,
23-
"main": "lib/index.js",
23+
"source": "src/index.js",
24+
"main": "dist/index.cjs",
25+
"module": "dist/index.module.js",
26+
"esmodule": "dist/index.modern.js",
27+
"umd:main": "dist/index.umd.js",
28+
"unpkg": "dist/index.umd.js",
29+
"exports": {
30+
".": {
31+
"browser": "./dist/index.module.js",
32+
"umd": "./dist/index.umd.js",
33+
"require": "./dist/index.cjs",
34+
"default": "./dist/index.modern.js"
35+
}
36+
},
2437
"files": [
25-
"lib"
38+
"dist"
2639
],
2740
"scripts": {
28-
"build": "babel --delete-dir-on-start --env-name production src -d lib",
41+
"build": "NODE_ENV=production microbundle",
2942
"build-docs": "esdoc",
3043
"build-gh-pages": "npm run build-docs",
3144
"commit-msg": "commitlint --edit",
@@ -44,13 +57,14 @@
4457
"travis": "npm run lint && npm run cover"
4558
},
4659
"dependencies": {
47-
"@aureooms/js-persistent-stack": "^0.0.0",
48-
"@aureooms/js-trie": "^0.0.1"
60+
"@functional-data-structure/persistent-stack": "^1.0.0",
61+
"@trie-data-structure/uncompressed-trie": "^1.0.0"
4962
},
5063
"devDependencies": {
5164
"@aureooms/js-string": "1.0.0",
52-
"@babel/cli": "7.13.10",
5365
"@babel/core": "7.13.10",
66+
"@babel/plugin-transform-destructuring": "^7.18.13",
67+
"@babel/plugin-transform-for-of": "7.18.8",
5468
"@babel/preset-env": "7.13.10",
5569
"@babel/register": "7.13.8",
5670
"@commitlint/cli": "17.1.2",
@@ -68,6 +82,7 @@
6882
"esdoc-standard-plugin": "1.0.0",
6983
"fixpack": "4.0.0",
7084
"husky": "8.0.1",
85+
"microbundle": "0.15.1",
7186
"np": "7.4.0",
7287
"pinst": "3.0.0",
7388
"power-assert": "1.6.1",
@@ -165,6 +180,8 @@
165180
]
166181
],
167182
"plugins": [
183+
"@babel/plugin-transform-destructuring",
184+
"@babel/plugin-transform-for-of",
168185
"babel-plugin-unassert"
169186
]
170187
}

src/index.js

+1-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1 @@
1-
import lz78 from './lz78.js';
2-
3-
/* eslint import/no-anonymous-default-export: [2, {"allowObject": true}] */
4-
export default {
5-
lz78,
6-
};
7-
8-
export {lz78};
1+
export * as lz78 from './lz78.js';

src/lz78.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {Trie, ObjectNode} from '@aureooms/js-trie';
2-
import {push, iter} from '@aureooms/js-persistent-stack';
1+
import {Trie, ObjectNode} from '@trie-data-structure/uncompressed-trie';
2+
import {push, iter} from '@functional-data-structure/persistent-stack';
33

44
/**
55
* Simple Lempel-Ziv lossless data compression algorithm implementation.

test/src/lz78.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import test from 'ava';
22

33
import {mul} from '@aureooms/js-string';
4-
import {dict, encode, decode} from '../../src/lz78.js';
4+
5+
import {lz78} from '../../src/index.js';
6+
const {dict, encode, decode} = lz78;
57

68
const alphabetaL = 'abcdefghijklmnopqrstuvwxyz';
79
const alphabetaU = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
@@ -20,7 +22,7 @@ const macro = (t, init, input) => {
2022
const repr = (string) =>
2123
string.length >= 20 ? string.slice(0, 9) + '..' + string.slice(-9) : string;
2224

23-
macro.title = (title, init, input) => `lz78 <${init.name}>: ${repr(input)}`;
25+
macro.title = (title, init, input) => title ?? `lz78 <${init.name}>: ${repr(input)}`;
2426

2527
for (const init of [initEmpty, initAlphabet]) {
2628
test(macro, init, '');

test/src/readme.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import test from 'ava';
22

3-
import {dict, encode, decode} from '../../src/lz78.js';
3+
import {lz78} from '../../src/index.js';
4+
const {dict, encode, decode} = lz78;
5+
46
test('README', (t) => {
57
const input = 'abcd';
68
t.is(input, [...decode(dict(), encode(dict(), input))].join(''));

0 commit comments

Comments
 (0)