caseparser 1.1.0 → 2.0.1

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.
@@ -1,365 +0,0 @@
1
- 'use strict';
2
-
3
- const caseparser = require('./lib/caseparser');
4
-
5
- const upperSnakeToCamel = {
6
- string: function () {
7
- const data = 'FIRST_NAME_IS_BEFORE_LAST_NAME';
8
- const expected = 'firstNameIsBeforeLastName';
9
- const result = caseparser.upperSnakeToCamel(data);
10
- const isFailed = result !== expected;
11
- console.log(' upperSnakeToCamel', isFailed ? '✗' : '✓');
12
- if (isFailed) {
13
- console.error(' expected: ', JSON.stringify(expected, null, 2));
14
- console.error(' received: ', JSON.stringify(result, null, 2));
15
- }
16
- },
17
- json: function () {
18
- const data = {
19
- "ID": 1,
20
- "IS_UNDER_AGE": false,
21
- "FIRST_NAME": "Timothee",
22
- "LAST_NAME": "Clausner",
23
- "EMAIL": "tclausner0@economist.com",
24
- "TELEPHONE_NUMBERS": [
25
- "(9999) 99999-9999",
26
- "(8888) 88888-8888"
27
- ],
28
- "ADDRESSES": [
29
- {
30
- "COUNTRY": "United_States",
31
- "STATE": "Illinois",
32
- "CITY": "Rockford",
33
- "POSTAL_CODE": "61105",
34
- "STREET": {
35
- "STREET_NAME": "41 Forest Run Circle",
36
- "STREET_NUMBER": "539"
37
- }
38
- }
39
- ]
40
- };
41
- const expected = {
42
- "id": 1,
43
- "isUnderAge": false,
44
- "firstName": "Timothee",
45
- "lastName": "Clausner",
46
- "email": "tclausner0@economist.com",
47
- "telephoneNumbers": [
48
- "(9999) 99999-9999",
49
- "(8888) 88888-8888"
50
- ],
51
- "addresses": [
52
- {
53
- "country": "United_States",
54
- "state": "Illinois",
55
- "city": "Rockford",
56
- "postalCode": "61105",
57
- "street": {
58
- "streetName": "41 Forest Run Circle",
59
- "streetNumber": "539"
60
- }
61
- }
62
- ]
63
- };
64
- const result = caseparser.upperSnakeToCamel(data);
65
- const isFailed = JSON.stringify(result) !== JSON.stringify(expected);
66
- console.log(' upperSnakeToCamel', isFailed ? '✗' : '✓');
67
- if (isFailed) {
68
- console.error(' expected: ', JSON.stringify(expected, null, 2));
69
- console.error(' received: ', JSON.stringify(result, null, 2));
70
- }
71
- }
72
- };
73
-
74
- const upperSnakeToSnake = {
75
- string: function () {
76
- const data = 'FIRST_NAME_IS_BEFORE_LAST_NAME';
77
- const expected = 'first_name_is_before_last_name';
78
- const result = caseparser.upperSnakeToSnake(data);
79
- const isFailed = result !== expected;
80
- console.log(' upperSnakeToSnake', isFailed ? '✗' : '✓');
81
- if (isFailed) {
82
- console.error(' expected: ', JSON.stringify(expected, null, 2));
83
- console.error(' received: ', JSON.stringify(result, null, 2));
84
- }
85
- },
86
- json: function () {
87
- const data = {
88
- "ID": 1,
89
- "IS_UNDER_AGE": false,
90
- "FIRST_NAME": "Timothee",
91
- "LAST_NAME": "Clausner",
92
- "EMAIL": "tclausner0@economist.com",
93
- "TELEPHONE_NUMBERS": [
94
- "(9999) 99999-9999",
95
- "(8888) 88888-8888"
96
- ],
97
- "ADDRESSES": [
98
- {
99
- "COUNTRY": "United_States",
100
- "STATE": "Illinois",
101
- "CITY": "Rockford",
102
- "POSTAL_CODE": "61105",
103
- "STREET": {
104
- "STREET_NAME": "41 Forest Run Circle",
105
- "STREET_NUMBER": "539"
106
- }
107
- }
108
- ]
109
- };
110
- const expected = {
111
- "id": 1,
112
- "is_under_age": false,
113
- "first_name": "Timothee",
114
- "last_name": "Clausner",
115
- "email": "tclausner0@economist.com",
116
- "telephone_numbers": [
117
- "(9999) 99999-9999",
118
- "(8888) 88888-8888"
119
- ],
120
- "addresses": [
121
- {
122
- "country": "United_States",
123
- "state": "Illinois",
124
- "city": "Rockford",
125
- "postal_code": "61105",
126
- "street": {
127
- "street_name": "41 Forest Run Circle",
128
- "street_number": "539"
129
- }
130
- }
131
- ]
132
- };
133
- const result = caseparser.upperSnakeToSnake(data);
134
- const isFailed = JSON.stringify(result) !== JSON.stringify(expected);
135
- console.log(' upperSnakeToSnake', isFailed ? '✗' : '✓');
136
- if (isFailed) {
137
- console.error(' expected: ', JSON.stringify(expected, null, 2));
138
- console.error(' received: ', JSON.stringify(result, null, 2));
139
- }
140
- }
141
- };
142
-
143
- const upperSnakeToDash = {
144
- string: function () {
145
- const data = 'FIRST_NAME_IS_BEFORE_LAST_NAME';
146
- const expected = 'first-name-is-before-last-name';
147
- const result = caseparser.upperSnakeToDash(data);
148
- const isFailed = result !== expected;
149
- console.log(' upperSnakeToDash', isFailed ? '✗' : '✓');
150
- if (isFailed) {
151
- console.error(' expected: ', JSON.stringify(expected, null, 2));
152
- console.error(' received: ', JSON.stringify(result, null, 2));
153
- }
154
- },
155
- json: function () {
156
- const data = {
157
- "ID": 1,
158
- "IS_UNDER_AGE": false,
159
- "FIRST_NAME": "Timothee",
160
- "LAST_NAME": "Clausner",
161
- "EMAIL": "tclausner0@economist.com",
162
- "TELEPHONE_NUMBERS": [
163
- "(9999) 99999-9999",
164
- "(8888) 88888-8888"
165
- ],
166
- "ADDRESSES": [
167
- {
168
- "COUNTRY": "United_States",
169
- "STATE": "Illinois",
170
- "CITY": "Rockford",
171
- "POSTAL_CODE": "61105",
172
- "STREET": {
173
- "STREET_NAME": "41 Forest Run Circle",
174
- "STREET_NUMBER": "539"
175
- }
176
- }
177
- ]
178
- };
179
- const expected = {
180
- "id": 1,
181
- "is-under-age": false,
182
- "first-name": "Timothee",
183
- "last-name": "Clausner",
184
- "email": "tclausner0@economist.com",
185
- "telephone-numbers": [
186
- "(9999) 99999-9999",
187
- "(8888) 88888-8888"
188
- ],
189
- "addresses": [
190
- {
191
- "country": "United_States",
192
- "state": "Illinois",
193
- "city": "Rockford",
194
- "postal-code": "61105",
195
- "street": {
196
- "street-name": "41 Forest Run Circle",
197
- "street-number": "539"
198
- }
199
- }
200
- ]
201
- };
202
- const result = caseparser.upperSnakeToDash(data);
203
- const isFailed = JSON.stringify(result) !== JSON.stringify(expected);
204
- console.log(' upperSnakeToDash', isFailed ? '✗' : '✓');
205
- if (isFailed) {
206
- console.error(' expected: ', JSON.stringify(expected, null, 2));
207
- console.error(' received: ', JSON.stringify(result, null, 2));
208
- }
209
- }
210
- };
211
-
212
- const upperSnakeToPascal = {
213
- string: function () {
214
- const data = 'FIRST_NAME_IS_BEFORE_LAST_NAME';
215
- const expected = 'FirstNameIsBeforeLastName';
216
- const result = caseparser.upperSnakeToPascal(data);
217
- const isFailed = result !== expected;
218
- console.log(' upperSnakeToPascal', isFailed ? '✗' : '✓');
219
- if (isFailed) {
220
- console.error(' expected: ', JSON.stringify(expected, null, 2));
221
- console.error(' received: ', JSON.stringify(result, null, 2));
222
- }
223
- },
224
- json: function () {
225
- const data = {
226
- "ID": 1,
227
- "IS_UNDER_AGE": false,
228
- "FIRST_NAME": "Timothee",
229
- "LAST_NAME": "Clausner",
230
- "EMAIL": "tclausner0@economist.com",
231
- "TELEPHONE_NUMBERS": [
232
- "(9999) 99999-9999",
233
- "(8888) 88888-8888"
234
- ],
235
- "ADDRESSES": [
236
- {
237
- "COUNTRY": "United_States",
238
- "STATE": "Illinois",
239
- "CITY": "Rockford",
240
- "POSTAL_CODE": "61105",
241
- "STREET": {
242
- "STREET_NAME": "41 Forest Run Circle",
243
- "STREET_NUMBER": "539"
244
- }
245
- }
246
- ]
247
- };
248
- const expected = {
249
- "Id": 1,
250
- "IsUnderAge": false,
251
- "FirstName": "Timothee",
252
- "LastName": "Clausner",
253
- "Email": "tclausner0@economist.com",
254
- "TelephoneNumbers": [
255
- "(9999) 99999-9999",
256
- "(8888) 88888-8888"
257
- ],
258
- "Addresses": [
259
- {
260
- "Country": "United_States",
261
- "State": "Illinois",
262
- "City": "Rockford",
263
- "PostalCode": "61105",
264
- "Street": {
265
- "StreetName": "41 Forest Run Circle",
266
- "StreetNumber": "539"
267
- }
268
- }
269
- ]
270
- };
271
- const result = caseparser.upperSnakeToPascal(data);
272
- const isFailed = JSON.stringify(result) !== JSON.stringify(expected);
273
- console.log(' upperSnakeToPascal', isFailed ? '✗' : '✓');
274
- if (isFailed) {
275
- console.error(' expected: ', JSON.stringify(expected, null, 2));
276
- console.error(' received: ', JSON.stringify(result, null, 2));
277
- }
278
- }
279
- };
280
-
281
- const upperSnakeToUpperDash = {
282
- string: function () {
283
- const data = 'FIRST_NAME_IS_BEFORE_LAST_NAME';
284
- const expected = 'FIRST-NAME-IS-BEFORE-LAST-NAME';
285
- const result = caseparser.upperSnakeToUpperDash(data);
286
- const isFailed = result !== expected;
287
- console.log(' upperSnakeToUpperDash', isFailed ? '✗' : '✓');
288
- if (isFailed) {
289
- console.error(' expected: ', JSON.stringify(expected, null, 2));
290
- console.error(' received: ', JSON.stringify(result, null, 2));
291
- }
292
- },
293
- json: function () {
294
- const data = {
295
- "ID": 1,
296
- "IS_UNDER_AGE": false,
297
- "FIRST_NAME": "Timothee",
298
- "LAST_NAME": "Clausner",
299
- "EMAIL": "tclausner0@economist.com",
300
- "TELEPHONE_NUMBERS": [
301
- "(9999) 99999-9999",
302
- "(8888) 88888-8888"
303
- ],
304
- "ADDRESSES": [
305
- {
306
- "COUNTRY": "United_States",
307
- "STATE": "Illinois",
308
- "CITY": "Rockford",
309
- "POSTAL_CODE": "61105",
310
- "STREET": {
311
- "STREET_NAME": "41 Forest Run Circle",
312
- "STREET_NUMBER": "539"
313
- }
314
- }
315
- ]
316
- };
317
- const expected = {
318
- "ID": 1,
319
- "IS-UNDER-AGE": false,
320
- "FIRST-NAME": "Timothee",
321
- "LAST-NAME": "Clausner",
322
- "EMAIL": "tclausner0@economist.com",
323
- "TELEPHONE-NUMBERS": [
324
- "(9999) 99999-9999",
325
- "(8888) 88888-8888"
326
- ],
327
- "ADDRESSES": [
328
- {
329
- "COUNTRY": "United_States",
330
- "STATE": "Illinois",
331
- "CITY": "Rockford",
332
- "POSTAL-CODE": "61105",
333
- "STREET": {
334
- "STREET-NAME": "41 Forest Run Circle",
335
- "STREET-NUMBER": "539"
336
- }
337
- }
338
- ]
339
- };
340
- const result = caseparser.upperSnakeToUpperDash(data);
341
- const isFailed = JSON.stringify(result) !== JSON.stringify(expected);
342
- console.log(' upperSnakeToUpperDash', isFailed ? '✗' : '✓');
343
- if (isFailed) {
344
- console.error(' expected: ', JSON.stringify(expected, null, 2));
345
- console.error(' received: ', JSON.stringify(result, null, 2));
346
- }
347
- }
348
- };
349
-
350
- const testUpperSnakeCaseSuite = function () {
351
- console.log(' String:');
352
- upperSnakeToCamel.string();
353
- upperSnakeToSnake.string();
354
- upperSnakeToDash.string();
355
- upperSnakeToPascal.string();
356
- upperSnakeToUpperDash.string();
357
- console.log(' JSON:');
358
- upperSnakeToCamel.json();
359
- upperSnakeToSnake.json();
360
- upperSnakeToDash.json();
361
- upperSnakeToPascal.json();
362
- upperSnakeToUpperDash.json();
363
- };
364
-
365
- module.exports = { testUpperSnakeCaseSuite };
package/test.js DELETED
@@ -1,31 +0,0 @@
1
- const CamelCaseSuite = require('./test-camel-case');
2
- const DashCaseSuite = require('./test-dash-case');
3
- const PascalCaseSuite = require('./test-pascal-case');
4
- const SnakeCaseSuite = require('./test-snake-case');
5
- const UpperDashCaseSuite = require('./test-upper-dash-case');
6
- const UpperSnakeCaseSuite = require('./test-upper-snake-case');
7
-
8
-
9
- console.log('---------------------------------');
10
- console.log('CamelCaseSuite:');
11
- CamelCaseSuite.testCamelCaseSuite();
12
-
13
- console.log('---------------------------------');
14
- console.log('SnakeCaseSuite:');
15
- SnakeCaseSuite.testSnakeCaseSuite();
16
-
17
- console.log('---------------------------------');
18
- console.log('DashCaseSuite:');
19
- DashCaseSuite.testDashCaseSuite();
20
-
21
- console.log('---------------------------------');
22
- console.log('PascalCaseSuite:');
23
- PascalCaseSuite.testPascalCaseSuite();
24
-
25
- console.log('---------------------------------');
26
- console.log('UpperSnakeCaseSuite:');
27
- UpperSnakeCaseSuite.testUpperSnakeCaseSuite();
28
-
29
- console.log('---------------------------------');
30
- console.log('UpperDashCaseSuite:');
31
- UpperDashCaseSuite.testUpperDashCaseSuite();