UNPKG

thai-multiplication-table

Version:

เป็นแพ็กเกจสำหรับช่วยในการแสดงตารางสูตรคูณภาษาไทยรูปแบบเลขจำนวนเต็มบวก

45 lines (42 loc) 1.7 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/index.ts var index_exports = {}; __export(index_exports, { getTable: () => getTable, toThaiNumber: () => toThaiNumber }); module.exports = __toCommonJS(index_exports); // src/functions.ts function toThaiNumber(number) { const thaiDigits = ["\u0E50", "\u0E51", "\u0E52", "\u0E53", "\u0E54", "\u0E55", "\u0E56", "\u0E57", "\u0E58", "\u0E59"]; return number.toString().split("").map((digit) => thaiDigits[parseInt(digit)]).join(""); } function getTable(multiplicand, multiplierStart = 1, multiplierEnd = 12) { const result = []; for (let multiplier = multiplierStart; multiplier <= multiplierEnd; multiplier++) { result.push(`${toThaiNumber(multiplicand)} x ${toThaiNumber(multiplier)} = ${toThaiNumber(multiplicand * multiplier)}`); } return result; } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { getTable, toThaiNumber });