Skip to content

Commit

Permalink
Support rescript-v11 (#5)
Browse files Browse the repository at this point in the history
* update

* changeset

* remove changeset

* 0.3.0
  • Loading branch information
namenu authored Feb 8, 2024
1 parent 588df5f commit 8410990
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 69 deletions.
8 changes: 0 additions & 8 deletions .changeset/README.md

This file was deleted.

11 changes: 0 additions & 11 deletions .changeset/config.json

This file was deleted.

77 changes: 38 additions & 39 deletions __tests__/KoreanNumeral_test.res
Original file line number Diff line number Diff line change
@@ -1,56 +1,55 @@
open Jest;
open Jest

describe(`1만 이하 표시`, () => {
open Expect;
open Expect

test(`KoreanNumeral.fromInt`, () => {
let result = KoreanNumeral.fromInt(1234, ());
expect(result) |> toBe(`1,234`);
});
let result = KoreanNumeral.fromInt(1234, ())
expect(result)->toBe(`1,234`)
})
test(`KoreanNumeral.fromFloat`, () => {
let result = KoreanNumeral.fromFloat(152212525110.0, ());
expect(result) |> toBe(`1,522억 1,252만 5,110`);
});
let result = KoreanNumeral.fromFloat(152212525110.0, ())
expect(result)->toBe(`1,522억 1,252만 5,110`)
})
test(`KoreanNumeral.fromInt64`, () => {
let result =
KoreanNumeral.fromInt64(Int64.of_string("1234567890987654321"), ());
expect(result) |> toBe(`123경 4,567조 8,909억 8,765만 4,321`);
});
});
let result = KoreanNumeral.fromInt64(Int64.of_string("1234567890987654321"), ())
expect(result)->toBe(`123경 4,567조 8,909억 8,765만 4,321`)
})
})

describe(`1만 이하는 절삭`, () => {
open Expect;
open Expect

test(`1234 => ""`, () => {
let result = KoreanNumeral.fromInt(1234, ~drop=1, ());
expect(result) |> toBe(``);
});
let result = KoreanNumeral.fromInt(1234, ~drop=1, ())
expect(result)->toBe(``)
})
test(`1234567 => "123만"`, () => {
let result = KoreanNumeral.fromInt(1234567, ~drop=1, ());
expect(result) |> toBe(`123만`);
});
let result = KoreanNumeral.fromInt(1234567, ~drop=1, ())
expect(result)->toBe(`123만`)
})
test(`1234567890 => "12억 3,456만"`, () => {
let result = KoreanNumeral.fromInt(1234567890, ~drop=1, ());
expect(result) |> toBe(`12억 3,456만`);
});
let result = KoreanNumeral.fromInt(1234567890, ~drop=1, ())
expect(result)->toBe(`12억 3,456만`)
})
test(`1234567890.1 => "12억 3,456만"`, () => {
let result = KoreanNumeral.fromFloat(1234567890.1, ~drop=1, ());
expect(result) |> toBe(`12억 3,456만`);
});
let result = KoreanNumeral.fromFloat(1234567890.1, ~drop=1, ())
expect(result)->toBe(`12억 3,456만`)
})
test(`152212525110 => "1,522억 1,252만"`, () => {
let result = KoreanNumeral.fromFloat(152212525110.0, ~drop=1, ());
expect(result) |> toBe(`1,522억 1,252만`);
});
let result = KoreanNumeral.fromFloat(152212525110.0, ~drop=1, ())
expect(result)->toBe(`1,522억 1,252만`)
})
test(`152212525110 => "1,522억"`, () => {
let result = KoreanNumeral.fromFloat(152200005110.0, ~drop=1, ());
expect(result) |> toBe(`1,522억`);
});
let result = KoreanNumeral.fromFloat(152200005110.0, ~drop=1, ())
expect(result)->toBe(`1,522억`)
})
test(`220000152212525110.0 => "22경 1,522억 1,252만"`, () => {
let result = KoreanNumeral.fromFloat(220000152212525110.0, ~drop=1, ());
expect(result) |> toBe(`22경 1,522억 1,252만`);
});
let result = KoreanNumeral.fromFloat(220000152212525110.0, ~drop=1, ())
expect(result)->toBe(`22경 1,522억 1,252만`)
})
test(`1234567890987654321 => "123경 4,567조 8,909억 8,765만"`, () => {
let result = KoreanNumeral.fromString("1234567890987654321", ~drop=1, ());
expect(result) |> toBe(`123경 4,567조 8,909억 8,765만`);
});
});
let result = KoreanNumeral.fromString("1234567890987654321", ~drop=1, ())
expect(result)->toBe(`123경 4,567조 8,909억 8,765만`)
})
})
11 changes: 4 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@greenlabs/rescript-korean-numeral",
"version": "0.2.0",
"version": "0.3.0",
"description": "ReScript module to convert the number to Korean",
"scripts": {
"start": "rescript build -w",
Expand All @@ -24,10 +24,7 @@
},
"homepage": "https://github.com/green-labs/rescript-korean-numeral#readme",
"devDependencies": {
"@glennsl/bs-jest": "^0.6.0",
"rescript": "^10"
},
"dependencies": {
"@changesets/cli": "^2.24.4"
"@glennsl/rescript-jest": "^0.10.0",
"rescript": "^11"
}
}
}
3 changes: 1 addition & 2 deletions bsconfig.json → rescript.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
}
],
"suffix": ".bs.js",
"refmt": 3,
"bs-dev-dependencies": [
"@glennsl/bs-jest"
"@glennsl/rescript-jest"
]
}
4 changes: 2 additions & 2 deletions src/KoreanNumeral.res
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@bs.send external toLocaleString: (int, string) => string = "toLocaleString"
@send external toLocaleString: (int, string) => string = "toLocaleString"

open Belt

Expand All @@ -20,7 +20,7 @@ let fromInt64 = (num, ~drop=0, ()) => {
->List.keep(i => i != "")
->List.reverse
->List.toArray
->Js.Array.joinWith(" ", _)
->(Js.Array.joinWith(" ", _))
}

let fromInt = (num, ~drop=0, ()) => {
Expand Down

0 comments on commit 8410990

Please sign in to comment.