-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e1bc61a
commit 2ea7424
Showing
21 changed files
with
785 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@opentf/utils": minor | ||
--- | ||
|
||
Added merge utils fns & renamed arrayDiff to arrDiff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Callout } from "nextra/components"; | ||
import REPL from "../../components/REPL"; | ||
|
||
> It deeply merges objects or arrays. | ||
## Syntax | ||
|
||
```ts | ||
import { merge } from '@opentf/utils'; | ||
|
||
merge(obj1, ...objN); | ||
``` | ||
|
||
<Callout type="info" emoji="✅"> | ||
Immutable: This does not mutate the given arrays or objects. | ||
</Callout> | ||
|
||
## Examples | ||
|
||
```ts | ||
const a = { a: { b: 1 }, d: 3 }; | ||
const b = { a: { c: 2 }, e: 5 }; | ||
merge(a, b); //=> { a: { b: 1, c: 2 }, d: 3, e: 5 } | ||
|
||
const a = { a: [1, 2] }; | ||
const b = { a: [3, 4, 5] }; | ||
const c = { a: [7, 8] }; | ||
merge(a, b, c); //=> { a: [7, 8, 5] } | ||
``` | ||
|
||
## Try | ||
|
||
<REPL code={`const { merge } = require('@opentf/utils'); | ||
const a = { a: { b: 1 }, d: 3 }; | ||
const b = { a: { c: 2 }, e: 5 }; | ||
merge(a, b); | ||
`} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Callout } from "nextra/components"; | ||
import REPL from "../../components/REPL"; | ||
|
||
> It deeply merges objects and concatenates the arrays if any present. | ||
## Syntax | ||
|
||
```ts | ||
import { mergeAll } from '@opentf/utils'; | ||
|
||
mergeAll(obj1, ...objN); | ||
``` | ||
|
||
<Callout type="info" emoji="✅"> | ||
Immutable: This does not mutate the given arrays or objects. | ||
</Callout> | ||
|
||
## Examples | ||
|
||
```ts | ||
const a = { a: { b: [1] } }; | ||
const b = { a: { b: [2] } }; | ||
mergeAll(a, b); //=> { a: { b: [1, 2] } | ||
``` | ||
|
||
## Try | ||
|
||
<REPL code={`const { mergeAll } = require('@opentf/utils'); | ||
const a = { a: { b: [1] } }; | ||
const b = { a: { b: [2] } }; | ||
mergeAll(a, b); | ||
`} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { Callout } from "nextra/components"; | ||
import REPL from "../../components/REPL"; | ||
|
||
> Shallow Merges objects or arrays. | ||
## Syntax | ||
|
||
```ts | ||
import { shallowMerge } from '@opentf/utils'; | ||
|
||
shallowMerge(obj1, ...objN); | ||
``` | ||
|
||
<Callout type="info" emoji="✅"> | ||
Immutable: This does not mutate the given arrays or objects. | ||
</Callout> | ||
|
||
## Examples | ||
|
||
```ts | ||
const a = { a: 1 }; | ||
const b = { b: 2 }; | ||
shallowMerge(a, b); //=> { a: 1, b: 2 } | ||
|
||
const a = [1]; | ||
const b = [2]; | ||
const c = [3]; | ||
shallowMerge(a, b, c); //=> [3] | ||
``` | ||
|
||
## Try | ||
|
||
<REPL code={`const { shallowMerge } = require('@opentf/utils'); | ||
const a = { a: 1 }; | ||
const b = { b: 2 }; | ||
shallowMerge(a, b); | ||
`} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { Callout } from "nextra/components"; | ||
import REPL from "../../components/REPL"; | ||
|
||
> Shallow merges objects and concatenates the array. | ||
## Syntax | ||
|
||
```ts | ||
import { shallowMergeAll } from '@opentf/utils'; | ||
|
||
shallowMergeAll(obj1, ...objN); | ||
``` | ||
|
||
<Callout type="info" emoji="✅"> | ||
Immutable: This does not mutate the given arrays or objects. | ||
</Callout> | ||
|
||
## Examples | ||
|
||
```ts | ||
const a = [1]; | ||
const b = [2]; | ||
const c = [3]; | ||
shallowMergeAll(a, b, c); //=> [1, 2, 3] | ||
``` | ||
|
||
## Try | ||
|
||
<REPL code={`const { shallowMergeAll } = require('@opentf/utils'); | ||
const a = [1]; | ||
const b = [2]; | ||
const c = [3]; | ||
shallowMergeAll(a, b, c); | ||
`} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.