3.1.36 • Published 2 months ago

ckn.core v3.1.36

Weekly downloads
-
License
ISC
Repository
-
Last release
2 months ago

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.core

Numeric 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.0

Numeric 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.0

Numeric 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.0

Numeric 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.50

Options

  • targetLength OPTIONAL is number of decimal that is show in printed string such as 2 for .50 in 1,500.50
  • separate_thousands OPTIONAL, 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 00015

Options

  • targetLength is length for padding string
  • padString is 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 15AAA

Options

  • targetLength is length for padding string
  • padString is 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 world

Options

  • editFunction is 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

  • eachFunction is 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 31

Date 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 05

Date 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 2023

License

MIT

3.1.36

2 months ago

3.1.35

3 months ago

3.1.34

4 months ago

3.1.33

4 months ago

3.1.30

4 months ago

3.1.32

4 months ago

3.1.31

4 months ago

3.1.29

5 months ago

3.1.27

5 months ago

3.1.28

5 months ago

3.1.25

5 months ago

3.1.24

5 months ago

3.1.26

5 months ago

3.1.23

5 months ago

3.1.22

5 months ago

3.1.21

5 months ago

3.1.20

5 months ago

3.1.18

5 months ago

3.1.19

5 months ago

3.1.12

9 months ago

3.1.11

9 months ago

3.1.14

7 months ago

3.1.13

7 months ago

3.1.16

7 months ago

3.1.15

7 months ago

3.1.17

6 months ago

3.1.10

9 months ago

3.1.9

9 months ago

3.1.8

9 months ago

3.1.3

10 months ago

3.1.2

10 months ago

3.1.1

10 months ago

3.1.0

10 months ago

3.1.7

9 months ago

3.1.6

9 months ago

3.1.5

10 months ago

3.0.6

10 months ago

3.1.4

10 months ago

3.0.5

11 months ago

3.0.4

11 months ago

3.0.3

11 months ago

3.0.2

1 year ago

3.0.1

1 year ago

3.0.0

1 year ago