progress on migrating to heex templates and font-icons

This commit is contained in:
Adam Piontek 2022-08-13 07:32:36 -04:00
parent d43daafdb7
commit 3eff955672
21793 changed files with 2161968 additions and 16895 deletions

View file

@ -0,0 +1,27 @@
"use strict";
module.exports = {
env: {
browser: true,
commonjs: true,
es2020: true,
},
extends: ["eslint:all", "prettier", "plugin:node/recommended"],
parserOptions: {
ecmaVersion: 11,
},
rules: {
camelcase: "off",
"capitalized-comments": "off",
curly: ["error", "all"],
"id-length": "off",
"max-lines-per-function": "off",
"max-statements": "off",
"multiline-comment-style": "off",
"no-bitwise": "off",
"no-magic-numbers": "off",
"no-param-reassign": "off",
"no-plusplus": "off",
"one-var": "off",
"padded-blocks": "off",
},
};

View file

@ -0,0 +1,4 @@
{
"tabWidth": 2,
"useTabs": false
}

View file

@ -0,0 +1,17 @@
sudo: false
language: node_js
os:
- linux
- osx
- windows
arch: amd64
node_js:
- node
script:
- npm test
- npm run test:coveralls

21
assets_old/node_modules/fastest-levenshtein/LICENSE.md generated vendored Normal file
View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020 Kasper Unn Weihe
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.

55
assets_old/node_modules/fastest-levenshtein/README.md generated vendored Normal file
View file

