zet-lib 1.2.102 → 1.2.104

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/Util.js +35 -0
  2. package/package.json +1 -1
package/lib/Util.js CHANGED
@@ -1275,4 +1275,39 @@ Util.decrypt = (str, key) => {
1275
1275
  return s + decrypt.final('utf8')
1276
1276
  }
1277
1277
 
1278
+ Util.terbilang = (nilai) => {
1279
+ nilai = Math.floor(Math.abs(nilai))
1280
+ let huruf = ['', 'Satu', 'Dua', 'Tiga', 'Empat', 'Lima', 'Enam', 'Tujuh', 'Delapan', 'Sembilan', 'Sepuluh', 'Sebelas']
1281
+ let bagi = 0
1282
+ let penyimpanan = ''
1283
+ if (nilai < 12) {
1284
+ penyimpanan = ' ' + huruf[nilai]
1285
+ } else if (nilai < 20) {
1286
+ penyimpanan = Util.terbilang(Math.floor(nilai - 10)) + ' Belas'
1287
+ } else if (nilai < 100) {
1288
+ bagi = Math.floor(nilai / 10)
1289
+ penyimpanan = Util.terbilang(bagi) + ' Puluh' + Util.terbilang(nilai % 10)
1290
+ } else if (nilai < 200) {
1291
+ penyimpanan = ' Seratus' + Util.terbilang(nilai - 100)
1292
+ } else if (nilai < 1000) {
1293
+ bagi = Math.floor(nilai / 100)
1294
+ penyimpanan = Util.terbilang(bagi) + ' Ratus' + Util.terbilang(nilai % 100)
1295
+ } else if (nilai < 2000) {
1296
+ penyimpanan = ' Seribu' + Util.terbilang(nilai - 1000)
1297
+ } else if (nilai < 1000000) {
1298
+ bagi = Math.floor(nilai / 1000)
1299
+ penyimpanan = Util.terbilang(bagi) + ' Ribu' + Util.terbilang(nilai % 1000)
1300
+ } else if (nilai < 1000000000) {
1301
+ bagi = Math.floor(nilai / 1000000)
1302
+ penyimpanan = Util.terbilang(bagi) + ' Juta' + Util.terbilang(nilai % 1000000)
1303
+ } else if (nilai < 1000000000000) {
1304
+ bagi = Math.floor(nilai / 1000000000)
1305
+ penyimpanan = Util.terbilang(bagi) + ' Miliar' + Util.terbilang(nilai % 1000000000)
1306
+ } else if (nilai < 1000000000000000) {
1307
+ bagi = Math.floor(nilai / 1000000000000)
1308
+ penyimpanan = Util.terbilang(nilai / 1000000000000) + ' Triliun' + Util.terbilang(nilai % 1000000000000)
1309
+ }
1310
+ return penyimpanan
1311
+ }
1312
+
1278
1313
  module.exports = Util
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zet-lib",
3
- "version": "1.2.102",
3
+ "version": "1.2.104",
4
4
  "description": "zet is a library that part of zet generator.",
5
5
  "engines": {
6
6
  "node": ">=18"