Skip to content

Commit cb6c426

Browse files
committed
export to npm module
1 parent 9fb9072 commit cb6c426

File tree

3 files changed

+69
-1
lines changed

3 files changed

+69
-1
lines changed

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ src = src
22
ifndef dest
33
dest = dist
44
endif
5+
ifndef destnpm
6+
destnpm = npm_export
7+
endif
58
closure = lib/compiler.jar
69
externJQ = --externs lib/jquery-1.7.js
710
externTwisty = --externs $(dest)/js/twisty.js
@@ -138,7 +141,7 @@ worker.js)
138141

139142
cstimer = $(dest)/js/cstimer.js
140143
twisty = $(dest)/js/twisty.js
141-
cstimer_module = $(dest)/js/cstimer_module.js
144+
cstimer_module = $(destnpm)/cstimer_module.js
142145
css = $(addprefix $(dest)/css/, $(shell ls $(src)/css))
143146
langJS = $(addprefix $(dest)/lang/, $(shell ls $(src)/lang/ | grep .*\.js))
144147
langPHP = $(addprefix $(dest)/lang/, $(shell ls $(src)/lang/ | grep .*\.php))

npm_export/README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# csTimer module
2+
The csTimer module is a function library that individually package some functions in csTimer.
3+
4+
Currently it only includes some of the scrambl functions supported by csTimer, and more functions will be supported later.
5+
6+
The csTimer module is part of csTimer and shares the same source code as csTimer: https://github.com/cs0x7f/cstimer
7+
8+
## Install
9+
10+
```bash
11+
# install
12+
npm i cstimer_module
13+
```
14+
15+
## Usage
16+
17+
```javascript
18+
var cstimer = require('cstimer_module');
19+
20+
// List all scramble types
21+
console.log(cstimer.getScrambleTypes());
22+
23+
// Generate random-state 3x3x3 scramble
24+
console.log(cstimer.getScramble('333'));
25+
26+
// Generate scrambles for all wca events
27+
var wca_events = [
28+
["3x3x3", "333", 0],
29+
["2x2x2", "222so", 0],
30+
["4x4x4", "444wca", 0],
31+
["5x5x5", "555wca", 60],
32+
["6x6x6", "666wca", 80],
33+
["7x7x7", "777wca", 100],
34+
["3x3 bld", "333ni", 0],
35+
["3x3 fm", "333fm", 0],
36+
["3x3 oh", "333", 0],
37+
["clock", "clkwca", 0],
38+
["megaminx", "mgmp", 70],
39+
["pyraminx", "pyrso", 10],
40+
["skewb", "skbso", 0],
41+
["sq1", "sqrs", 0],
42+
["4x4 bld", "444bld", 40],
43+
["5x5 bld", "555bld", 60],
44+
["3x3 mbld", "r3ni", 5]
45+
];
46+
47+
for (var i = 0; i < wca_events.length; i++) {
48+
var param = wca_events[i];
49+
console.log(param[0] + ': ', cstimer.getScramble(param[1] /*scramble type*/, param[2] /*scramble length*/));
50+
}
51+
```

npm_export/package.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "cstimer_module",
3+
"version": "0.0.2",
4+
"description": "scramble and tools used in csTimer",
5+
"main": "cstimer_module.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"keywords": [
10+
"Rubik's Cube"
11+
],
12+
"author": "cs0x7f",
13+
"license": "GPL-3.0"
14+
}

0 commit comments

Comments
 (0)