@ -0,0 +1,55 @@
# fastest-levenshtein :rocket:
> Fastest JS implemenation of [Levenshtein distance](https://en.wikipedia.org/wiki/Levenshtein_distance).<br>
> Measure the difference between two strings.
[![Build Status](https://travis-ci.org/ka-weihe/node-levenshtein.svg?branch=master)](https://travis-ci.org/ka-weihe/node-levenshtein)
[![Coverage Status](https://coveralls.io/repos/github/ka-weihe/node-levenshtein/badge.svg?branch=master)](https://coveralls.io/github/ka-weihe/node-levenshtein?branch=master)
```
$ npm i fastest-levenshtein
```
## Usage
### Node
```javascript
const {distance, closest} = require('fastest-levenshtein')
// Print levenshtein-distance between 'fast' and 'faster'
console.log(distance('fast', 'faster'))
//=> 2
// Print string from array with lowest edit-distance to 'fast'
console.log(closest('fast', ['slow', 'faster', 'fastest']))
//=> 'faster'
```
### Deno
```javascript
import {distance, closest} from 'https://deno.land/x/fastest_levenshtein/mod.ts'
// Print levenshtein-distance between 'fast' and 'faster'
console.log(distance('fast', 'faster'))
//=> 2
// Print string from array with lowest edit-distance to 'fast'
console.log(closest('fast', ['slow', 'faster', 'fastest']))
//=> 'faster'
```
## Benchmark
I generated 500 pairs of strings with length N. I measured the ops/sec each library achieves to process all the given pairs. Higher is better. `fastest-levenshtein` is a lot faster in all cases.
| Test Target | N=4 | N=8 | N=16 | N=32 | N=64 | N=128 | N=256 | N=512 | N=1024 |
|---------------------------|-------|-------|-------|------|-------|-------|-------|-------|--------|
| fastest-levenshtein | 44423 | 23702 | 10764 | 4595 | 1049 | 291.5 | 86.64 | 22.24 | 5.473 |
| js-levenshtein | 21261 | 10030 | 2939 | 824 | 223 | 57.62 | 14.77 | 3.717 | 0.934 |
| leven | 19688 | 6884 | 1606 | 436 | 117 | 30.34 | 7.604 | 1.929 | 0.478 |
| fast-levenshtein | 18577 | 6112 | 1265 | 345 | 89.41 | 22.70 | 5.676 | 1.428 | 0.348 |
| levenshtein-edit-distance | 22968 | 7445 | 1493 | 409 | 109 | 28.07 | 7.095 | 1.789 | 0.445 |
### Relative Performance
This image shows the relative performance between `fastest-levenshtein` and `js-levenshtein` (the 2nd fastest). `fastest-levenshtein` is always a lot faster. x-axis shows "times faster".
![Benchmark](/images/relaperf.png)
## License
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details

View file

@ -0,0 +1,2 @@
export function distance(a: string, b: string): number;
export function closest(str: string, arr: string[]): string;

147
assets_old/node_modules/fastest-levenshtein/index.js generated vendored Normal file
View file

@ -0,0 +1,147 @@
"use strict";
const peq = new Uint32Array(0x10000);
const myers_32 = (a, b) => {
const n = a.length;
const m = b.length;
const lst = 1 << (n - 1);
let pv = -1;
let mv = 0;
let sc = n;
let i = n;
while (i--) {
peq[a.charCodeAt(i)] |= 1 << i;
}
for (i = 0; i < m; i++) {
let eq = peq[b.charCodeAt(i)];
const xv = eq | mv;
eq |= ((eq & pv) + pv) ^ pv;
mv |= ~(eq | pv);
pv &= eq;
if (mv & lst) {
sc++;
}
if (pv & lst) {
sc--;
}
mv = (mv << 1) | 1;
pv = (pv << 1) | ~(xv | mv);
mv &= xv;
}
i = n;
while (i--) {
peq[a.charCodeAt(i)] = 0;
}
return sc;
};
const myers_x = (a, b) => {
const n = a.length;
const m = b.length;
const mhc = [];
const phc = [];
const hsize = Math.ceil(n / 32);
const vsize = Math.ceil(m / 32);
let score = m;
for (let i = 0; i < hsize; i++) {
phc[i] = -1;
mhc[i] = 0;
}
let j = 0;
for (; j < vsize - 1; j++) {
let mv = 0;
let pv = -1;
const start = j * 32;
const end = Math.min(32, m) + start;
for (let k = start; k < end; k++) {
peq[b.charCodeAt(k)] |= 1 << k;
}
score = m;
for (let i = 0; i < n; i++) {
const eq = peq[a.charCodeAt(i)];
const pb = (phc[(i / 32) | 0] >>> i) & 1;
const mb = (mhc[(i / 32) | 0] >>> i) & 1;
const xv = eq | mv;
const xh = ((((eq | mb) & pv) + pv) ^ pv) | eq | mb;
let ph = mv | ~(xh | pv);
let mh = pv & xh;
if ((ph >>> 31) ^ pb) {
phc[(i / 32) | 0] ^= 1 << i;
}
if ((mh >>> 31) ^ mb) {
mhc[(i / 32) | 0] ^= 1 << i;
}
ph = (ph << 1) | pb;
mh = (mh << 1) | mb;
pv = mh | ~(xv | ph);
mv = ph & xv;
}
for (let k = start; k < end; k++) {
peq[b.charCodeAt(k)] = 0;
}
}
let mv = 0;
let pv = -1;
const start = j * 32;
const end = Math.min(32, m - start) + start;
for (let k = start; k < end; k++) {
peq[b.charCodeAt(k)] |= 1 << k;
}
score = m;
for (let i = 0; i < n; i++) {
const eq = peq[a.charCodeAt(i)];
const pb = (phc[(i / 32) | 0] >>> i) & 1;
const mb = (mhc[(i / 32) | 0] >>> i) & 1;
const xv = eq | mv;
const xh = ((((eq | mb) & pv) + pv) ^ pv) | eq | mb;
let ph = mv | ~(xh | pv);
let mh = pv & xh;
score += (ph >>> (m - 1)) & 1;
score -= (mh >>> (m - 1)) & 1;
if ((ph >>> 31) ^ pb) {
phc[(i / 32) | 0] ^= 1 << i;
}
if ((mh >>> 31) ^ mb) {
mhc[(i / 32) | 0] ^= 1 << i;
}
ph = (ph << 1) | pb;
mh = (mh << 1) | mb;
pv = mh | ~(xv | ph);
mv = ph & xv;
}
for (let k = start; k < end; k++) {
peq[b.charCodeAt(k)] = 0;
}
return score;
};
const distance = (a, b) => {
if (a.length > b.length) {
const tmp = b;
b = a;
a = tmp;
}
if (a.length === 0) {
return b.length;
}
if (a.length <= 32) {
return myers_32(a, b);
}
return myers_x(a, b);
};
const closest = (str, arr) => {
let min_distance = Infinity;
let min_index = 0;
for (let i = 0; i < arr.length; i++) {
const dist = distance(str, arr[i]);
if (dist < min_distance) {
min_distance = dist;
min_index = i;
}
}
return arr[min_index];
};
module.exports = {
closest, distance
}

View file

@ -0,0 +1,63 @@
{
"name": "fastest-levenshtein",
"version": "1.0.12",
"description": "Fastest Levenshtein distance implementation in JS.",
"main": "index.js",
"repository": {
"type": "git",
"url": "git+https://github.com/ka-weihe/fastest-levenshtein.git"
},
"keywords": [
"levenshtein",
"distance",
"fast",
"fastest",
"edit",
"string",
"similarity",
"algorithm",
"match",
"comparison",
"fuzzy",
"search",
"string",
"matching",
"similar",
"node",
"difference"
],
"author": "Kasper U. Weihe",
"license": "MIT",
"bugs": {
"url": "https://github.com/ka-weihe/fastest-levenshtein/issues"
},
"homepage": "https://github.com/ka-weihe/fastest-levenshtein#README",
"scripts": {
"test": "jest",
"test:coverage": "jest --coverage",
"test:coveralls": "jest --coverage --coverageReporters=text-lcov | coveralls"
},
"devDependencies": {
"benchmark": "^2.1.4",
"coveralls": "^3.1.0",
"eslint": "^7.5.0",
"eslint-config-airbnb": "^18.2.0",
"eslint-config-airbnb-base": "^14.2.0",
"eslint-config-node": "^4.1.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.20.3",
"eslint-plugin-react-hooks": "^4.0.0",
"fast-levenshtein": "^2.0.6",
"jest": "^26.1.0",
"js-levenshtein": "^1.1.6",
"leven": "^3.1.0",
"natural": "^2.1.5",
"prettier": "^2.0.5",
"talisman": "^1.1.2",
"levenshtein-edit-distance": "^2.0.5"
}
}

64
assets_old/node_modules/fastest-levenshtein/test.js generated vendored Normal file
View file

@ -0,0 +1,64 @@
const {distance, closest} = require("./index.js");
const levenshtein = (a, b) => {
if (a.length === 0) return b.length;
if (b.length === 0) return a.length;
if (a.length > b.length) {
const tmp = a;
a = b;
b = tmp;
}
const row = [];
for (let i = 0; i <= a.length; i++) {
row[i] = i;
}
for (let i = 1; i <= b.length; i++) {
let prev = i;
for (let j = 1; j <= a.length; j++) {
let val;
if (b.charAt(i - 1) === a.charAt(j - 1)) {
val = row[j - 1];
} else {
val = Math.min(row[j - 1] + 1, prev + 1, row[j] + 1);
}
row[j - 1] = prev;
prev = val;
}
row[a.length] = prev;
}
return row[a.length];
};
function makeid(length) {
let result = "";
const characters =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
const charactersLength = characters.length;
for (let i = 0; i < length; i++) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
test("test compare", () => {
const errors = 0;
for (let i = 0; i < 1000; i++) {
const rnd_num1 = (Math.random() * 1000) | 0;
const rnd_num2 = (Math.random() * 1000) | 0;
const rnd_string1 = makeid(rnd_num1);
const rnd_string2 = makeid(rnd_num2);
const actual = distance(rnd_string1, rnd_string2);
const expected = levenshtein(rnd_string1, rnd_string2);
expect(actual).toBe(expected);
}
});
test("test find", () => {
const actual = closest("fast", ["slow", "faster", "fastest"]);
const expected = "faster";
expect(actual).toBe(expected);
});