Skip to content

type "array" with "duplicate-arguments-array" works inconsistently #162

@juergba

Description

@juergba

array of type number is not affected by duplicate-arguments-array and doesn't reduce duplicated arguments:

var args = parse(
    ['--file', '2', '--file', '6', '--timeout', '2s', '--timeout', '800'], {
        array: [{key: 'file', number: true}],
        string: ['timeout'],
        configuration: {
            'duplicate-arguments-array': false
        }
});
console.log(args);         // { _: [], file: [ 2, 6 ], timeout: '800' }

array of type string does reduce duplicated arguments with duplicate-arguments-array:

var args = parse(
    ['--file', '2', '--file', '6', '--timeout', '2s', '--timeout', '800'], {
        array: [{key: 'file', string: true}],
        string: ['timeout'],
        configuration: {
            'duplicate-arguments-array': false
        }
});
console.log(args);         // { _: [], file: [ '6' ], timeout: '800' }

An array of type boolean is always reduced, indepently of duplicate-arguments-array. So it doesn't seem possible to build an array of boolean with more than one element.

It is not clear:

  • wether duplicate-arguments-array should reduce array's at all. Analysing the tests, the answer is yes. Maybe it would be more logical to exclude array's from this rule?
  • the behavior of typed array's is not consistent (number <=> string).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions