skak
v1.4.0
Published
A probably useful wheel
Downloads
4
Readme
INFO
Project_name: SKAK
Project_code: L4601
Author: MikumoAoi
Update_date: 2024-08-14
Current_ver: 1.4.0
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: 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%")); // SKAKstd.getStringLength: STRING INCLUDES INVALID CHAR console.log(SKAKstd.getStringLength(435204)); // SKAKstd.getStringLength: TYPEOF ERROR
generateRandomCode
To generate a random code string
args: format, charset, char in format (optional, default 'x')
return: 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)); // SKAKstd.generateRandomCode: TYPEOF ERROR console.log(SKAKstd.generateRandomCode("xxxxxx", "0123456789", "xx")); // SKAKstd.generateRandomCode: INVALID CHAR
toLength (renamed from "zeroAdder" since v1.4.0)
To make sure the length of something is the same
args: value, length (a integer), length2 (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 | undefined
return: a stringexample:
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)); // SKAKstd.toLength: TYPEOF ERROR console.log(SKAKstd.toLength(435204, 4)); // SKAKstd.toLength: NUMBER IS ALREADY LONGER THAN LENGTH console.log(SKAKstd.toLength(435204, -6)); // SKAKstd.toLength: INVALID LENGTH console.log(SKAKstd.toLength("SKAK", 8, 0)); // SKAKstd.toLength: INVALID LENGTH
SKAKgeo (functions)
getDistance
To calculate the distance between two points
args: longitude1, latitude1, longitude2, latitude2
return: 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)); // SKAKgeo.getDistance: COORDINATE OUT OF RANGE
SKAKtime (constructor)
create by timestamp or undefined (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.0 (2024-08-14)
[Optimization] Added support for both CommonJS and ES6 usage methods.
[Optimization] Function SKAKstd.generateRandomCode now supports custom placeholders.
[Optimization] The logic of function SKAKstd.zeroAdder has been optimized, and it now supports long string truncation and has been renamed to toLength.
[Optimization] Type checking for function parameters has been improved.
[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.