Browse Source

Add scripts

Scripts test the capabilities of the library.
master
TheoryOfNekomata 3 years ago
parent
commit
bfe6f2596e
4 changed files with 37 additions and 2 deletions
  1. +2
    -1
      .gitignore
  2. +1
    -1
      TODO.md
  3. +17
    -0
      scripts/count-to-one-milliamilliatillion.js
  4. +17
    -0
      scripts/count-to-one-million.js

+ 2
- 1
.gitignore View File

@@ -1 +1,2 @@
.idea/
.idea/
scripts/*.out.*

+ 1
- 1
TODO.md View File

@@ -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`)

+ 17
- 0
scripts/count-to-one-milliamilliatillion.js View File

@@ -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()

+ 17
- 0
scripts/count-to-one-million.js View File

@@ -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()

Loading…
Cancel
Save