Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
},
"homepage": "https://github.com/devongovett/linebreaker",
"dependencies": {
"base64-js": "0.0.8",
"unicode-trie": "^2.0.0"
},
"devDependencies": {
Expand Down
1 change: 1 addition & 0 deletions src/classes-trie-data.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file removed src/classes.trie
Binary file not shown.
6 changes: 4 additions & 2 deletions src/generate_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ request('https://www.unicode.org/Public/15.0.0/ucd/LineBreak.txt', function (err

trie.setRange(parseInt(start, 16), parseInt(end, 16), classes[type], true);

// write the trie to a file
fs.writeFileSync(new URL('classes.trie', import.meta.url), trie.toBuffer());
// write the trie Uint8Array to a file
const trieBuffer = trie.toBuffer();
const output = `export default new Uint8Array([${[...trieBuffer].join(',')}]);\n`;
fs.writeFileSync(new URL('classes-trie-data.js', import.meta.url), output);
});
4 changes: 1 addition & 3 deletions src/linebreaker.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import UnicodeTrie from 'unicode-trie';
import fs from 'fs';
import base64 from 'base64-js';
import { BK, CR, LF, NL, SG, WJ, SP, ZWJ, BA, HY, NS, AI, AL, CJ, HL, RI, SA, XX } from './classes';
import { DI_BRK, IN_BRK, CI_BRK, CP_BRK, PR_BRK, pairTable } from './pairs';
import data from './classes-trie-data.js';

const data = base64.toByteArray(fs.readFileSync(__dirname + '/classes.trie', 'base64'));
const classTrie = new UnicodeTrie(data);

const mapClass = function (c) {
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -965,11 +965,6 @@ base-x@^3.0.8:
dependencies:
safe-buffer "^5.0.1"

base64-js@0.0.8:
version "0.0.8"
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-0.0.8.tgz#1101e9544f4a76b1bc3b26d452ca96d7a35e7978"
integrity sha1-EQHpVE9KdrG8OybUUsqW16NeeXg=

bcrypt-pbkdf@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz#a4301d389b6a43f9b67ff3ca11a3f6637e360e9e"
Expand Down