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
27b113a5
Commit
27b113a5
authored
Aug 14, 2025
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve impl of isEqual
parent
981fbe1c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
7 deletions
+16
-7
index.ts
index.ts
+15
-2
src/utils.ts
src/utils.ts
+1
-5
No files found.
index.ts
View file @
27b113a5
...
@@ -223,11 +223,24 @@ export default class YGOProDeck implements YGOProDeckLike {
...
@@ -223,11 +223,24 @@ export default class YGOProDeck implements YGOProDeckLike {
}
=
{},
}
=
{},
):
boolean
{
):
boolean
{
const
{
ignoreOrder
=
false
}
=
options
;
const
{
ignoreOrder
=
false
}
=
options
;
const
fields
=
[
'
main
'
,
'
extra
'
,
'
side
'
]
as
const
;
const
getField
=
(
o
:
YGOProDeckLike
,
field
:
(
typeof
fields
)[
number
])
=>
o
[
field
]
||
[];
if
(
fields
.
some
(
(
field
)
=>
getField
(
this
,
field
).
length
!==
getField
(
other
,
field
).
length
,
)
)
{
return
false
;
}
const
normalize
=
(
arr
:
number
[])
=>
const
normalize
=
(
arr
:
number
[])
=>
ignoreOrder
?
[...
arr
].
sort
((
a
,
b
)
=>
a
-
b
)
:
arr
;
ignoreOrder
?
[...
arr
].
sort
((
a
,
b
)
=>
a
-
b
)
:
arr
;
const
fields
=
[
'
main
'
,
'
extra
'
,
'
side
'
]
as
const
;
return
fields
.
every
((
field
)
=>
return
fields
.
every
((
field
)
=>
arrayEquals
(
normalize
(
this
[
field
]),
normalize
(
other
[
field
]
||
[])),
arrayEquals
(
normalize
(
getField
(
this
,
field
)),
normalize
(
getField
(
other
,
field
)),
),
);
);
}
}
}
}
src/utils.ts
View file @
27b113a5
...
@@ -175,9 +175,5 @@ export class BufferReader extends BufferCursor {
...
@@ -175,9 +175,5 @@ export class BufferReader extends BufferCursor {
}
}
export
const
arrayEquals
=
<
T
>
(
a
:
T
[],
b
:
T
[]):
boolean
=>
{
export
const
arrayEquals
=
<
T
>
(
a
:
T
[],
b
:
T
[]):
boolean
=>
{
if
(
a
.
length
!==
b
.
length
)
return
false
;
return
a
.
length
===
b
.
length
&&
a
.
every
((
v
,
i
)
=>
v
===
b
[
i
]);
for
(
let
i
=
0
;
i
<
a
.
length
;
i
++
)
{
if
(
a
[
i
]
!==
b
[
i
])
return
false
;
}
return
true
;
};
};
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