lang-json 1.0.3 → 213.21.24

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of lang-json might be problematic. Click here for more details.

Files changed (37) hide show
  1. package/index.js +34 -0
  2. package/package.json +7 -57
  3. package/README.md +0 -0
  4. package/babel.config.js +0 -8
  5. package/coverage/clover.xml +0 -6
  6. package/coverage/coverage-final.json +0 -1
  7. package/coverage/lcov-report/base.css +0 -224
  8. package/coverage/lcov-report/block-navigation.js +0 -87
  9. package/coverage/lcov-report/favicon.png +0 -0
  10. package/coverage/lcov-report/index.html +0 -101
  11. package/coverage/lcov-report/prettify.css +0 -1
  12. package/coverage/lcov-report/prettify.js +0 -2
  13. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  14. package/coverage/lcov-report/sorter.js +0 -196
  15. package/coverage/lcov.info +0 -0
  16. package/dist/esm/src/index.d.ts +0 -18
  17. package/dist/esm/src/index.js +0 -369
  18. package/dist/esm/src/index.js.map +0 -1
  19. package/dist/esm/src/modules/is-this/index.d.ts +0 -136
  20. package/dist/esm/src/modules/is-this/index.js +0 -484
  21. package/dist/esm/src/modules/is-this/index.js.map +0 -1
  22. package/dist/esm/tests/helpers.test.d.ts +0 -1
  23. package/dist/esm/tests/helpers.test.js +0 -284
  24. package/dist/esm/tests/helpers.test.js.map +0 -1
  25. package/dist/esm/tests/index.test.d.ts +0 -1
  26. package/dist/esm/tests/index.test.js +0 -537
  27. package/dist/esm/tests/index.test.js.map +0 -1
  28. package/dist/esm/tests/readme.test.d.ts +0 -1
  29. package/dist/esm/tests/readme.test.js +0 -73
  30. package/dist/esm/tests/readme.test.js.map +0 -1
  31. package/jest.config.ts +0 -212
  32. package/src/index.ts +0 -467
  33. package/src/modules/is-this/index.ts +0 -682
  34. package/tests/helpers.test.ts +0 -331
  35. package/tests/index.test.ts +0 -681
  36. package/tests/readme.test.ts +0 -78
  37. package/tsconfig.json +0 -16
