kordweb 0.5.5 → 0.5.7
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 +42 -1
- package/klib.d.ts +510 -90
- package/klib.js +797 -361
- package/klib_bg.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
# kord
|
|
11
11
|
|
|
12
|
-
A music theory binary and library for Rust ([capability playground](https://kord.twitchax.com/)).
|
|
12
|
+
A music theory binary and library for Rust / JS (via WASM) ([capability playground](https://kord.twitchax.com/)).
|
|
13
13
|
|
|
14
14
|
## Binary Usage
|
|
15
15
|
|
|
@@ -44,6 +44,12 @@ Cargo:
|
|
|
44
44
|
$ cargo install kord
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
+
NPM:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
$ npm install --save kordweb
|
|
51
|
+
```
|
|
52
|
+
|
|
47
53
|
### Help Docs
|
|
48
54
|
|
|
49
55
|
```bash
|
|
@@ -193,6 +199,41 @@ use klib::chord::*;
|
|
|
193
199
|
assert_eq!(C.into_chord().augmented().major7().chord(), vec![C, E, GSharp, B]);
|
|
194
200
|
```
|
|
195
201
|
|
|
202
|
+
## JS Usage
|
|
203
|
+
|
|
204
|
+
The npm package is available [here](https://www.npmjs.com/package/kordweb).
|
|
205
|
+
|
|
206
|
+
First, load the module as you would any other ES module.
|
|
207
|
+
|
|
208
|
+
```js
|
|
209
|
+
import init, { KordNote, KordChord } from 'kordweb/klib.js';
|
|
210
|
+
|
|
211
|
+
// Run `init` once.
|
|
212
|
+
await init();
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Then, you can use the library similarly as you would in Rust.
|
|
216
|
+
|
|
217
|
+
```js
|
|
218
|
+
// Create a note.
|
|
219
|
+
const note = KordNote.parse('C4');
|
|
220
|
+
|
|
221
|
+
note.name(); // C4
|
|
222
|
+
note.octave(); // 4
|
|
223
|
+
|
|
224
|
+
// Create a chord.
|
|
225
|
+
const chord = KordChord.parse('C7#9');
|
|
226
|
+
|
|
227
|
+
chord.name(); // C7(♯9)
|
|
228
|
+
chord.chordString(); // C4 E4 G4 Bb5 D#5
|
|
229
|
+
|
|
230
|
+
// Easy chaining.
|
|
231
|
+
KordChord.parse('C7b9').withOctave(2).chord().map(n => n.name()); // [ 'C2', 'D♭2', 'E2', 'G2', 'B♭2' ]
|
|
232
|
+
|
|
233
|
+
// Build chords.
|
|
234
|
+
KordChord.parse('C').min().seven().chord().map(n => n.name()); // [ 'C4', 'Eb4', 'G4', 'Bb4' ]
|
|
235
|
+
```
|
|
236
|
+
|
|
196
237
|
## Feature Flags
|
|
197
238
|
|
|
198
239
|
The library and binary both support various feature flags. Of most important note are:
|