Skip to content

Commit

Permalink
Temp commit
Browse files Browse the repository at this point in the history
  • Loading branch information
hakatashi committed Nov 29, 2023
1 parent b18fa52 commit 7340ae6
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 2 deletions.
16 changes: 16 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"ascii85": "^1.0.2",
"browserify": "^17.0.0",
"browserify-shim": "^3.8.16",
"bs58": "^5.0.0",
"chai": "^4.3.7",
"coffeeify": "^3.0.1",
"coffeescript": "^2.7.0",
Expand Down
9 changes: 9 additions & 0 deletions src/base58.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import * as bs58 from 'bs58';

export const encode = (data:Buffer) => {
return bs58.encode(data);
};

export const decode = (text:string) => {
return Buffer.from(bs58.decode(text));
};
2 changes: 1 addition & 1 deletion src/nfc.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import unorm = require('unorm');
import * as unorm from 'unorm';

export const encode = (data:Buffer) => {
return unorm.nfc(data.toString('utf-8'));
Expand Down
2 changes: 1 addition & 1 deletion src/nfkc.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import unorm = require('unorm');
import * as unorm from 'unorm';

export const encode = (data:Buffer) => {
return unorm.nfkc(data.toString('utf-8'));
Expand Down
18 changes: 18 additions & 0 deletions test/base58.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
chai = require 'chai'
base58 = require '../src/base58'

{equalityWith} = require './util'

expect = chai.expect

describe 'base58', ->
describe 'base58.encode', ->
it 'basically works', ->
expect base58.encode Buffer.from 'Hello World!', 'ascii'
.to.be.a 'string'
.and.equal '2NEpo7TZRRrLZSi2U'

describe 'base58.decode', ->
it 'basically works', ->
expect base58.decode Buffer.from '2NEpo7TZRRrLZSi2U', 'ascii'
.to.satisfy equalityWith 'Hello World!'
1 change: 1 addition & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require('./nfkc');
require('./idna');
require('./rot13');
require('./binary');
require('./base58');
require('./base64');
require('./ascii85');
require('./unicode');
Expand Down

0 comments on commit 7340ae6

Please sign in to comment.