@@ -1,331 +0,0 @@
1
- import LangJSON from "../src/index";
2
-
3
- describe("LangJSON Helpers", () => {
4
- const langJson = new LangJSON();
5
-
6
- // var helper
7
- test("var", () => {
8
- const template = "{{#var name}}";
9
- const result = langJson.applyTemplate(template, { name: "Devansh" });
10
- expect(result).toBe("Devansh");
11
- });
12
-
13
- // manupilating helpers
14
- test("each", () => {
15
- const template = { "{{#each items}}": { name: "{{#var item}}" } };
16
- const result = langJson.applyTemplate(template, {
17
- items: ["Apple", "Banana", "Grapes"],
18
- });
19
- expect(result).toEqual([
20
- { name: "Apple" },
21
- { name: "Banana" },
22
- { name: "Grapes" },
23
- ]);
24
- });
25
-
26
- // manupilating helpers
27
- test("loop", () => {
28
- const template = {
29
- "{{#loop items.length}}": { name: "{{#var items[(var index)]}}" },
30
- };
31
- const result = langJson.applyTemplate(template, {
32
- items: ["Apple", "Banana", "Grapes"],
33
- });
34
- expect(result).toEqual([
35
- { name: "Apple" },
36
- { name: "Banana" },
37
- { name: "Grapes" },
38
- ]);
39
- });
40
-
41
- // String Helpers
42
- test("uppercase", () => {
43
- const template = "{{#uppercase 'hello'}}";
44
- const result = langJson.applyTemplate(template, {});
45
- expect(result).toBe("HELLO");
46
- });
47
-
48
- test("lowercase", () => {
49
- const template = "{{#lowercase 'HELLO'}}";
50
- const result = langJson.applyTemplate(template, {});
51
- expect(result).toBe("hello");
52
- });
53
-
54
- test("capitalize", () => {
55
- const template = "{{#capitalize 'hello'}}";
56
- const result = langJson.applyTemplate(template, {});
57
- expect(result).toBe("Hello");
58
- });
59
-
60
- test("trim", () => {
61
- const template = "{{#trim ' hello '}}";
62
- const result = langJson.applyTemplate(template, {});
63
- expect(result).toBe("hello");
64
- });
65
-
66
- test("concat", () => {
67
- const template = "{{#concat 'Hello' ' ' 'World'}}";
68
- const result = langJson.applyTemplate(template, {});
69
- expect(result).toBe("Hello World");
70
- });
71
-
72
- test("replace", () => {
73
- const template = "{{#replace 'hello world' 'world' 'jest'}}";
74
- const result = langJson.applyTemplate(template, {});
75
- expect(result).toBe("hello jest");
76
- });
77
-
78
- test("split", () => {
79
- const template = "{{#split 'a,b,c' ','}}";
80
- const result = langJson.applyTemplate(template, {});
81
- expect(result).toEqual(["a", "b", "c"]);
82
- });
83
-
84
- test("join", () => {
85
- const template = "{{#join (split 'a,b,c' ',') '-'}}";
86
- const result = langJson.applyTemplate(template, {});
87
- expect(result).toBe("a-b-c");
88
- });
89
-
90
- test("contains", () => {
91
- const template = "{{#contains 'a-nice-string' '-'}}";
92
- const result = langJson.applyTemplate(template, {});
93
- expect(result).toBe(true);
94
- });
95
-
96
- test("length", () => {
97
- const template = "{{#length 'a-nice-string'}}";
98
- const result = langJson.applyTemplate(template, {});
99
- expect(result).toBe(13);
100
- });
101
-
102
- test("startsWith", () => {
103
- const template = "{{#startsWith 'Hello, World' 'Hello'}}";
104
- const result = langJson.applyTemplate(template, {});
105
- expect(result).toBe(true);
106
- });
107
-
108
- test("endsWith", () => {
109
- const template = "{{#endsWith 'Hello, World' 'World'}}";
110
- const result = langJson.applyTemplate(template, {});
111
- expect(result).toBe(true);
112
- });
113
-
114
- test("reverseString", () => {
115
- const template = "{{#reverseString 'jest'}}";
116
- const result = langJson.applyTemplate(template, {});
117
- expect(result).toBe("tsej");
118
- });
119
-
120
- test("repeat", () => {
121
- const template = "{{#repeat 'jest ' 3}}";
122
- const result = langJson.applyTemplate(template, {});
123
- expect(result).toBe("jest jest jest ");
124
- });
125
-
126
- // Mathematical Helpers
127
- test("add", () => {
128
- const template = "{{#add 1 2}}";
129
- const result = langJson.applyTemplate(template, {});
130
- expect(result).toBe(3);
131
- });
132
-
133
- test("subtract", () => {
134
- const template = "{{#subtract 5 3}}";
135
- const result = langJson.applyTemplate(template, {});
136
- expect(result).toBe(2);
137
- });
138
-
139
- test("multiply", () => {
140
- const template = "{{#multiply 2 3}}";
141
- const result = langJson.applyTemplate(template, {});
142
- expect(result).toBe(6);
143
- });
144
-
145
- test("divide", () => {
146
- const template = "{{#divide 6 3}}";
147
- const result = langJson.applyTemplate(template, {});
148
- expect(result).toBe(2);
149
- });
150
-
151
- test("modulo", () => {
152
- const template = "{{#modulo 5 2}}";
153
- const result = langJson.applyTemplate(template, {});
154
- expect(result).toBe(1);
155
- });
156
-
157
- test("max", () => {
158
- const template = "{{#max 1 2 3 4}}";
159
- const result = langJson.applyTemplate(template, {});
160
- expect(result).toBe(4);
161
- });
162
-
163
- test("min", () => {
164
- const template = "{{#min 1 2 3 4}}";
165
- const result = langJson.applyTemplate(template, {});
166
- expect(result).toBe(1);
167
- });
168
-
169
- test("round", () => {
170
- const template = "{{#round 4.7}}";
171
- const result = langJson.applyTemplate(template, {});
172
- expect(result).toBe(5);
173
- });
174
-
175
- test("floor", () => {
176
- const template = "{{#floor 4.7}}";
177
- const result = langJson.applyTemplate(template, {});
178
- expect(result).toBe(4);
179
- });
180
-
181
- test("ceil", () => {
182
- const template = "{{#ceil 4.1}}";
183
- const result = langJson.applyTemplate(template, {});
184
- expect(result).toBe(5);
185
- });
186
-
187
- // Logical Helpers
188
- test("if", () => {
189
- const template = "{{#if true 'yes' 'no'}}";
190
- const result = langJson.applyTemplate(template, {});
191
- expect(result).toBe("yes");
192
- });
193
-
194
- test("and", () => {
195
- const template = "{{#and true true}}";
196
- const result = langJson.applyTemplate(template, {});
197
- expect(result).toBe(true);
198
- });
199
-
200
- test("or", () => {
201
- const template = "{{#or false true}}";
202
- const result = langJson.applyTemplate(template, {});
203
- expect(result).toBe(true);
204
- });
205
-
206
- test("not", () => {
207
- const template = "{{#not false}}";
208
- const result = langJson.applyTemplate(template, {});
209
- expect(result).toBe(true);
210
- });
211
-
212
- // Date Helpers
213
- test("getCurrentDate", () => {
214
- const template = "{{#getCurrentDate}}";
215
- const result = langJson.applyTemplate(template, {});
216
- const currentDate = new Date().toISOString().split("T")[0];
217
- expect(result).toBe(currentDate);
218
- });
219
-
220
- test("getCurrentTime", () => {
221
- const template = "{{#getCurrentTime}}";
222
- const result = langJson.applyTemplate(template, {});
223
- const currentTime = new Date().toLocaleTimeString();
224
- expect(result).toBe(currentTime);
225
- });
226
-
227
- // Array Helpers
228
- test("arrayLength", () => {
229
- const template = "{{#arrayLength (split '1,2,3' ',')}}";
230
- const result = langJson.applyTemplate(template, {});
231
- expect(result).toBe(3);
232
- });
233
-
234
- test("arrayIncludes", () => {
235
- const template = "{{#arrayIncludes (split '1,2,3' ',') '2'}}";
236
- const result = langJson.applyTemplate(template, {});
237
- expect(result).toBe(true);
238
- });
239
-
240
- test("arrayJoin", () => {
241
- const template = "{{#arrayJoin (split '1,2,3' ',') '-'}}";
242
- const result = langJson.applyTemplate(template, {});
243
- expect(result).toBe("1-2-3");
244
- });
245
-
246
- test("uniqueArray", () => {
247
- const template = "{{#uniqueArray (split '1,1,2,3' ',')}}";
248
- const result = langJson.applyTemplate(template, {});
249
- expect(result).toEqual(["1", "2", "3"]);
250
- });
251
-
252
- // Object Helpers
253
- test("objectKeys", () => {
254
- const template = "{{#objectKeys data}}";
255
- const result = langJson.applyTemplate(template, {
256
- data: { a: 1, b: 2 },
257
- });
258
- expect(result).toEqual(["a", "b"]);
259
- });
260
-
261
- test("objectValues", () => {
262
- const template = "{{#objectValues data}}";
263
- const result = langJson.applyTemplate(template, {
264
- data: { a: 1, b: 2 },
265
- });
266
- expect(result).toEqual([1, 2]);
267
- });
268
-
269
- test("mergeObjects", () => {
270
- const template = "{{#mergeObjects data data2}}";
271
- const result = langJson.applyTemplate(template, {
272
- data: { a: 1, b: 2 },
273
- data2: { c: 3, d: 4 },
274
- });
275
- expect(result).toEqual({ a: 1, b: 2, c: 3, d: 4 });
276
- });
277
-
278
- // Date Helpers
279
- test("getCurrentDate", () => {
280
- const template = "{{#getCurrentDate}}";
281
- const result = langJson.applyTemplate(template, {});
282
- const currentDate = new Date().toISOString().split("T")[0];
283
- expect(result).toBe(currentDate);
284
- });
285
-
286
- test("getCurrentTime", () => {
287
- const template = "{{#getCurrentTime}}";
288
- const result = langJson.applyTemplate(template, {});
289
- const currentTime = new Date().toLocaleTimeString();
290
- expect(result).toBe(currentTime);
291
- });
292
-
293
- // Miscellaneous Helpers
294
- test("jsonStringify", () => {
295
- const template = "{{#jsonStringify data}}";
296
- const result = langJson.applyTemplate(template, {
297
- data: { a: 1, b: 2 },
298
- });
299
- expect(result).toBe('{"a":1,"b":2}');
300
- });
301
-
302
- test("deepEqual", () => {
303
- const template = "{{#deepEqual data data2}}";
304
- const result = langJson.applyTemplate(template, {
305
- data: { a: 1 },
306
- data2: { a: 1 },
307
- });
308
- expect(result).toBe(true);
309
- });
310
-
311
- test("delay", async () => {
312
- const template = "{{#delay 100}}";
313
- const start = Date.now();
314
- await langJson.applyTemplate(template, {});
315
- const end = Date.now();
316
- expect(end - start).toBeGreaterThanOrEqual(100);
317
- });
318
-
319
- // Additional Helpers
320
- test("camelToSnake", () => {
321
- const template = "{{#camelToSnake 'camelCase'}}";
322
- const result = langJson.applyTemplate(template, {});
323
- expect(result).toBe("camel_case");
324
- });
325
-
326
- test("snakeToCamel", () => {
327
- const template = "{{#snakeToCamel 'snake_case'}}";
328
- const result = langJson.applyTemplate(template, {});
329
- expect(result).toBe("snakeCase");
330
- });
331
- });