From bfe6f2596e1e6bfe7a562d8dd084e5e283c05e6f Mon Sep 17 00:00:00 2001 From: TheoryOfNekomata Date: Wed, 21 Jul 2021 14:38:26 +0800 Subject: [PATCH] Add scripts Scripts test the capabilities of the library. --- .gitignore | 3 ++- TODO.md | 2 +- scripts/count-to-one-milliamilliatillion.js | 17 +++++++++++++++++ scripts/count-to-one-million.js | 17 +++++++++++++++++ 4 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 scripts/count-to-one-milliamilliatillion.js create mode 100644 scripts/count-to-one-million.js diff --git a/.gitignore b/.gitignore index 62c8935..a8a510b 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -.idea/ \ No newline at end of file +.idea/ +scripts/*.out.* \ No newline at end of file diff --git a/TODO.md b/TODO.md index 9ddde2d..8ec7a7a 100644 --- a/TODO.md +++ b/TODO.md @@ -6,6 +6,6 @@ - [ ] Exponential syntax support - [ ] Optimizations for fractions - [ ] Check invalid string inputs -- [ ] Ordinals (e.g. `twentieth`, `first`, `two millionth`) +- [X] Ordinals (e.g. `twentieth`, `first`, `two millionth`) - [ ] Implement other `fractionType`s, implement `lazy` fractions, e.g. `0.05` => `zero point zero five`, will implement `ratio` (`zero and five over one hundred`) and `part` (`zero and five hundredths`) diff --git a/scripts/count-to-one-milliamilliatillion.js b/scripts/count-to-one-milliamilliatillion.js new file mode 100644 index 0000000..2bbb002 --- /dev/null +++ b/scripts/count-to-one-milliamilliatillion.js @@ -0,0 +1,17 @@ +const { default: getNumberName } = require('../packages/core') +const fs = require('fs') +const path = require('path') + +const main = async () => { + const ws = fs.createWriteStream(path.resolve(__dirname, 'count-to-one-milliatillion.out.csv')) + ws.write('number,name\n') + for (let i = 0; i <= 3000003; i++) { + if (i % 1000 === 0) { + console.log(i) + } + ws.write(`1e+${i}` + ',' + getNumberName(`1e+${i}`) + '\n') + } + ws.close() +} + +void main() diff --git a/scripts/count-to-one-million.js b/scripts/count-to-one-million.js new file mode 100644 index 0000000..8220e49 --- /dev/null +++ b/scripts/count-to-one-million.js @@ -0,0 +1,17 @@ +const { default: getNumberName } = require('../packages/core') +const fs = require('fs') +const path = require('path') + +const main = async () => { + const ws = fs.createWriteStream(path.resolve(__dirname, 'count-to-one-million.out.csv')) + ws.write('number,name\n') + for (let i = 0; i <= 1000000; i++) { + if (i % 1000 === 0) { + console.log(i) + } + ws.write(i + ',' + getNumberName(i) + '\n') + } + ws.close() +} + +void main()