@questwork/q-utilities 0.1.11 → 0.1.12
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/dist/index.min.cjs +22 -19
- package/dist/index.min.js +22 -19
- package/dist/q-utilities.min.js +2413 -0
- package/package.json +1 -1
package/dist/index.min.cjs
CHANGED
|
@@ -62,7 +62,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
62
62
|
formatDate: () => (/* reexport */ formatDate),
|
|
63
63
|
generalPost: () => (/* reexport */ generalPost),
|
|
64
64
|
getValidation: () => (/* reexport */ getValidation),
|
|
65
|
-
getValueByKeys: () => (/* reexport */
|
|
65
|
+
getValueByKeys: () => (/* reexport */ getValueByKeys_getValueByKeys),
|
|
66
66
|
makeApiResponse: () => (/* reexport */ makeApiResponse),
|
|
67
67
|
makeService: () => (/* reexport */ makeService),
|
|
68
68
|
objectHelper: () => (/* reexport */ objectHelper),
|
|
@@ -260,7 +260,7 @@ function padding(m) {
|
|
|
260
260
|
|
|
261
261
|
;// ./lib/helpers/getValueByKeys/getValueByKeys.js
|
|
262
262
|
// keys can be array or object or string
|
|
263
|
-
function
|
|
263
|
+
function getValueByKeys_getValueByKeys(keys, data) {
|
|
264
264
|
let _keys = keys
|
|
265
265
|
let _data = data
|
|
266
266
|
if (typeof keys === 'string') {
|
|
@@ -276,7 +276,7 @@ function getValueByKeys(keys, data) {
|
|
|
276
276
|
}
|
|
277
277
|
const firstKey = _keys.shift()
|
|
278
278
|
if (_data && Object.prototype.hasOwnProperty.call(_data, firstKey)) {
|
|
279
|
-
return
|
|
279
|
+
return getValueByKeys_getValueByKeys(_keys, _data[firstKey])
|
|
280
280
|
}
|
|
281
281
|
if (_data && firstKey) {
|
|
282
282
|
return _data[firstKey]
|
|
@@ -284,8 +284,8 @@ function getValueByKeys(keys, data) {
|
|
|
284
284
|
return _data
|
|
285
285
|
|
|
286
286
|
}
|
|
287
|
-
/* harmony default export */ const
|
|
288
|
-
getValueByKeys
|
|
287
|
+
/* harmony default export */ const getValueByKeys = ({
|
|
288
|
+
getValueByKeys: getValueByKeys_getValueByKeys
|
|
289
289
|
});
|
|
290
290
|
|
|
291
291
|
|
|
@@ -429,7 +429,7 @@ function _existObject(data, args) {
|
|
|
429
429
|
const arg = args[0]
|
|
430
430
|
return data.filter((e) => {
|
|
431
431
|
if (arg.includes('.')) {
|
|
432
|
-
return
|
|
432
|
+
return getValueByKeys_getValueByKeys(arg.split('.'), e)
|
|
433
433
|
}
|
|
434
434
|
return Object.prototype.hasOwnProperty.call(e, arg)
|
|
435
435
|
})
|
|
@@ -447,7 +447,7 @@ function _existObject(data, args) {
|
|
|
447
447
|
const [key, ..._argsArr] = args
|
|
448
448
|
const _args = _argsArr.flat()
|
|
449
449
|
return data.filter((e) => {
|
|
450
|
-
const value = key.includes('.') ?
|
|
450
|
+
const value = key.includes('.') ? getValueByKeys_getValueByKeys(key.split('.'), e) : e[key]
|
|
451
451
|
return _args.some((arg) => _performOperation(arg, value))
|
|
452
452
|
})
|
|
453
453
|
}
|
|
@@ -1219,21 +1219,21 @@ function concatStringByArray(arrTemplate, data) {
|
|
|
1219
1219
|
const { type, value = '', restriction, template, format, showMinutes } = item
|
|
1220
1220
|
switch (type) {
|
|
1221
1221
|
case('label'): {
|
|
1222
|
-
if (getValidation(restriction, data,
|
|
1222
|
+
if (getValidation(restriction, data, getValueByKeys_getValueByKeys)) {
|
|
1223
1223
|
acc += (value.toString())
|
|
1224
1224
|
}
|
|
1225
1225
|
break
|
|
1226
1226
|
}
|
|
1227
1227
|
case('value'): {
|
|
1228
|
-
if (getValidation(restriction, data,
|
|
1229
|
-
const _value =
|
|
1228
|
+
if (getValidation(restriction, data, getValueByKeys_getValueByKeys)) {
|
|
1229
|
+
const _value = getValueByKeys_getValueByKeys(value.split('.'), data) || ''
|
|
1230
1230
|
acc += (_value.toString())
|
|
1231
1231
|
}
|
|
1232
1232
|
break
|
|
1233
1233
|
}
|
|
1234
1234
|
case('array'): {
|
|
1235
|
-
if (getValidation(restriction, data,
|
|
1236
|
-
const _value =
|
|
1235
|
+
if (getValidation(restriction, data, getValueByKeys_getValueByKeys)) {
|
|
1236
|
+
const _value = getValueByKeys_getValueByKeys(value.split('.'), data) || []
|
|
1237
1237
|
acc += _value.reduce((_acc, item) => {
|
|
1238
1238
|
return _acc += concatStringByArray(template, item)
|
|
1239
1239
|
}, '')
|
|
@@ -1241,9 +1241,9 @@ function concatStringByArray(arrTemplate, data) {
|
|
|
1241
1241
|
break
|
|
1242
1242
|
}
|
|
1243
1243
|
case('ellipsis'): {
|
|
1244
|
-
if (getValidation(restriction, data,
|
|
1244
|
+
if (getValidation(restriction, data, getValueByKeys_getValueByKeys)) {
|
|
1245
1245
|
const { maxLength } = item
|
|
1246
|
-
const _value =
|
|
1246
|
+
const _value = getValueByKeys_getValueByKeys(value.split('.'), data) || ''
|
|
1247
1247
|
if (_value.length <= maxLength) {
|
|
1248
1248
|
acc += (_value.toString())
|
|
1249
1249
|
} else {
|
|
@@ -1253,14 +1253,14 @@ function concatStringByArray(arrTemplate, data) {
|
|
|
1253
1253
|
break
|
|
1254
1254
|
}
|
|
1255
1255
|
case ('date'): {
|
|
1256
|
-
if (getValidation(restriction, data,
|
|
1257
|
-
const _value =
|
|
1256
|
+
if (getValidation(restriction, data, getValueByKeys_getValueByKeys)) {
|
|
1257
|
+
const _value = getValueByKeys_getValueByKeys(value.split('.'), data) || ''
|
|
1258
1258
|
acc += (formatDate(_value, format).toString())
|
|
1259
1259
|
}
|
|
1260
1260
|
break
|
|
1261
1261
|
}
|
|
1262
1262
|
case ('templateCompiler'): {
|
|
1263
|
-
if (getValidation(restriction, data,
|
|
1263
|
+
if (getValidation(restriction, data, getValueByKeys_getValueByKeys)) {
|
|
1264
1264
|
const templateCompiler = new TemplateCompiler({ data })
|
|
1265
1265
|
acc += templateCompiler.pipe(value)
|
|
1266
1266
|
}
|
|
@@ -1280,13 +1280,16 @@ function concatStringByArray(arrTemplate, data) {
|
|
|
1280
1280
|
|
|
1281
1281
|
|
|
1282
1282
|
;// ./lib/helpers/convertString/convertString.js
|
|
1283
|
+
|
|
1284
|
+
|
|
1283
1285
|
function convertString(string, patternMatch = /\$\{(.+?)\}/g, value, getValueByKeys) {
|
|
1284
|
-
if (!string
|
|
1286
|
+
if (!string) {
|
|
1285
1287
|
return ''
|
|
1286
1288
|
}
|
|
1289
|
+
let _getValueByKeys = typeof getValueByKeys !== 'function' ? getValueByKeys : getValueByKeys_getValueByKeys
|
|
1287
1290
|
const reg = new RegExp(patternMatch, 'g')
|
|
1288
1291
|
return string.replace(reg, (match, key) => {
|
|
1289
|
-
const result =
|
|
1292
|
+
const result = _getValueByKeys({ keys: key.split('.'), obj: value })
|
|
1290
1293
|
if (result === null || result === undefined) {
|
|
1291
1294
|
return ''
|
|
1292
1295
|
}
|
package/dist/index.min.js
CHANGED
|
@@ -37,7 +37,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
37
37
|
Yq: () => (/* reexport */ formatDate),
|
|
38
38
|
zn: () => (/* reexport */ generalPost),
|
|
39
39
|
G8: () => (/* reexport */ getValidation),
|
|
40
|
-
pY: () => (/* reexport */
|
|
40
|
+
pY: () => (/* reexport */ getValueByKeys_getValueByKeys),
|
|
41
41
|
su: () => (/* reexport */ makeApiResponse),
|
|
42
42
|
Q6: () => (/* reexport */ makeService),
|
|
43
43
|
UI: () => (/* reexport */ objectHelper),
|
|
@@ -235,7 +235,7 @@ function padding(m) {
|
|
|
235
235
|
|
|
236
236
|
;// ./lib/helpers/getValueByKeys/getValueByKeys.js
|
|
237
237
|
// keys can be array or object or string
|
|
238
|
-
function
|
|
238
|
+
function getValueByKeys_getValueByKeys(keys, data) {
|
|
239
239
|
let _keys = keys
|
|
240
240
|
let _data = data
|
|
241
241
|
if (typeof keys === 'string') {
|
|
@@ -251,7 +251,7 @@ function getValueByKeys(keys, data) {
|
|
|
251
251
|
}
|
|
252
252
|
const firstKey = _keys.shift()
|
|
253
253
|
if (_data && Object.prototype.hasOwnProperty.call(_data, firstKey)) {
|
|
254
|
-
return
|
|
254
|
+
return getValueByKeys_getValueByKeys(_keys, _data[firstKey])
|
|
255
255
|
}
|
|
256
256
|
if (_data && firstKey) {
|
|
257
257
|
return _data[firstKey]
|
|
@@ -259,8 +259,8 @@ function getValueByKeys(keys, data) {
|
|
|
259
259
|
return _data
|
|
260
260
|
|
|
261
261
|
}
|
|
262
|
-
/* harmony default export */ const
|
|
263
|
-
getValueByKeys
|
|
262
|
+
/* harmony default export */ const getValueByKeys = ({
|
|
263
|
+
getValueByKeys: getValueByKeys_getValueByKeys
|
|
264
264
|
});
|
|
265
265
|
|
|
266
266
|
|
|
@@ -404,7 +404,7 @@ function _existObject(data, args) {
|
|
|
404
404
|
const arg = args[0]
|
|
405
405
|
return data.filter((e) => {
|
|
406
406
|
if (arg.includes('.')) {
|
|
407
|
-
return
|
|
407
|
+
return getValueByKeys_getValueByKeys(arg.split('.'), e)
|
|
408
408
|
}
|
|
409
409
|
return Object.prototype.hasOwnProperty.call(e, arg)
|
|
410
410
|
})
|
|
@@ -422,7 +422,7 @@ function _existObject(data, args) {
|
|
|
422
422
|
const [key, ..._argsArr] = args
|
|
423
423
|
const _args = _argsArr.flat()
|
|
424
424
|
return data.filter((e) => {
|
|
425
|
-
const value = key.includes('.') ?
|
|
425
|
+
const value = key.includes('.') ? getValueByKeys_getValueByKeys(key.split('.'), e) : e[key]
|
|
426
426
|
return _args.some((arg) => _performOperation(arg, value))
|
|
427
427
|
})
|
|
428
428
|
}
|
|
@@ -1194,21 +1194,21 @@ function concatStringByArray(arrTemplate, data) {
|
|
|
1194
1194
|
const { type, value = '', restriction, template, format, showMinutes } = item
|
|
1195
1195
|
switch (type) {
|
|
1196
1196
|
case('label'): {
|
|
1197
|
-
if (getValidation(restriction, data,
|
|
1197
|
+
if (getValidation(restriction, data, getValueByKeys_getValueByKeys)) {
|
|
1198
1198
|
acc += (value.toString())
|
|
1199
1199
|
}
|
|
1200
1200
|
break
|
|
1201
1201
|
}
|
|
1202
1202
|
case('value'): {
|
|
1203
|
-
if (getValidation(restriction, data,
|
|
1204
|
-
const _value =
|
|
1203
|
+
if (getValidation(restriction, data, getValueByKeys_getValueByKeys)) {
|
|
1204
|
+
const _value = getValueByKeys_getValueByKeys(value.split('.'), data) || ''
|
|
1205
1205
|
acc += (_value.toString())
|
|
1206
1206
|
}
|
|
1207
1207
|
break
|
|
1208
1208
|
}
|
|
1209
1209
|
case('array'): {
|
|
1210
|
-
if (getValidation(restriction, data,
|
|
1211
|
-
const _value =
|
|
1210
|
+
if (getValidation(restriction, data, getValueByKeys_getValueByKeys)) {
|
|
1211
|
+
const _value = getValueByKeys_getValueByKeys(value.split('.'), data) || []
|
|
1212
1212
|
acc += _value.reduce((_acc, item) => {
|
|
1213
1213
|
return _acc += concatStringByArray(template, item)
|
|
1214
1214
|
}, '')
|
|
@@ -1216,9 +1216,9 @@ function concatStringByArray(arrTemplate, data) {
|
|
|
1216
1216
|
break
|
|
1217
1217
|
}
|
|
1218
1218
|
case('ellipsis'): {
|
|
1219
|
-
if (getValidation(restriction, data,
|
|
1219
|
+
if (getValidation(restriction, data, getValueByKeys_getValueByKeys)) {
|
|
1220
1220
|
const { maxLength } = item
|
|
1221
|
-
const _value =
|
|
1221
|
+
const _value = getValueByKeys_getValueByKeys(value.split('.'), data) || ''
|
|
1222
1222
|
if (_value.length <= maxLength) {
|
|
1223
1223
|
acc += (_value.toString())
|
|
1224
1224
|
} else {
|
|
@@ -1228,14 +1228,14 @@ function concatStringByArray(arrTemplate, data) {
|
|
|
1228
1228
|
break
|
|
1229
1229
|
}
|
|
1230
1230
|
case ('date'): {
|
|
1231
|
-
if (getValidation(restriction, data,
|
|
1232
|
-
const _value =
|
|
1231
|
+
if (getValidation(restriction, data, getValueByKeys_getValueByKeys)) {
|
|
1232
|
+
const _value = getValueByKeys_getValueByKeys(value.split('.'), data) || ''
|
|
1233
1233
|
acc += (formatDate(_value, format).toString())
|
|
1234
1234
|
}
|
|
1235
1235
|
break
|
|
1236
1236
|
}
|
|
1237
1237
|
case ('templateCompiler'): {
|
|
1238
|
-
if (getValidation(restriction, data,
|
|
1238
|
+
if (getValidation(restriction, data, getValueByKeys_getValueByKeys)) {
|
|
1239
1239
|
const templateCompiler = new TemplateCompiler({ data })
|
|
1240
1240
|
acc += templateCompiler.pipe(value)
|
|
1241
1241
|
}
|
|
@@ -1255,13 +1255,16 @@ function concatStringByArray(arrTemplate, data) {
|
|
|
1255
1255
|
|
|
1256
1256
|
|
|
1257
1257
|
;// ./lib/helpers/convertString/convertString.js
|
|
1258
|
+
|
|
1259
|
+
|
|
1258
1260
|
function convertString(string, patternMatch = /\$\{(.+?)\}/g, value, getValueByKeys) {
|
|
1259
|
-
if (!string
|
|
1261
|
+
if (!string) {
|
|
1260
1262
|
return ''
|
|
1261
1263
|
}
|
|
1264
|
+
let _getValueByKeys = typeof getValueByKeys !== 'function' ? getValueByKeys : getValueByKeys_getValueByKeys
|
|
1262
1265
|
const reg = new RegExp(patternMatch, 'g')
|
|
1263
1266
|
return string.replace(reg, (match, key) => {
|
|
1264
|
-
const result =
|
|
1267
|
+
const result = _getValueByKeys({ keys: key.split('.'), obj: value })
|
|
1265
1268
|
if (result === null || result === undefined) {
|
|
1266
1269
|
return ''
|
|
1267
1270
|
}
|