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 đặt
npm install number-to-words
API
toOrdinal(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.0
Xem 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.
- Sửa lỗi trong
var converter = require('number-to-words');
converter.toWords(13);
converter.toWords(2.9);
converter.toWords(-3);
converter.toWords(9007199254740992);
0 cho Phantom và IE (#10). Cảm ơn @jeremiahrhall.
- 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.
- Gói Bower
- 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ếnvar 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ằngvar converter = require('number-to-words');
converter.toWords(13);
converter.toWords(2.9);
converter.toWords(-3);
converter.toWords(9007199254740992);
9).
- 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ự
- Điều chỉnh gói nhỏ
- phát hành lần đầu