Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro-deck-encode
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
ygopro-deck-encode
Commits
570aaaa5
Commit
570aaaa5
authored
Jan 26, 2026
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use deep copy
parent
678460c5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
1 deletion
+76
-1
index.ts
index.ts
+4
-1
tests/deep-copy.spec.ts
tests/deep-copy.spec.ts
+72
-0
No files found.
index.ts
View file @
570aaaa5
...
@@ -23,7 +23,10 @@ export default class YGOProDeck implements YGOProDeckLike {
...
@@ -23,7 +23,10 @@ export default class YGOProDeck implements YGOProDeckLike {
name
?:
string
;
name
?:
string
;
constructor
(
init
:
Partial
<
YGOProDeckLike
>
=
{})
{
constructor
(
init
:
Partial
<
YGOProDeckLike
>
=
{})
{
Object
.
assign
(
this
,
init
);
this
.
main
=
init
.
main
?
[...
init
.
main
]
:
[];
this
.
extra
=
init
.
extra
?
[...
init
.
extra
]
:
[];
this
.
side
=
init
.
side
?
[...
init
.
side
]
:
[];
this
.
name
=
init
.
name
;
}
}
bufferLength
(
noCompact
=
false
)
{
bufferLength
(
noCompact
=
false
)
{
...
...
tests/deep-copy.spec.ts
0 → 100644
View file @
570aaaa5
import
YGOProDeck
from
'
..
'
;
describe
(
'
Constructor deep copy
'
,
()
=>
{
it
(
'
should deep copy main/extra/side arrays from plain object
'
,
()
=>
{
const
init
=
{
main
:
[
1
,
2
],
extra
:
[
3
],
side
:
[
4
,
5
],
};
const
deck
=
new
YGOProDeck
(
init
);
expect
(
deck
.
main
).
toStrictEqual
([
1
,
2
]);
expect
(
deck
.
extra
).
toStrictEqual
([
3
]);
expect
(
deck
.
side
).
toStrictEqual
([
4
,
5
]);
expect
(
deck
.
main
).
not
.
toBe
(
init
.
main
);
expect
(
deck
.
extra
).
not
.
toBe
(
init
.
extra
);
expect
(
deck
.
side
).
not
.
toBe
(
init
.
side
);
init
.
main
.
push
(
99
);
init
.
extra
.
push
(
88
);
init
.
side
.
push
(
77
);
expect
(
deck
.
main
).
toStrictEqual
([
1
,
2
]);
expect
(
deck
.
extra
).
toStrictEqual
([
3
]);
expect
(
deck
.
side
).
toStrictEqual
([
4
,
5
]);
deck
.
main
.
push
(
66
);
deck
.
extra
.
push
(
55
);
deck
.
side
.
push
(
44
);
expect
(
init
.
main
).
toStrictEqual
([
1
,
2
,
99
]);
expect
(
init
.
extra
).
toStrictEqual
([
3
,
88
]);
expect
(
init
.
side
).
toStrictEqual
([
4
,
5
,
77
]);
});
it
(
'
should deep copy main/extra/side arrays from another deck
'
,
()
=>
{
const
source
=
new
YGOProDeck
({
main
:
[
10
],
extra
:
[
20
,
21
],
side
:
[
30
],
name
:
'
source
'
,
});
const
deck
=
new
YGOProDeck
(
source
);
expect
(
deck
.
main
).
toStrictEqual
([
10
]);
expect
(
deck
.
extra
).
toStrictEqual
([
20
,
21
]);
expect
(
deck
.
side
).
toStrictEqual
([
30
]);
expect
(
deck
.
main
).
not
.
toBe
(
source
.
main
);
expect
(
deck
.
extra
).
not
.
toBe
(
source
.
extra
);
expect
(
deck
.
side
).
not
.
toBe
(
source
.
side
);
source
.
main
.
push
(
11
);
source
.
extra
.
push
(
22
);
source
.
side
.
push
(
31
);
expect
(
deck
.
main
).
toStrictEqual
([
10
]);
expect
(
deck
.
extra
).
toStrictEqual
([
20
,
21
]);
expect
(
deck
.
side
).
toStrictEqual
([
30
]);
deck
.
main
.
push
(
12
);
deck
.
extra
.
push
(
23
);
deck
.
side
.
push
(
32
);
expect
(
source
.
main
).
toStrictEqual
([
10
,
11
]);
expect
(
source
.
extra
).
toStrictEqual
([
20
,
21
,
22
]);
expect
(
source
.
side
).
toStrictEqual
([
30
,
31
]);
});
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment