to-chinese-numeral
Advanced tools
Comparing version 0.1.0 to 0.2.0
"use strict"; | ||
function toChineseNumeral(num) { | ||
if (typeof num !== "number") { | ||
if (typeof num !== "number" || Number.isNaN(num)) { | ||
throw new TypeError("Not a number"); | ||
@@ -5,0 +5,0 @@ } |
{ | ||
"name": "to-chinese-numeral", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "A function that takes a Number as its argument and returns a Chinese numeral string.", |
@@ -0,1 +1,3 @@ | ||
![Jest Tests](https://github.com/mornir/to-chinese-numeral/workflows/Jest%20Tests/badge.svg?branch=master) [![NPM](https://nodei.co/npm/to-chinese-numeral.png?mini=true)](https://npmjs.org/package/to-chinese-numeral) | ||
# to-chinese-numeral | ||
@@ -20,3 +22,3 @@ | ||
const num = toChineseNumeral(156) | ||
// num = | ||
// num = 一百五十六 | ||
} catch (error) { | ||
@@ -35,2 +37,2 @@ console.error(error.message) | ||
This package was inspired by a [challenge](https://www.codewars.com/kata/52608f5345d4a19bed000b31/train/javascript) on [codewars.com](https://www.codewars.com/) | ||
This package was inspired by a [challenge](https://www.codewars.com/kata/52608f5345d4a19bed000b31/train/javascript) on [codewars.com](https://www.codewars.com/). |
function toChineseNumeral(num: number) { | ||
if (typeof num !== "number") { | ||
if (typeof num !== "number" || Number.isNaN(num)) { | ||
throw new TypeError("Not a number") | ||
@@ -4,0 +4,0 @@ } |
@@ -39,2 +39,10 @@ const toChineseNumeral = require("../dist/index.js") | ||
expect(() => { | ||
toChineseNumeral(NaN) | ||
}).toThrow(TypeError) | ||
expect(() => { | ||
toChineseNumeral("") | ||
}).toThrow(TypeError) | ||
expect(() => { | ||
toChineseNumeral(56896325) | ||
@@ -41,0 +49,0 @@ }).toThrow(RangeError) |
15697
10
250
37