ckn.core v3.1.36
CKN Core
CKN Framework is framework for Javascript to support both of backend and frontend. It helps us to develop microservice model easier. And it helps to manage 3rd parties library. CKN Core is foundation library of CKN Framework. Including override method for primitive data type, api function that support both of frontend and backend and logging tools.
Installation
CKN Core is public npm package on NPM registry. Before install package, need to install Node.js version 18.0 or higher.
npm install ckn.coreNumeric tools - round
CKN Core provide round function for all numeric variable to round the decimal.
import {ckn} from 'ckn.core'
let n = 10.3;
console.log(n.round()); // output is 10.0Numeric tools - ceil
CKN Core provide ceil function for all numeric variable to round up the decimal.
import {ckn} from 'ckn.core'
let n = 10.3;
console.log(n.ceil());
// output is 11.0Numeric tools - floor
CKN Core provide floor function for all numeric variable to round down the decimal.
import {ckn} from 'ckn.core'
let n = 10.3;
console.log(n.floor());
// output is 11.0Numeric tools - printFormat
CKN Core provide printFormat function for all numeric variable to convert to string with normal number format ex. 1500 will be print as "1,500.00".
import {ckn} from 'ckn.core'
let n = 1500.5;
let decemal_number = 2;
let separate_thousands = ',';
console.log(n.printFormat(decemal_number, separate_thousands));
// output is 1,500.50
console.log(n.printFormat(decemal_number));
// output is 1,500.50
console.log(n.printFormat());
// output is 1500.50Options
targetLengthOPTIONAL is number of decimal that is show in printed string such as 2 for .50 in 1,500.50separate_thousandsOPTIONAL, DEFAULT = ',' is character that is used for separate thousands such as , for 1,5000.00
Numeric tools - padStart
CKN Core provide padStart function for all numeric variable to convert to string and pad string before original data.
import {ckn} from 'ckn.core'
let n = 15;
let targetLength = 5;
let padString = '0';
console.log(n.padStart(targetLength, padString));
// output is 00015Options
targetLengthis length for padding stringpadStringis character that is used for padding
Numeric tools - padEnd
CKN Core provide padEnd function for all numeric variable to convert to string pad string after original data.
import {ckn} from 'ckn.core'
let n = 15;
let targetLength = 5;
let padString = 'A';
console.log(n.padEnd(targetLength, padString));
// output is 15AAAOptions
targetLengthis length for padding stringpadStringis character that is used for padding
String tools - edit
CKN Core provide edit function for all string variable to edit string by processing for each character.
import {ckn} from 'ckn.core'
let str = "Hello world";
let editFunction = c => {
if (c == 'e') {
return 'a';
}
return c;
};
let newStr = str.edit(editFunction);
console.log(newStr)
// output is Hallo worldOptions
editFunctionis function to process edit condition
String tools - each
CKN Core provide each function for all string variable to process for each character in string
import {ckn} from 'ckn.core'
let str = "Hello world";
let eachFunction = c => {
if (c == 'e') {
console.log("Hi", c);
}
};
str.each(eachFunction);
// output is 'Hi e'Options
eachFunctionis function to process each condition
Date tools - date
CKN Core provide date function for all Date variable to get date value
import {ckn} from 'ckn.core'
let date = new Date(2023, 4, 31); // 31 May 2023
console.log(date.date());
// output is 31Date tools - month
CKN Core provide month function for all Date variable to get month value
import {ckn} from 'ckn.core'
let date = new Date(2023, 4, 31); // 31 May 2023
console.log(date.month());
// output is 05Date tools - year
CKN Core provide year function for all Date variable to get year value
import {ckn} from 'ckn.core'
let date = new Date(2023, 4, 31); // 31 May 2023
console.log(date.year());
// output is 2023License
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago