skak
v1.4.2
Published
A wheel for personal use
Readme
INFO
Project_name: SKAK
Project_code: L4601
Author: MikumoAoi
Update_date: 2025-02-25
Current_ver: 1.4.2
GUIDE
Do not use version 1.2.x, these versions can not work properly.
SKAKstd (functions)
getStringLength
To calculate the length of a string, which only contains '-' and '_' and numbers and letters (length:1), kanji and kana (length:2)
args:
a string
return value:
the length of the stringexample:
console.log(SKAKstd.getStringLength("SKAKskak")); // 8 console.log(SKAKstd.getStringLength("AFさくら11")); // 10 console.log(SKAKstd.getStringLength("三雲有桜生")); // 10 console.log(SKAKstd.getStringLength("155%+166%")); // error: SKAKstd.getStringLength: STRING INCLUDES INVALID CHAR console.log(SKAKstd.getStringLength(435204)); // error: SKAKstd.getStringLength: TYPEOF ERRORgenerateRandomCode
To generate a random code string
args:
format
charset
char in format (optional, default: 'x')
return value:
a stringexample:
console.log(SKAKstd.generateRandomCode("xxxxxxxx-xxxx-4xxx-8xxx-xxxxxxxxxxxx", "0123456789abcdef")); // "a8754fc4-5422-4aa3-8977-c4cc99ae81c5" console.log(SKAKstd.generateRandomCode("xxxxxx", "0123456789ABCEFGHJKLMNPQRTUVWXY")); // "8R3UN0" console.log(SKAKstd.generateRandomCode("CODE IS: xxxxxx-0Xxxxxxx", "0123456789ABCDEF")); // "CODE IS: D2A8C1-0XC14ECA" console.log(SKAKstd.generateRandomCode("0x********", "0123456789abcdef", '*')); // "0x4cc6b83a" console.log(SKAKstd.generateRandomCode("xxxxxx", 435204)); // error: SKAKstd.generateRandomCode: TYPEOF ERROR console.log(SKAKstd.generateRandomCode("xxxxxx", "0123456789", "xx")); // error: SKAKstd.generateRandomCode: INVALID CHARtimeoutWatcher
To manage a timeout and allow refreshing the timer
args:
function to execute when the timeout completes
function to execute when the timer is refreshed (optional)
the timeout duration in milliseconds (optional, default: 5000)
return value:
a function to refresh the timerexample:
// The timeout will trigger after 8 seconds // During this time, clicking the button will refresh the timer let refresh = new timeoutWatcher(() => { alert("timeout!"); }, () => { console.log("timer refreshed."); }, 8000); // Simulate a button click to refresh the timer refresh(); // Timer resets and will trigger after another 8 secondstoLength (renamed from "zeroAdder" since v1.4.0)
To make sure the length of something is the same
args:
value
length (a integer)
length2 (optional, default: 0, only when number, the length of decimal part, a integer)type of value | length | length2
:------------ | :----- | :------
bigint | more than 1 | undefined | 0
boolean | more than 0 | undefined
number | more than 1ormore than (length2 + 2) | undefined | 0orless than 21
string | more than 1 | undefined
undefined | more than 0 | undefinedreturn value: a string
example:
console.log(SKAKstd.toLength(435204, 9)); // "000435204" console.log(SKAKstd.toLength(4352.04, 12, 4)); // "0004352.0400" console.log(SKAKstd.toLength(-4352.04068, 12, 4)); // "-004352.0407" console.log(SKAKstd.toLength(435204n, 9)); // "000435204" console.log(SKAKstd.toLength("SKAK", 8)); // " SKAK" console.log(SKAKstd.toLength("SKAKSKAKSKAK", 8)); // "SKAKS..." console.log(SKAKstd.toLength(true, 4)); // "0001" console.log(SKAKstd.toLength(undefined, 6)); // "------" console.log(SKAKstd.toLength([1, 2, 3, 4], 8)); // error: SKAKstd.toLength: TYPEOF ERROR console.log(SKAKstd.toLength(435204, 4)); // error: SKAKstd.toLength: NUMBER IS ALREADY LONGER THAN LENGTH console.log(SKAKstd.toLength(435204, -6)); // error: SKAKstd.toLength: INVALID LENGTH console.log(SKAKstd.toLength("SKAK", 8, 0)); // error: SKAKstd.toLength: INVALID LENGTH
SKAKgeo (functions)
getDistance
To calculate the distance between two points
args:
longitude1
latitude1
longitude2
latitude2
return value:
distance of two points (meter)example:
console.log(SKAKgeo.getDistance(138.8, 35.5, 138.7, 35.6)); // 14334.91 console.log(SKAKgeo.getDistance(138.8, 135.5, 138.7, 35.6)); // error: SKAKgeo.getDistance: COORDINATE OUT OF RANGE
SKAKtime (constructor)
create by timestamp or undefined (default: current timestamp)
- dateid: days count after 1998-01-25 (set/get)
- time: timestamp (set/get)
- timestamp: timestamp, same as time (get)
- date: string like "YYYY-MM-DD" (get)
- timestring: string like "YYYY-MM-DD HH:MM:SS:mmm" (get)
- datelength: array(2) like [timestamp1, timestamp2], timestamp1 is for 00:00:00:000 of that day, timestamp2 is for 23:59:59:999 of that day (get)
example:
let skaktime = new SKAKtime();
console.log(skaktime.time); // 1723114029066
console.log(skaktime.dateid); // 9693
console.log(skaktime.timestring); // "2024-08-08 18:47:09:066"
skaktime.dateid = 9999;
console.log(skaktime.timestamp); // 1749484800000
console.log(skaktime.timestring); // "2025-06-10 00:00:00:000"CHANGELOG
Version 1.4.2 (2025-02-25)
[Added] New function SKAKstd.timeoutWatcher has been added.
[Optimized] Handling of default parameter values for some functions has been improved.
[Optimized] Documentation improved.
Version 1.4.1 (2024-12-18)
[Optimized] Unified the rules for using single and double quotes.
[Optimized] Documentation improved.
Version 1.4.0 (2024-08-14)
[Optimized] Function SKAKstd.generateRandomCode now supports custom placeholders.
[Optimized] The logic of function SKAKstd.zeroAdder has been optimized, and it now supports long string truncation and has been renamed to SKAKstd.toLength.
[Optimized] Type checking for function parameters has been improved.
[Optimized] Added support for both CommonJS and ES6 usage methods.
[Optimized] Documentation improved.
Version 1.3.0 (2024-08-13)
[Added] Function SKAKstd.zeroAdder now supports data of type undefined.
[Fixed] Important bugs fixed.
[Optimized] Documentation improved.
Version 1.2.1 (2024-08-08) (UNAVAILABLE)
[Initial] Release the first npm package version.
