aneka 0.7.3 → 0.7.4

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/CHANGES.md CHANGED
@@ -13,6 +13,7 @@
13
13
  - [0.7.1] Bug fix in ```parseObject()```
14
14
  - [0.7.2] Bug fix in ```parseArgsArgv()```
15
15
  - [0.7.3] Rewrite options in ```parseObject()```
16
+ - [0.7.4] Bug fix in ```parseObject()```
16
17
 
17
18
  ## 2025-12-11
18
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aneka",
3
- "version": "0.7.3",
3
+ "version": "0.7.4",
4
4
  "description": "Some usefull function helper for daily use",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -20,6 +20,7 @@ import { set, isString, cloneDeep, isPlainObject, isArray, omit } from 'lodash-e
20
20
  */
21
21
  function parseObject (input, options = {}) {
22
22
  const { silent = true, parseValue = false, translator = {} } = options
23
+ const { prefix, lang, handler } = translator
23
24
  const statics = ['*']
24
25
  if (isString(input)) {
25
26
  try {
@@ -43,12 +44,12 @@ function parseObject (input, options = {}) {
43
44
  if (isArray(obj[k][idx])) obj[k][idx] = obj[k][idx].map(item => typeof item === 'string' ? item.trim() : item)
44
45
  })
45
46
  } else if (isSet(v)) {
46
- if (isString(v) && translator.handler && translator.matcher && translator.matcher(v)) v = translator.handler(v.slice(2))
47
+ if (isString(v) && prefix && lang && handler && v.startsWith(prefix)) v = handler(v.slice(prefix.length))
47
48
  try {
48
49
  if (statics.includes(v)) obj[k] = v
49
- else if (isString(v)) {
50
- const newK = k.slice(2)
51
- if (translator.handler && translator.matcher && translator.matcher(k)) obj[newK] = translator.handler(v)
50
+ else if (isString(v) && prefix && handler && k.startsWith(prefix)) {
51
+ const newK = k.slice(prefix.length)
52
+ if (lang) obj[newK] = handler(v)
52
53
  else obj[newK] = v
53
54
  mutated.push(k)
54
55
  } else if (parseValue) {
@@ -0,0 +1,10 @@
1
+ import { expect } from 'chai'
2
+ import fn from '../src/parse-object.js'
3
+
4
+ describe('parseObjecy', function () {
5
+ it('Should return the expected result', function () {
6
+ const items = { _: { log: { pretty: true, level: 'trace' }, lang: 'id' } }
7
+ const result = fn(items, { parseValue: true })
8
+ expect(result).to.eql(items)
9
+ })
10
+ })