Ver código fonte

Add scripts

Scripts test the capabilities of the library.
master
TheoryOfNekomata 3 anos atrás
pai
commit
bfe6f2596e
4 arquivos alterados com 37 adições e 2 exclusões
  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 Ver arquivo

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

+ 1
- 1
TODO.md Ver arquivo

@@ -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 Ver arquivo

@@ -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 Ver arquivo

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

Carregando…
Cancelar
Salvar