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
56536e96
Commit
56536e96
authored
Feb 13, 2023
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add toUint8Array
parent
c2edbd5f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
5 deletions
+16
-5
index.ts
index.ts
+16
-5
No files found.
index.ts
View file @
56536e96
import
{
countItems
}
from
'
./src/utils
'
;
import
{
countItems
}
from
'
./src/utils
'
;
import
{
Base64
}
from
'
js-base64
'
;
import
{
Base64
,
fromUint8Array
}
from
'
js-base64
'
;
export
default
class
YGOProDeck
{
export
default
class
YGOProDeck
{
main
:
number
[]
=
[];
main
:
number
[]
=
[];
...
@@ -17,7 +17,7 @@ export default class YGOProDeck {
...
@@ -17,7 +17,7 @@ export default class YGOProDeck {
return
counted
.
reduce
((
a
,
b
)
=>
a
+
b
.
size
*
4
,
0
);
return
counted
.
reduce
((
a
,
b
)
=>
a
+
b
.
size
*
4
,
0
);
}
}
to
EncodedString
()
{
to
Uint8Array
()
{
const
counted
=
[
this
.
main
,
this
.
extra
,
this
.
side
].
map
(
countItems
);
const
counted
=
[
this
.
main
,
this
.
extra
,
this
.
side
].
map
(
countItems
);
const
buf
=
new
Uint8Array
(
counted
.
reduce
((
a
,
b
)
=>
a
+
b
.
size
*
4
,
0
));
const
buf
=
new
Uint8Array
(
counted
.
reduce
((
a
,
b
)
=>
a
+
b
.
size
*
4
,
0
));
let
pointer
=
0
;
let
pointer
=
0
;
...
@@ -38,15 +38,18 @@ export default class YGOProDeck {
...
@@ -38,15 +38,18 @@ export default class YGOProDeck {
}
}
};
};
counted
.
forEach
(
writeCards
);
counted
.
forEach
(
writeCards
);
return
Base64
.
fromUint8Array
(
buf
,
true
);
return
buf
;
}
toEncodedString
()
{
return
Base64
.
fromUint8Array
(
this
.
toUint8Array
(),
true
);
}
}
toString
()
{
toString
()
{
return
this
.
toEncodedString
();
return
this
.
toEncodedString
();
}
}
fromEncodedString
(
str
:
string
)
{
fromUint8Array
(
buf
:
Uint8Array
)
{
const
buf
=
Base64
.
toUint8Array
(
str
);
for
(
let
i
=
0
;
i
<
buf
.
length
-
3
;
i
+=
4
)
{
for
(
let
i
=
0
;
i
<
buf
.
length
-
3
;
i
+=
4
)
{
const
value
=
const
value
=
buf
[
i
]
|
(
buf
[
i
+
1
]
<<
8
)
|
(
buf
[
i
+
2
]
<<
16
)
|
(
buf
[
i
+
3
]
<<
24
);
buf
[
i
]
|
(
buf
[
i
+
1
]
<<
8
)
|
(
buf
[
i
+
2
]
<<
16
)
|
(
buf
[
i
+
3
]
<<
24
);
...
@@ -62,6 +65,14 @@ export default class YGOProDeck {
...
@@ -62,6 +65,14 @@ export default class YGOProDeck {
return
this
;
return
this
;
}
}
static
fromUint8Array
(
buf
:
Uint8Array
)
{
return
new
YGOProDeck
().
fromUint8Array
(
buf
);
}
fromEncodedString
(
str
:
string
)
{
return
this
.
fromUint8Array
(
Base64
.
toUint8Array
(
str
));
}
static
fromEncodedString
(
str
:
string
)
{
static
fromEncodedString
(
str
:
string
)
{
return
new
YGOProDeck
().
fromEncodedString
(
str
);
return
new
YGOProDeck
().
fromEncodedString
(
str
);
}
}
...
...
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