puzlink 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -2
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/parse.ts +3 -0
- package/src/puzlink.ts +7 -4
package/README.md
CHANGED
|
@@ -6,9 +6,40 @@ Inspired by cosmologicon's [puzlink](https://github.com/cosmologicon/puzlink), r
|
|
|
6
6
|
|
|
7
7
|
## Usage
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Install with `npm install puzlink`. This is an ESM only library.
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
```ts
|
|
12
|
+
import { Puzlink } from "puzlink";
|
|
13
|
+
|
|
14
|
+
const puzlink = await Puzlink.download();
|
|
15
|
+
|
|
16
|
+
puzlink.link(`
|
|
17
|
+
BATED, TANK, BUSINESS, ETC, OVER, ELVIS, CAR, COW, MARS, PARIS, AIRLINES
|
|
18
|
+
`);
|
|
19
|
+
// {
|
|
20
|
+
// name: "10/11 can insert h",
|
|
21
|
+
// score: 30.8,
|
|
22
|
+
// description: [
|
|
23
|
+
// "bated insert h = bathed",
|
|
24
|
+
// "tank insert h = thank",
|
|
25
|
+
// "etc insert h = etch",
|
|
26
|
+
// "over insert h = hover",
|
|
27
|
+
// "elvis insert h = elvish",
|
|
28
|
+
// "car insert h = char",
|
|
29
|
+
// "cow insert h = chow",
|
|
30
|
+
// "mars insert h = marsh",
|
|
31
|
+
// "paris insert h = parish, pharis",
|
|
32
|
+
// "airlines insert h = hairlines"
|
|
33
|
+
// ],
|
|
34
|
+
// },
|
|
35
|
+
// ...
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Why?
|
|
39
|
+
|
|
40
|
+
puzlink used to be online on [puz.link](https://puz.link/), but the website has been down for maintenance for a while now. While I've used the library locally, nothing can beat the convenience of a web app. I'm a believer in client-side solving tools, so I wanted to make it run client-side too; that's partly why I wrote [cromulence](https://blog.cjquines.com/post/cromulence/) a year ago.
|
|
41
|
+
|
|
42
|
+
Collective.jl is a huge design influence. I liked the idea of applying the binomial distribution to boolean word properties, which I used for computing many linker probabilities. A lot of the test cases in `scripts/evals` are from Collective.jl too.
|
|
12
43
|
|
|
13
44
|
## Development
|
|
14
45
|
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
package/src/parse.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// This is in a separate file for tree-shaking reasons.
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Parse an input to a list of slugs.
|
|
3
5
|
*
|
|
@@ -6,6 +8,7 @@
|
|
|
6
8
|
*/
|
|
7
9
|
export function parse(words: string | readonly string[]): string[] {
|
|
8
10
|
if (typeof words === "string") {
|
|
11
|
+
words = words.trim();
|
|
9
12
|
if (words.includes("\n")) {
|
|
10
13
|
words = words.split("\n");
|
|
11
14
|
} else if (words.includes(",")) {
|
package/src/puzlink.ts
CHANGED
|
@@ -59,6 +59,11 @@ export type LinkOptions = {
|
|
|
59
59
|
ordered?: boolean;
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
+
/** Create a Puzlink instance by downloading the cromulence wordlist. */
|
|
63
|
+
export async function download(): Promise<Puzlink> {
|
|
64
|
+
return new Puzlink(await loadWordlist());
|
|
65
|
+
}
|
|
66
|
+
|
|
62
67
|
export class Puzlink {
|
|
63
68
|
linkers: Linker[];
|
|
64
69
|
|
|
@@ -66,10 +71,8 @@ export class Puzlink {
|
|
|
66
71
|
this.linkers = allLinkers(new Wordlist(wordlist));
|
|
67
72
|
}
|
|
68
73
|
|
|
69
|
-
|
|
70
|
-
static
|
|
71
|
-
return new Puzlink(await loadWordlist());
|
|
72
|
-
}
|
|
74
|
+
static download = download;
|
|
75
|
+
static parse = parse;
|
|
73
76
|
|
|
74
77
|
private *linkLazy(
|
|
75
78
|
slugs: string[],
|