Số cho các từChứa một số phương thức sử dụng để chuyển đổi số thành từ, từ thứ tự và số thứ tự. Cài đặtnpm install number-to-words
APItoOrdinal(number)
Chuyển đổi một số nguyên thành một chuỗi với một postfix thứ tự. Nếu số là số thập phân, số thập phân sẽ bị xóa. var converter = require('number-to-words'); converter.toOrdinal(21);
toWords(number)
Chuyển đổi một số nguyên thành từ. Nếu số là số thập phân, số thập phân sẽ bị xóa. var converter = require('number-to-words'); converter.toWords(13); converter.toWords(2.9); converter.toWords(-3); converter.toWords(9007199254740992);
toWordsOrdinal(number)
Chuyển đổi một số thành các từ thứ tự. Nếu số là số thập phân, số thập phân sẽ bị xóa. var converter = require('number-to-words'); converter.toWordsOrdinal(21);
Đóng góp, nhận xét và lỗiĐóng góp, nhận xét và/hoặc báo cáo lỗi được đánh giá cao. Mở một yêu cầu kéo hoặc thêm nhận xét trên trang vấn đề. Cảm ơn! Sắp tới v2.0Xem lộ trình để biết chi tiết. Thay đổi nhật kýPhiên bản 1.2.4 (Bản phát hành cuối cùng 1.x)- Sửa lỗi trong
toOrdinal . Khi được thông qua -11, -12 và -13, nó đã trả lại một hậu tố không chính xác (#15). Cảm ơn @dmrzn. toOrdinal và toWords hiện đã ném một lỗi chính xác hơn khi được thông qua một số không an toàn (#13). Cảm ơn @Adrianomelo.
Phiên bản 1.2.3Phiên bản 1.2.2- Sửa lỗi trong
toOrdinal . Đầu vào 11, 12 và 13 hiện mang lại hậu tố chính xác (#8). Cảm ơn @Pilyugin.
Phiên bản 1.2.1Phiên bản 1.2.0- Các gói hiện có sẵn cho các trình duyệt (
var converter = require('number-to-words'); converter.toWords(13); converter.toWords(2.9); converter.toWords(-3); converter.toWords(9007199254740992); 2 và var converter = require('number-to-words'); converter.toWords(13); converter.toWords(2.9); converter.toWords(-3); converter.toWords(9007199254740992); 3). Họ xuất khẩu một biến var converter = require('number-to-words'); converter.toWords(13); converter.toWords(2.9); converter.toWords(-3); converter.toWords(9007199254740992); 4 toàn cầu. - Thực hiện các bài kiểm tra đơn vị có thể chạy trong trình duyệt. Để chạy các thử nghiệm đơn vị trong trình duyệt, hãy khởi động một máy chủ cục bộ và truy cập localhost/spec bằng trình duyệt.
toOrdinal , toWords và var converter = require('number-to-words'); converter.toWords(13); converter.toWords(2.9); converter.toWords(-3); converter.toWords(9007199254740992); 7 Bây giờ cũng cho phép các giá trị chuỗi làm đầu vào (đã thay thế var converter = require('number-to-words'); converter.toWords(13); converter.toWords(2.9); converter.toWords(-3); converter.toWords(9007199254740992); 8 bằng var converter = require('number-to-words'); converter.toWords(13); converter.toWords(2.9); converter.toWords(-3); converter.toWords(9007199254740992); 9).
1.1.0- Phương pháp mới
toOrdinal và var converter = require('number-to-words'); converter.toWords(13); converter.toWords(2.9); converter.toWords(-3); converter.toWords(9007199254740992); 7 - Không dùng
toWords Bây giờ chuyển đổi bất kỳ đầu vào thập phân nào thành số nguyên (với var converter = require('number-to-words'); converter.toWords(13); converter.toWords(2.9); converter.toWords(-3); converter.toWords(9007199254740992); 8)- Lỗi đã cố định trả về "zeroth" thay vì "số 0" khi chuyển đổi một từ số thành thứ tự
1.0.11.0.0 |