@fraczak/k 1.3.3 → 2.0.0

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/test.js DELETED
@@ -1,161 +0,0 @@
1
- // Generated by CoffeeScript 2.7.0
2
- (function() {
3
- var k, k_expression, k_fn;
4
-
5
- k = require("./index.coffee");
6
-
7
- console.log('var k = require("k");');
8
-
9
- console.log("");
10
-
11
- [
12
- ["ANYTHING...",
13
- '()'],
14
- ["ANYTHING...",
15
- '{"ala" name, 23 age}'],
16
- [
17
- {
18
- year: 2002,
19
- age: 19
20
- },
21
- '[.year, .age]'
22
- ],
23
- ["duplicate me",
24
- '[(), ()]'],
25
- ["nesting",
26
- '[[[()]]]'],
27
- ["nesting and accessing",
28
- '[[()]] {() nested, .0.0 val}'],
29
- [
30
- {
31
- test: "parse integer"
32
- },
33
- '0000'
34
- ],
35
- [
36
- {
37
- x: 3,
38
- y: 4
39
- },
40
- '[.y,.x] PLUS'
41
- ]
42
- ].map(function([data, script]) {
43
- console.log(`k_expression = '${script}';`);
44
- console.log(`k.run(k_expression,${JSON.stringify(data)});`);
45
- console.log(`// RETURNS: ${JSON.stringify(k.run(script, data))}`);
46
- return console.log("");
47
- });
48
-
49
- k_expression = '{.name nom, <[.age, 18] GT .0, [.age, 12] GT "ado", "enfant"> age}';
50
-
51
- k_fn = k.compile(k_expression);
52
-
53
- console.log(`var k_fn = k.compile('${k_expression}');`);
54
-
55
- console.log("");
56
-
57
- [
58
- {
59
- age: 23,
60
- name: "Emily"
61
- },
62
- {
63
- age: 16,
64
- name: "Katrina"
65
- },
66
- {
67
- age: 2,
68
- name: "Mark"
69
- }
70
- ].map(function(data) {
71
- console.log(`k_fn(${JSON.stringify(data)});`);
72
- console.log(`// RETURNS: ${JSON.stringify(k_fn(data))}`);
73
- return console.log("");
74
- });
75
-
76
- k_expression = "$t = < i: int, t: [ t ] > ; <$t, $int>";
77
-
78
- k_fn = k.compile(k_expression);
79
-
80
- console.log(`var k_fn = k.compile('${k_expression}');`);
81
-
82
- console.log("");
83
-
84
- [
85
- 1,
86
- {
87
- i: 1
88
- },
89
- [
90
- {
91
- i: 2
92
- },
93
- {
94
- i: 3
95
- },
96
- {
97
- t: []
98
- }
99
- ],
100
- {
101
- "t": [
102
- {
103
- "i": 2
104
- },
105
- {
106
- "i": 3
107
- },
108
- {
109
- "t": []
110
- }
111
- ]
112
- }
113
- ].map(function(data) {
114
- console.log(`k_fn(${JSON.stringify(data)});`);
115
- console.log(`// RETURNS: ${JSON.stringify(k_fn(data))}`);
116
- return console.log("");
117
- });
118
-
119
- k_expression = "$ < < [ int ] ints, [ bool ] bools > list, string None>";
120
-
121
- k_fn = k.compile(k_expression);
122
-
123
- console.log(`var k_fn = k.compile('${k_expression}');`);
124
-
125
- console.log("");
126
-
127
- [
128
- {
129
- None: "None"
130
- },
131
- {
132
- list: {
133
- ints: []
134
- }
135
- },
136
- {
137
- list: {
138
- ints: [1,
139
- 2,
140
- 3]
141
- }
142
- },
143
- {
144
- list: {
145
- bools: [true,
146
- false]
147
- }
148
- },
149
- {
150
- list: {
151
- bools: [true,
152
- 0]
153
- }
154
- }
155
- ].map(function(data) {
156
- console.log(`k_fn(${JSON.stringify(data)});`);
157
- console.log(`// RETURNS: ${JSON.stringify(k_fn(data))}`);
158
- return console.log("");
159
- });
160
-
161
- }).call(this);