First commit
This commit is contained in:
21
node_modules/linebreak/LICENSE
generated
vendored
Normal file
21
node_modules/linebreak/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2014-present Devon Govett
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
1369
node_modules/linebreak/dist/main.cjs
generated
vendored
Normal file
1369
node_modules/linebreak/dist/main.cjs
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/linebreak/dist/main.cjs.map
generated
vendored
Normal file
1
node_modules/linebreak/dist/main.cjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1368
node_modules/linebreak/dist/module.mjs
generated
vendored
Normal file
1368
node_modules/linebreak/dist/module.mjs
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/linebreak/dist/module.mjs.map
generated
vendored
Normal file
1
node_modules/linebreak/dist/module.mjs.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
5
node_modules/linebreak/node_modules/base64-js/.travis.yml
generated
vendored
Normal file
5
node_modules/linebreak/node_modules/base64-js/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "0.8"
|
||||
- "0.10"
|
||||
- "0.11"
|
||||
21
node_modules/linebreak/node_modules/base64-js/LICENSE.MIT
generated
vendored
Normal file
21
node_modules/linebreak/node_modules/base64-js/LICENSE.MIT
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
31
node_modules/linebreak/node_modules/base64-js/README.md
generated
vendored
Normal file
31
node_modules/linebreak/node_modules/base64-js/README.md
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
base64-js
|
||||
=========
|
||||
|
||||
`base64-js` does basic base64 encoding/decoding in pure JS.
|
||||
|
||||
[](http://travis-ci.org/beatgammit/base64-js)
|
||||
|
||||
[](https://ci.testling.com/beatgammit/base64-js)
|
||||
|
||||
Many browsers already have base64 encoding/decoding functionality, but it is for text data, not all-purpose binary data.
|
||||
|
||||
Sometimes encoding/decoding binary data in the browser is useful, and that is what this module does.
|
||||
|
||||
## install
|
||||
|
||||
With [npm](https://npmjs.org) do:
|
||||
|
||||
`npm install base64-js`
|
||||
|
||||
## methods
|
||||
|
||||
`var base64 = require('base64-js')`
|
||||
|
||||
`base64` has two exposed functions, `toByteArray` and `fromByteArray`, which both take a single argument.
|
||||
|
||||
* `toByteArray` - Takes a base64 string and returns a byte array
|
||||
* `fromByteArray` - Takes a byte array and returns a base64 string
|
||||
|
||||
## license
|
||||
|
||||
MIT
|
||||
19
node_modules/linebreak/node_modules/base64-js/bench/bench.js
generated
vendored
Normal file
19
node_modules/linebreak/node_modules/base64-js/bench/bench.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
var random = require('crypto').pseudoRandomBytes
|
||||
|
||||
var b64 = require('../')
|
||||
var fs = require('fs')
|
||||
var path = require('path')
|
||||
var data = random(1e6).toString('base64')
|
||||
//fs.readFileSync(path.join(__dirname, 'example.b64'), 'ascii').split('\n').join('')
|
||||
var start = Date.now()
|
||||
var raw = b64.toByteArray(data)
|
||||
var middle = Date.now()
|
||||
var data = b64.fromByteArray(raw)
|
||||
var end = Date.now()
|
||||
|
||||
console.log('decode ms, decode ops/ms, encode ms, encode ops/ms')
|
||||
console.log(
|
||||
middle - start, data.length / (middle - start),
|
||||
end - middle, data.length / (end - middle))
|
||||
//console.log(data)
|
||||
|
||||
124
node_modules/linebreak/node_modules/base64-js/lib/b64.js
generated
vendored
Normal file
124
node_modules/linebreak/node_modules/base64-js/lib/b64.js
generated
vendored
Normal file
@@ -0,0 +1,124 @@
|
||||
var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
||||
|
||||
;(function (exports) {
|
||||
'use strict';
|
||||
|
||||
var Arr = (typeof Uint8Array !== 'undefined')
|
||||
? Uint8Array
|
||||
: Array
|
||||
|
||||
var PLUS = '+'.charCodeAt(0)
|
||||
var SLASH = '/'.charCodeAt(0)
|
||||
var NUMBER = '0'.charCodeAt(0)
|
||||
var LOWER = 'a'.charCodeAt(0)
|
||||
var UPPER = 'A'.charCodeAt(0)
|
||||
var PLUS_URL_SAFE = '-'.charCodeAt(0)
|
||||
var SLASH_URL_SAFE = '_'.charCodeAt(0)
|
||||
|
||||
function decode (elt) {
|
||||
var code = elt.charCodeAt(0)
|
||||
if (code === PLUS ||
|
||||
code === PLUS_URL_SAFE)
|
||||
return 62 // '+'
|
||||
if (code === SLASH ||
|
||||
code === SLASH_URL_SAFE)
|
||||
return 63 // '/'
|
||||
if (code < NUMBER)
|
||||
return -1 //no match
|
||||
if (code < NUMBER + 10)
|
||||
return code - NUMBER + 26 + 26
|
||||
if (code < UPPER + 26)
|
||||
return code - UPPER
|
||||
if (code < LOWER + 26)
|
||||
return code - LOWER + 26
|
||||
}
|
||||
|
||||
function b64ToByteArray (b64) {
|
||||
var i, j, l, tmp, placeHolders, arr
|
||||
|
||||
if (b64.length % 4 > 0) {
|
||||
throw new Error('Invalid string. Length must be a multiple of 4')
|
||||
}
|
||||
|
||||
// the number of equal signs (place holders)
|
||||
// if there are two placeholders, than the two characters before it
|
||||
// represent one byte
|
||||
// if there is only one, then the three characters before it represent 2 bytes
|
||||
// this is just a cheap hack to not do indexOf twice
|
||||
var len = b64.length
|
||||
placeHolders = '=' === b64.charAt(len - 2) ? 2 : '=' === b64.charAt(len - 1) ? 1 : 0
|
||||
|
||||
// base64 is 4/3 + up to two characters of the original data
|
||||
arr = new Arr(b64.length * 3 / 4 - placeHolders)
|
||||
|
||||
// if there are placeholders, only get up to the last complete 4 chars
|
||||
l = placeHolders > 0 ? b64.length - 4 : b64.length
|
||||
|
||||
var L = 0
|
||||
|
||||
function push (v) {
|
||||
arr[L++] = v
|
||||
}
|
||||
|
||||
for (i = 0, j = 0; i < l; i += 4, j += 3) {
|
||||
tmp = (decode(b64.charAt(i)) << 18) | (decode(b64.charAt(i + 1)) << 12) | (decode(b64.charAt(i + 2)) << 6) | decode(b64.charAt(i + 3))
|
||||
push((tmp & 0xFF0000) >> 16)
|
||||
push((tmp & 0xFF00) >> 8)
|
||||
push(tmp & 0xFF)
|
||||
}
|
||||
|
||||
if (placeHolders === 2) {
|
||||
tmp = (decode(b64.charAt(i)) << 2) | (decode(b64.charAt(i + 1)) >> 4)
|
||||
push(tmp & 0xFF)
|
||||
} else if (placeHolders === 1) {
|
||||
tmp = (decode(b64.charAt(i)) << 10) | (decode(b64.charAt(i + 1)) << 4) | (decode(b64.charAt(i + 2)) >> 2)
|
||||
push((tmp >> 8) & 0xFF)
|
||||
push(tmp & 0xFF)
|
||||
}
|
||||
|
||||
return arr
|
||||
}
|
||||
|
||||
function uint8ToBase64 (uint8) {
|
||||
var i,
|
||||
extraBytes = uint8.length % 3, // if we have 1 byte left, pad 2 bytes
|
||||
output = "",
|
||||
temp, length
|
||||
|
||||
function encode (num) {
|
||||
return lookup.charAt(num)
|
||||
}
|
||||
|
||||
function tripletToBase64 (num) {
|
||||
return encode(num >> 18 & 0x3F) + encode(num >> 12 & 0x3F) + encode(num >> 6 & 0x3F) + encode(num & 0x3F)
|
||||
}
|
||||
|
||||
// go through the array every three bytes, we'll deal with trailing stuff later
|
||||
for (i = 0, length = uint8.length - extraBytes; i < length; i += 3) {
|
||||
temp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
|
||||
output += tripletToBase64(temp)
|
||||
}
|
||||
|
||||
// pad the end with zeros, but make sure to not forget the extra bytes
|
||||
switch (extraBytes) {
|
||||
case 1:
|
||||
temp = uint8[uint8.length - 1]
|
||||
output += encode(temp >> 2)
|
||||
output += encode((temp << 4) & 0x3F)
|
||||
output += '=='
|
||||
break
|
||||
case 2:
|
||||
temp = (uint8[uint8.length - 2] << 8) + (uint8[uint8.length - 1])
|
||||
output += encode(temp >> 10)
|
||||
output += encode((temp >> 4) & 0x3F)
|
||||
output += encode((temp << 2) & 0x3F)
|
||||
output += '='
|
||||
break
|
||||
}
|
||||
|
||||
return output
|
||||
}
|
||||
|
||||
exports.toByteArray = b64ToByteArray
|
||||
exports.fromByteArray = uint8ToBase64
|
||||
}(typeof exports === 'undefined' ? (this.base64js = {}) : exports))
|
||||
34
node_modules/linebreak/node_modules/base64-js/package.json
generated
vendored
Normal file
34
node_modules/linebreak/node_modules/base64-js/package.json
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"author": "T. Jameson Little <t.jameson.little@gmail.com>",
|
||||
"name": "base64-js",
|
||||
"description": "Base64 encoding/decoding in pure JS",
|
||||
"version": "0.0.8",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/beatgammit/base64-js.git"
|
||||
},
|
||||
"main": "lib/b64.js",
|
||||
"scripts": {
|
||||
"test": "tape test/*.js"
|
||||
},
|
||||
"testling": {
|
||||
"files": "test/*.js",
|
||||
"browsers": [
|
||||
"ie/6..latest",
|
||||
"chrome/4..latest",
|
||||
"firefox/3..latest",
|
||||
"safari/5.1..latest",
|
||||
"opera/11.0..latest",
|
||||
"iphone/6",
|
||||
"ipad/6"
|
||||
]
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"tape": "~2.3.2"
|
||||
}
|
||||
}
|
||||
51
node_modules/linebreak/node_modules/base64-js/test/convert.js
generated
vendored
Normal file
51
node_modules/linebreak/node_modules/base64-js/test/convert.js
generated
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
var test = require('tape'),
|
||||
b64 = require('../lib/b64'),
|
||||
checks = [
|
||||
'a',
|
||||
'aa',
|
||||
'aaa',
|
||||
'hi',
|
||||
'hi!',
|
||||
'hi!!',
|
||||
'sup',
|
||||
'sup?',
|
||||
'sup?!'
|
||||
];
|
||||
|
||||
test('convert to base64 and back', function (t) {
|
||||
t.plan(checks.length);
|
||||
|
||||
for (var i = 0; i < checks.length; i++) {
|
||||
var check = checks[i],
|
||||
b64Str,
|
||||
arr,
|
||||
str;
|
||||
|
||||
b64Str = b64.fromByteArray(map(check, function (char) { return char.charCodeAt(0); }));
|
||||
|
||||
arr = b64.toByteArray(b64Str);
|
||||
str = map(arr, function (byte) { return String.fromCharCode(byte); }).join('');
|
||||
|
||||
t.equal(check, str, 'Checked ' + check);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
function map (arr, callback) {
|
||||
var res = [],
|
||||
kValue,
|
||||
mappedValue;
|
||||
|
||||
for (var k = 0, len = arr.length; k < len; k++) {
|
||||
if ((typeof arr === 'string' && !!arr.charAt(k))) {
|
||||
kValue = arr.charAt(k);
|
||||
mappedValue = callback(kValue, k, arr);
|
||||
res[k] = mappedValue;
|
||||
} else if (typeof arr !== 'string' && k in arr) {
|
||||
kValue = arr[k];
|
||||
mappedValue = callback(kValue, k, arr);
|
||||
res[k] = mappedValue;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
18
node_modules/linebreak/node_modules/base64-js/test/url-safe.js
generated
vendored
Normal file
18
node_modules/linebreak/node_modules/base64-js/test/url-safe.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
var test = require('tape'),
|
||||
b64 = require('../lib/b64');
|
||||
|
||||
test('decode url-safe style base64 strings', function (t) {
|
||||
var expected = [0xff, 0xff, 0xbe, 0xff, 0xef, 0xbf, 0xfb, 0xef, 0xff];
|
||||
|
||||
var actual = b64.toByteArray('//++/++/++//');
|
||||
for (var i = 0; i < actual.length; i++) {
|
||||
t.equal(actual[i], expected[i])
|
||||
}
|
||||
|
||||
actual = b64.toByteArray('__--_--_--__');
|
||||
for (var i = 0; i < actual.length; i++) {
|
||||
t.equal(actual[i], expected[i])
|
||||
}
|
||||
|
||||
t.end();
|
||||
});
|
||||
57
node_modules/linebreak/package.json
generated
vendored
Normal file
57
node_modules/linebreak/package.json
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
{
|
||||
"name": "linebreak",
|
||||
"version": "1.1.0",
|
||||
"description": "An implementation of the Unicode Line Breaking Algorithm (UAX #14)",
|
||||
"source": "src/linebreaker.js",
|
||||
"type": "module",
|
||||
"main": "dist/main.cjs",
|
||||
"module": "dist/module.mjs",
|
||||
"exports": {
|
||||
"require": "./dist/main.cjs",
|
||||
"import": "./dist/module.mjs"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/devongovett/linebreaker.git"
|
||||
},
|
||||
"keywords": [
|
||||
"unicode",
|
||||
"text",
|
||||
"wrapping"
|
||||
],
|
||||
"author": "Devon Govett <devongovett@gmail.com>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/devongovett/linebreaker/issues"
|
||||
},
|
||||
"homepage": "https://github.com/devongovett/linebreaker",
|
||||
"dependencies": {
|
||||
"base64-js": "0.0.8",
|
||||
"unicode-trie": "^2.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": "^10.0.0",
|
||||
"parcel": "^2.5.0",
|
||||
"request": "^2.88.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "parcel build && mocha --reporter landing",
|
||||
"build": "parcel build",
|
||||
"prepublishOnly": "parcel build"
|
||||
},
|
||||
"targets": {
|
||||
"main": {
|
||||
"includeNodeModules": [
|
||||
"fs"
|
||||
]
|
||||
},
|
||||
"module": {
|
||||
"includeNodeModules": [
|
||||
"fs"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
62
node_modules/linebreak/readme.md
generated
vendored
Normal file
62
node_modules/linebreak/readme.md
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
# linebreak
|
||||
An implementation of the Unicode Line Breaking Algorithm (UAX #14)
|
||||
|
||||
> Line breaking, also known as word wrapping, is the process of breaking a section of text into lines such that it will fit in the
|
||||
> available width of a page, window or other display area. The Unicode Line Breaking Algorithm performs part of this process.
|
||||
> Given an input text, it produces a set of positions called "break opportunities" that are appropriate points to begin a new line.
|
||||
> The selection of actual line break positions from the set of break opportunities is not covered by the Unicode Line Breaking Algorithm,
|
||||
> but is in the domain of higher level software with knowledge of the available width and the display size of the text.
|
||||
|
||||
This is a JavaScript implementation of the [Unicode Line Breaking Algorithm](http://www.unicode.org/reports/tr14/#SampleCode) for Node.js
|
||||
(and browsers I guess). Currently supports Unicode version 13. It is used by [PDFKit](http://github.com/devongovett/pdfkit/) for
|
||||
line wrapping text in PDF documents, but since the algorithm knows nothing about the actual visual appearance or layout of text,
|
||||
it could be used for other things as well.
|
||||
|
||||
## Installation
|
||||
|
||||
You can install via npm
|
||||
|
||||
npm install linebreak
|
||||
|
||||
## Example
|
||||
|
||||
```javascript
|
||||
var LineBreaker = require('linebreak');
|
||||
|
||||
var lorem = 'lorem ipsum...';
|
||||
var breaker = new LineBreaker(lorem);
|
||||
var last = 0;
|
||||
var bk;
|
||||
|
||||
while (bk = breaker.nextBreak()) {
|
||||
// get the string between the last break and this one
|
||||
var word = lorem.slice(last, bk.position);
|
||||
console.log(word);
|
||||
|
||||
// you can also check bk.required to see if this was a required break...
|
||||
if (bk.required) {
|
||||
console.log('\n\n');
|
||||
}
|
||||
|
||||
last = bk.position;
|
||||
}
|
||||
```
|
||||
|
||||
## Development Notes
|
||||
|
||||
In order to use the library, you shouldn't need to know this, but if you're interested in
|
||||
contributing or fixing bugs, these things might be of interest.
|
||||
|
||||
* The `src/classes.js` file is automatically generated from `LineBreak.txt` in the Unicode
|
||||
database by `src/generate_data.js`. It should be rare that you need to run this, but
|
||||
you may if, for instance, you want to change the Unicode version.
|
||||
|
||||
* You can run the tests using `npm test`. They are written using `mocha`, and generated from
|
||||
`LineBreakTest.txt` from the Unicode database, which is included in the repository for performance
|
||||
reasons while running them. About 50 of the over 7600 tests are currently skipped due to
|
||||
implementation differences. It appears that some of the tests may be wrong or use different
|
||||
tailoring from the spec.
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
Reference in New Issue
Block a user