# ckn.core

> CKN Framework

Latest version **3.1.36** (published 2024-03-24) · ISC license · 0 weekly downloads

## Install

```sh
npm install ckn.core
pnpm add ckn.core
yarn add ckn.core
bun add ckn.core
```

Provides the command `ckn`.

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.1.36 |
| Published | 2024-03-24 |
| First published | 2023-05-14 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 54 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Santi Chongkaonar |
| Maintainers | santi.chongkaonar |
| Keywords | CKN |

## Links

- npm: https://www.npmjs.com/package/ckn.core
- npm.io page: https://npm.io/package/ckn.core

## Dependencies (1)

- [prompts](https://npm.io/package/prompts.md) ^2.4.2

## Recent versions

- 3.1.36 (latest) — 2024-03-24
- 3.1.35 — 2024-02-21
- 3.1.34 — 2024-02-01
- 3.1.33 — 2024-01-28
- 3.1.32 — 2024-01-14
- 3.1.31 — 2024-01-14
- 3.1.30 — 2024-01-14
- 3.1.29 — 2024-01-07
- 3.1.28 — 2024-01-02
- 3.1.27 — 2024-01-02
- 3.1.26 — 2024-01-02
- 3.1.25 — 2024-01-02
- 3.1.24 — 2024-01-02
- 3.1.23 — 2023-12-27
- 3.1.22 — 2023-12-23
- … 29 more at https://npm.io/package/ckn.core/versions

## README

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

```bash
npm install ckn.core
```

## Numeric tools - round

CKN Core provide round function for all numeric variable to round the decimal.

```javascript
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.

```javascript
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.

```javascript
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".

```javascript
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.

```javascript
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.

```javascript
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.

```javascript
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

```javascript
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

```javascript
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

```javascript
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

```javascript
import {ckn} from 'ckn.core'

let date = new Date(2023, 4, 31); // 31 May 2023

console.log(date.year());
// output is 2023
```

## License

[MIT](https://choosealicense.com/licenses/mit/)

---
_Source: https://npm.io/package/ckn.core · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
