npm package: @kokimin/utils
Description: ### Import
Latest version: 0.0.11

## Usage

### Import

```ts
import _utils from '@kokimin/utils'

// or
import { uniq, orderBy, dateFormat } from '@kokimin/utils'
```

---

## Examples

### Array

```ts
import { uniq, union, head, last } from '@kokimin/utils'

uniq([1, 2, 2, 3])        // [1, 2, 3]
union([1, 2], [2, 3])     // [1, 2, 3]
head([10, 20, 30])        // 10
last([10, 20, 30])        // 30
```

---

### Collection

```ts
import { sortBy, orderBy } from '@kokimin/utils'

orderBy(
  [
    { name: 'Tom', age: 30 },
    { name: 'Jane', age: 20 }
  ],
  ['age'],
  ['asc']
)
```

---

### Date (Dayjs-based)

```ts
import { dateFormat, searchDefaultDate } from '@kokimin/utils'

dateFormat(new Date(), 'YYYY-MM-DD')

searchDefaultDate('thisMonth')
// ['2025-12-01', '2025-12-31']
```

---

### Formatter

```ts
import { currencyFormatter, phoneFormatter } from '@kokimin/utils'

currencyFormatter(1234567)      // "1,234,567"
phoneFormatter('01012341234')   // "010-1234-1234"
```

---

### Object

```ts
import { omit, has, merge } from '@kokimin/utils'

omit({ a: 1, b: 2 }, 'b')        // { a: 1 }
has({ a: { b: 1 } }, 'a.b')      // true
merge({ a: 1 }, { b: 2 })        // { a: 1, b: 2 }
```

---

### String

```ts
import { padStart, trim } from '@kokimin/utils'

padStart('5', 3, '0')            // "005"
trim('  hello  ')                // "hello"
```

---

### Number

```ts
import { random, numberArrayMax } from '@kokimin/utils'

random(1, 10)
numberArrayMax([3, 9, 5])        // 9
```

---

### Clone & Validation

```ts
import { cloneDeep, isEmpty } from '@kokimin/utils'

cloneDeep({ a: 1 })
isEmpty({})                      // true
```

---

### UI Alerts (SweetAlert2)

```ts
import { alert, confirm, toastSuccess } from '@kokimin/utils'

await alert('Notice', 'Saved successfully')

const ok = await confirm('Confirm', 'Delete this item?')

toastSuccess('Success', 'Completed')
```

---

## API

### Array

* `concat(array, ...values)`
* `uniq(array)`
* `union(...arrays)`
* `intersection(...arrays)`
* `head(array)`
* `last(array)`
* `flattenDeep(array)`
* `flattenDeepAll(array, key?, child?)`

---

### Collection

* `sortBy(collection, iteratees)`
* `orderBy(collection, iteratees, orders?)`

---

### Common

* `generateUuid(v?: 'v1' | 'v4')`
* `generateRandomNumber(min?, max?)`
* `trimStringByByte(str, byteLength)`
* `getByteLength(str)`

---

### Date

* `dateFormat(date, format?)`
* `quarter(date)`
* `calculateDay(options?)`
* `searchDefaultDate(type?)`

---

### Formatter

* `currencyFormatter(value, precision?)`
* `phoneFormatter(phone?)`

---

### Object

* `assign(object, ...sources)`
* `merge(object, ...sources)`
* `has(object, path)`
* `omit(object, paths)`
* `objectEmptyRemove(object)`

---

### String

* `padStart(string, targetLength, padString?)`
* `replace(string, pattern, replacement)`
* `trim(string, chars?)`

---

### Number

* `random(lower?, upper?, floating?)`
* `numberArrayMax(arr)`

---

### Alert

* `alert(title, content)`
* `confirm(title, content)`
* `toastSuccess(title, content?)`
* `toastError(title, content?)`
* `close()`

---

## Default Export

All utilities are also available via default export:

```ts
import _utils from '@kokimin/utils';

_utils.dateFormat(new Date())
_utils.toastSuccess('Done')
```

---

## TypeScript Support

* Built-in `.d.ts`
* Generic-friendly APIs
* No additional configuration required

---

## License

MIT © kokimin