-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.js
executable file
·50 lines (42 loc) · 1.33 KB
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env node
var DatamatrixDecoder = require('./index.js');
// Encodes the ASCII string "Wikipedia"
var bits = [
[1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0],
[1,0,1,1,0,0,1,0,1,0,1,0,1,0,1,1],
[1,1,0,1,0,1,0,1,0,1,0,1,1,1,0,0],
[1,0,1,0,1,1,0,1,0,0,0,0,0,1,1,1],
[1,1,0,1,0,0,1,0,1,0,0,1,0,0,0,0],
[1,0,1,0,0,1,1,0,1,1,0,1,1,0,1,1],
[1,1,1,1,0,1,1,1,0,0,0,0,0,0,1,0],
[1,0,0,1,0,0,1,1,1,0,0,0,1,0,0,1],
[1,0,1,0,0,0,1,1,1,1,1,0,1,1,0,0],
[1,0,1,0,0,1,1,0,1,0,0,1,0,0,1,1],
[1,1,0,0,1,1,0,0,1,0,1,1,0,0,1,0],
[1,0,1,0,0,0,1,1,1,0,1,0,0,1,1,1],
[1,0,0,1,0,1,0,0,1,1,1,1,0,0,1,0],
[1,1,0,0,0,0,1,0,0,1,1,0,1,1,0,1],
[1,1,1,1,1,1,0,1,0,1,0,0,0,0,1,0],
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]
];
// Encodes the numeric value 1901371821
// using digit pairs
var digitBits = [
[1,0,1,0,1,0,1,0,1,0,1,0],
[1,1,0,1,1,1,0,1,0,1,0,1],
[1,0,0,0,1,0,1,0,0,0,1,0],
[1,0,1,1,0,1,0,1,1,1,0,1],
[1,0,1,1,1,1,1,1,1,0,0,0],
[1,1,0,0,0,1,0,1,1,1,1,1],
[1,0,0,0,0,1,0,1,0,1,0,0],
[1,0,0,0,0,1,0,0,0,0,0,1],
[1,0,1,1,1,0,1,0,0,0,1,0],
[1,1,0,1,1,0,1,1,1,1,0,1],
[1,1,0,0,1,0,0,1,1,0,1,0],
[1,1,1,1,1,1,1,1,1,1,1,1]
];
var str;
str = DatamatrixDecoder(bits);
console.log("Ascii decoded:", str);
str = DatamatrixDecoder(digitBits);
console.log("Digit pairs decoded:", str);