11#!/usr/bin/env node
2+ // @ts -check
23// NOTE: npm run package
3- // const fs = require('fs');
4+
5+ import fs from 'fs' ;
6+ import notation from '../lib/index.js' ;
47// // const notation = require('../notation');
58// const notation = require('../');
6- // let query = process.argv.slice(2)[0];
9+ let query = process . argv . slice ( 2 ) [ 0 ] ;
710
8- // // query = '123456781234567876000 ';
9- // // query = '27,000,000.00 ';
10- // // query = '၁,၂၀၀၀၀၀.၂ဝ';
11+ query = '27,000,000.00 ' ;
12+ // query = '27,000,000';
13+ // query = '၁,၂၀၀၀၀၀.၂ဝ';
1114// // query = '၂၇၀၀';
1215// query = '၂,၇၀၀';
1316// // query = '5.23e+8';
17+ // console.log(notation);
18+
19+ let raw = notation ( query ) ;
20+ fs . writeFile ( "./test/mod.json" , JSON . stringify ( raw , null , 2 ) , 'utf8' , e => console . log ( e || "...done" ) ) ;
21+
22+ // function NumInWords( n ) {
23+
24+ // var string = n.toString(), units, tens, scales, start, end, chunks, chunksLen, chunk, ints, i, word, words, and = 'and';
25+
26+ // /* Remove spaces and commas */
27+ // string = string.replace(/[, ]/g,"");
28+
29+ // /* Is number zero? */
30+ // if( parseInt( string ) === 0 ) {
31+ // return 'zero';
32+ // }
33+
34+ // /* Array of units as words */
35+ // units = [ '', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen' ];
36+
37+ // /* Array of tens as words */
38+ // tens = [ '', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety' ];
39+
40+ // /* Array of scales as words */
41+ // scales = [ '', 'thousand', 'million', 'billion', 'trillion', 'quadrillion', 'quintillion', 'sextillion', 'septillion', 'octillion', 'nonillion', 'decillion', 'undecillion', 'duodecillion', 'tredecillion', 'quatttuor-decillion', 'quindecillion', 'sexdecillion', 'septen-decillion', 'octodecillion', 'novemdecillion', 'vigintillion', 'centillion' ];
42+
43+ // /* Split user argument into 3 digit chunks from right to left */
44+ // start = string.length;
45+ // chunks = [];
46+ // while( start > 0 ) {
47+ // end = start;
48+ // chunks.push( string.slice( ( start = Math.max( 0, start - 3 ) ), end ) );
49+ // }
50+
51+ // /* Check if function has enough scale words to be able to stringify the user argument */
52+ // chunksLen = chunks.length;
53+ // if( chunksLen > scales.length ) {
54+ // return '';
55+ // }
56+
57+ // /* Stringify each integer in each chunk */
58+ // words = [];
59+ // for( i = 0; i < chunksLen; i++ ) {
60+
61+ // chunk = parseInt( chunks[i] );
62+
63+ // if( chunk ) {
64+
65+ // /* Split chunk into array of individual integers */
66+ // ints = chunks[i].split( '' ).reverse().map( parseFloat );
67+
68+ // /* If tens integer is 1, i.e. 10, then add 10 to units integer */
69+ // if( ints[1] === 1 ) {
70+ // ints[0] += 10;
71+ // }
72+
73+ // /* Add scale word if chunk is not zero and array item exists */
74+ // if( ( word = scales[i] ) ) {
75+ // words.push( word );
76+ // }
77+
78+ // /* Add unit word if array item exists */
79+ // if( ( word = units[ ints[0] ] ) ) {
80+ // words.push( word );
81+ // }
82+
83+ // /* Add tens word if array item exists */
84+ // if( ( word = tens[ ints[1] ] ) ) {
85+ // words.push( word );
86+ // }
87+
88+ // /* Add 'and' string after units or tens integer if: */
89+ // if( ints[0] || ints[1] ) {
90+
91+ // /* Chunk has a hundreds integer or chunk is the first of multiple chunks */
92+ // if( ints[2] || (i + 1) > chunksLen ) {
93+ // words.push( and );
94+ // }
95+
96+
97+ // }
98+
99+ // /* Add hundreds word if array item exists */
100+ // if( ( word = units[ ints[2] ] ) ) {
101+ // words.push( word + ' hundred' );
102+ // }
103+
104+ // }
105+
106+ // }
107+
108+ // return words.reverse().join( ' ' );
109+
110+ // }
111+
112+
113+ // // console.log(NumInWords(1111))
114+
115+ // /**
116+ // * @param {number | string } n
117+ // */
118+ // function NumInMyanmar(n=''){
119+ // var string = n.toString().replace(/[, ]/g,"");
120+ // return string;
121+ // }
14122
15- // let raw = notation.get(query);
16- // fs.writeFile("./test/mod.json", JSON.stringify(raw, null, 2), 'utf8', e=>console.log(e || "...done"));
123+ // console.log(NumInMyanmar(1111))
0 commit comments