Hướng dẫn number to words javascript library - thư viện javascript số thành từ

Hướng dẫn number to words javascript library - thư viện javascript số thành từ

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.
  • toOrdinaltoWords 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.3
  • 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.
Phiê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.1
  • Gói Bower
Phiê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

    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

    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.1
  • Điều chỉnh gói nhỏ
1.0.0
  • phát hành lần đầu