Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
G1lib.js
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
libs
G1lib.js
Commits
554211c4
Commit
554211c4
authored
3 years ago
by
Millicent Billette
Browse files
Options
Downloads
Patches
Plain Diff
100% coverage
parent
819346b1
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/basex.mjs
+2
-2
2 additions, 2 deletions
src/basex.mjs
src/basex.test.mjs
+21
-0
21 additions, 0 deletions
src/basex.test.mjs
with
23 additions
and
2 deletions
src/basex.mjs
+
2
−
2
View file @
554211c4
...
...
@@ -2,8 +2,8 @@
const
B58_ALPHABET
=
'
123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz
'
;
export
const
b58
=
basex
(
B58_ALPHABET
);
export
const
b16
=
basex
(
'
0123456789abcdef
'
);
export
default
function
basex
(
ALPHABET
)
{
export
default
basex
;
export
function
basex
(
ALPHABET
)
{
const
ALPHABET_MAP
=
{};
const
BASE
=
ALPHABET
.
length
;
const
LEADER
=
ALPHABET
.
charAt
(
0
);
...
...
This diff is collapsed.
Click to expand it.
src/basex.test.mjs
+
21
−
0
View file @
554211c4
...
...
@@ -7,3 +7,24 @@ const pubKey = 'AoxVA41dGL2s4ogMNdbCw3FFYjFo5FPK36LuiW1tjGbG';
test
(
'
b58 should decode/encode well
'
,
t
=>
{
t
.
is
(
app
.
b58
.
encode
(
app
.
b58
.
decode
(
pubKey
)),
pubKey
);
});
test
(
'
basex dont allow ambigous alphabet (each character must be unique)
'
,
t
=>
{
t
.
throws
(()
=>
app
.
basex
(
'
zz
'
));
});
test
(
'
empty input empty output
'
,
t
=>
{
t
.
is
(
app
.
b58
.
encode
([]),
''
);
});
test
(
'
encode 0000 filled source
'
,
t
=>
{
t
.
is
(
app
.
b16
.
encode
([
0
,
0
,
0
,
0
,
15
]),
'
0000f
'
);
});
test
(
'
decode 0000 filled source
'
,
t
=>
{
t
.
deepEqual
(
app
.
b16
.
decode
(
'
0000f
'
),
new
Uint8Array
([
0
,
0
,
0
,
0
,
15
]));
});
test
(
'
decode out of base chr throw error
'
,
t
=>
{
t
.
throws
(()
=>
app
.
b58
.
decode
(
pubKey
+
'
§
'
));
});
test
(
'
no string decode throw
'
,
t
=>
{
t
.
throws
(()
=>
app
.
b58
.
decode
([]));
});
test
(
'
decode empty string => empty array
'
,
t
=>
{
t
.
deepEqual
(
app
.
b16
.
decode
(
''
),
new
Uint8Array
(
0
));
});
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment