aneka 0.7.1 → 0.7.3

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
@@ -11,6 +11,8 @@
11
11
  - [0.6.0] Add ```parseDuration()```
12
12
  - [0.7.0] Add ```parseObject()```
13
13
  - [0.7.1] Bug fix in ```parseObject()```
14
+ - [0.7.2] Bug fix in ```parseArgsArgv()```
15
+ - [0.7.3] Rewrite options in ```parseObject()```
14
16
 
15
17
  ## 2025-12-11
16
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aneka",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "description": "Some usefull function helper for daily use",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -26,7 +26,7 @@ async function parseWithParser () {
26
26
  }
27
27
 
28
28
  async function parseWithYargs () {
29
- const pkgFile = `${process.cwd}/package.json`
29
+ const pkgFile = `${process.cwd()}/package.json`
30
30
  const pkg = JSON.parse(fs.readFileSync(pkgFile, 'utf8'))
31
31
  let name = `node ${pkg.main}`
32
32
  if (pkg.bin) name = path.basename(pkg.bin, '.js')
@@ -14,12 +14,12 @@ import { set, isString, cloneDeep, isPlainObject, isArray, omit } from 'lodash-e
14
14
  * @param {Object} [options={}] - Options
15
15
  * @param {boolean} [options.silent=true] - If ```true``` (default), exception are not thrown and silently ignored
16
16
  * @param {boolean} [options.parseValue=false] - If ```true```, values will be parsed & normalized
17
- * @param {function(string): string} [options.translator] - If provided, translate string value with this function
17
+ * @param {Object} [options.translator] - If provided, translate string value
18
18
  * @returns {Object}
19
19
  * @see {@link https://github.com/ladjs/dotenv-parse-variables}
20
20
  */
21
21
  function parseObject (input, options = {}) {
22
- const { silent = true, parseValue = false, translate } = options
22
+ const { silent = true, parseValue = false, translator = {} } = options
23
23
  const statics = ['*']
24
24
  if (isString(input)) {
25
25
  try {
@@ -43,12 +43,12 @@ function parseObject (input, options = {}) {
43
43
  if (isArray(obj[k][idx])) obj[k][idx] = obj[k][idx].map(item => typeof item === 'string' ? item.trim() : item)
44
44
  })
45
45
  } else if (isSet(v)) {
46
- if (isString(v) && translate) v = translate(v.slice(2))
46
+ if (isString(v) && translator.handler && translator.matcher && translator.matcher(v)) v = translator.handler(v.slice(2))
47
47
  try {
48
48
  if (statics.includes(v)) obj[k] = v
49
- else if (k.startsWith('t:') && isString(v)) {
49
+ else if (isString(v)) {
50
50
  const newK = k.slice(2)
51
- if (translate) obj[newK] = translate(v)
51
+ if (translator.handler && translator.matcher && translator.matcher(k)) obj[newK] = translator.handler(v)
52
52
  else obj[newK] = v
53
53
  mutated.push(k)
54
54
  } else if (parseValue) {