diff --git a/README.md b/README.md index 372b7e5f..2f5fef6f 100644 --- a/README.md +++ b/README.md @@ -119,8 +119,6 @@ const configuration await expand("${include('" + '/path/to/the/config.json' + "' - [Parameters](#parameters-9) - [merge](#merge) - [Parameters](#parameters-10) -- [removeSensibleValues](#removesensiblevalues) - - [Parameters](#parameters-11) ## defaultConstants @@ -277,17 +275,6 @@ When a and b are arrays of values only the none duplaces are appendend to a Returns **any** merged b into a -## removeSensibleValues - -genereates a new object tree by removing sensible values like credentials from it - -### Parameters - -- `object` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** -- `toBeRemoved` (optional, default `key=>key.match(/pass|auth|key|user|secret/)`) - -Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** object tree free of sensible data - # install With [npm](http://npmjs.org) do: diff --git a/src/util.mjs b/src/util.mjs index a7b7d4f3..3bb66a48 100644 --- a/src/util.mjs +++ b/src/util.mjs @@ -20,7 +20,7 @@ export function merge(a, b) { if (Array.isArray(a)) { if (Array.isArray(b)) { - return [...a, ...a.filter(x => !b.find(e => equal(e, x)))]; + return [...a, ...b.filter(x => !a.find(e => equal(e, x)))]; } return [...a, b]; } diff --git a/tests/merge-test.mjs b/tests/merge-test.mjs index 45377206..4ff57912 100644 --- a/tests/merge-test.mjs +++ b/tests/merge-test.mjs @@ -23,6 +23,32 @@ test("merge complex array", async t => [{ a: 1 }, { b: 2 }] )); +test("merge complex array 2", async t => + t.deepEqual( + await expand([ + { + "type": "github-repository-provider" + }, + { + "type": "gitea-repository-provider" + } + ], { + default: [ + { + "type": "github-repository-provider" + } + ] + }), + [ + { + "type": "github-repository-provider" + }, + { + "type": "gitea-repository-provider" + } + ] + )); + test("merge array", async t => t.deepEqual( await expand( @@ -51,9 +77,9 @@ test("merge array", async t => )); -test("eq1",t =>{ - t.true(equal(1,1)); - t.true(equal([1],[1])); - t.true(equal([{a:1}],[{a:1}])); - t.false(equal([{a:1}],[{b:1}])); +test("eq1", t => { + t.true(equal(1, 1)); + t.true(equal([1], [1])); + t.true(equal([{ a: 1 }], [{ a: 1 }])); + t.false(equal([{ a: 1 }], [{ b: 1 }])); });