# will-util

> Utility functional

Latest version **1.0.11** (published 2026-02-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install will-util
pnpm add will-util
yarn add will-util
bun add will-util
```

## Health

**Score 55/100 (C)** — status: stable.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 1.0.11 |
| Published | 2026-02-02 |
| First published | 2022-10-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=20 |
| Dependencies | 1 |
| Unpacked size | 59.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | tassun_oro@hotmail.com |
| Maintainers | tassun_oro |
| Keywords | Utilities, Arguments, Iterator, StringTokenizer, Configure |

## Links

- npm: https://www.npmjs.com/package/will-util
- Repository: https://github.com/tassun/will-util
- Homepage: https://github.com/tassun/will-util#readme
- Issues: https://github.com/tassun/will-util/issues
- npm.io page: https://npm.io/package/will-util

## Dependencies (1)

- [crypto-js](https://npm.io/package/crypto-js.md) ^4.2.0

## Alternatives

- [@mce/gif](https://npm.io/package/@mce/gif.md) — 2.6K weekly downloads
- [cleanse](https://npm.io/package/cleanse.md) — 173 weekly downloads
- [str](https://npm.io/package/str.md) — 127 weekly downloads
- [naming](https://npm.io/package/naming.md) — 95 weekly downloads
- [tap-telco-api](https://npm.io/package/tap-telco-api.md) — 19 weekly downloads

## Recent versions

- 1.0.11 (latest) — 2026-02-02
- 1.0.10 — 2025-08-28
- 1.0.9 — 2024-04-24
- 1.0.8 — 2024-04-16
- 1.0.7 — 2023-09-22
- 1.0.6 — 2023-09-13
- 1.0.5 — 2023-08-31
- 1.0.4 — 2023-08-06
- 1.0.3 — 2022-11-11
- 1.0.2 — 2022-11-09
- 1.0.1 — 2022-10-31
- 1.0.0 — 2022-10-30

## README

# will-util

Utilities functional

## Installation

    npm install will-util

### Arguments
Arguments handle for reading parameter value from command line arguments

```typescript
import { Arguments } from "will-util";

let args = process.argv.slice(2);
//this will read from specified arguments with option -user if not defined return tester as default
let user = Arguments.getString(args,'tester','-user');
//this will read from specified arguments with option -p or -pwd if not defined return null as default
let pwd = Arguments.getString(args,null,'-p','-pwd');
//this will read from command line arguments directly
let count = Arguments.getInteger(null,0,'-count');
```

### Iterator
Iterator handle for iterate array of object

```typescript
import { Iterator } from "will-util";

let ary = ["hello","new","world"];
let it = new Iterator<string>(ary);
while(it.hasNext()) {
    console.log(it.next());
}
```

### RandomUtility
Utility for randomize number or alphabets with min/max range

```typescript
import { RandomUtility } from "will-util";

console.log(RandomUtility.getRandomNum(1,10));
console.log(RandomUtility.random(6)); 
console.log(RandomUtility.randomNumber(6));
```

### StringTokenizer
StringTokenizer handle for token raw string with delimiters.

default delimiter is blank or space and new line with no return separator
```typescript
import { StringTokenizer } from "will-util";

let str = "Hello new world";
let token = new StringTokenizer(str);
let result = token.tokenize();
console.log(result); 
//result is [ 'Hello', 'new', 'world' ]
```

specified with delimiter and return separator
```typescript
import { StringTokenizer } from "will-util";

let str = "Hello ? world";
let token = new StringTokenizer(str,"?",true);
let result = token.tokenize();
console.log(result);
//result is [ 'Hello ', '?', ' world' ]
```

### Utilities
The utilities functional

```typescript
import { Utilities } from "will-util";

console.log(Utilities.compareString("AAA","BBB")); // result is -1
console.log(Utilities.compareString("AAA","AAA")); // result is 0
console.log(Utilities.compareString("BBB","AAA")); // result is 1
```

| Function | Description |
| -------- | ----------- |
| getWorkingDir | To get base directory if base name is src or dist. |
| getDateNow | To get date in format dd/MM/yyyy. |
| getTimeNow | To get time in format HH:mm:ss. |
| getDateTimeNow | To get datetime in format dd/MM/yyyy HH:mm:ss. |
| getYMD | To get date in format yyyy-MM-dd. |
| getDMY | To get date in format dd/MM/yyyy. |
| formatDate | To format Date to dd/MM/yyyy or yyyy-MM-dd. |
| formatTime | To format time HH:mm:ss. |
| formatDateTime | To format date into dd/MM/yyyy HH:mm:ss or yyyy-MM-dd HH:mm:ss. |
| getHMS | To format time HH:mm:ss. |
| currentDate | To format Date to yyyy-MM-dd. |
| currentTime | To format time to HH:mm:ss. |
| currentDateTime | To format Date to yyyy-MM-dd HH:mm:ss. |
| currentTimeMillis | To get current time in milli seconds. |
| addDays | To add number of days into Date. |
| compareDate | To compare between date. (returns number, -1 = lesser than, 0 = equal , 1 = greater than)|
| compareTime | To compare between time. (returns number, -1 = lesser than, 0 = equal , 1 = greater than)|
| compareDateTime | To compare between datetime. (returns number, -1 = lesser than, 0 = equal , 1 = greater than)|
| compareString | To compare string value. (returns number, -1 = lesser than, 0 = equal , 1 = greater than)|
| equalsIgnoreCase | To check string equals with ignore case. |
| isString | To check data is string or not. |
| hasAttributes | To check attributes is in object element. |
| parseInteger | To parse integer (especially from string). |
| parseFloat | To parse float (especially from string). |
| parseBoolean | To parse boolean (especially from string). |
| parseDate | To parse Date with data value string in format dd/MM/yyyy, yyyy-MM-dd, dd/MM/yyyy HH:mmss, yyyy-MM-dd HH:mm:ss. |
| now | To get current date/time. |
| translateVariables | To replace all variables in markup ${variable-name}. |

### Configure
Configure class implements for reading config/default.json and environment variables

```typescript
import { Configure } from "will-util";
import config from "will-util";

console.log(Configure.hasConfig("SECTION"));
console.log(Configure.getConfig("SECTION"));
console.log(Configure.getEnv("SECTION"));
console.log(Configure.getEnv("SECTION","TEST"));

console.log(config.has("SECTION"));
console.log(config.get("SECTION"));
console.log(config.env("SECTION"));
console.log(config.env("SECTION","TEST"));
```

`getEnv` and `env` will return environment variables when found or else return value from default.json and default value in order

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