open-index/open-npm huggingface dataset:
npm package: @kccd/nkc-utils
Description: Utility helpers with separate browser and Node.js entry behavior.
Latest version: 0.0.6
Deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

# nkc-utils

A small utility library with separate browser and Node.js entry behavior.

## Installation

```bash
npm install nkc-utils
```

## Usage

### Browser / universal usage

```ts
import { pureJsMethod, sharedUtil, nodeOnlyMethod } from "nkc-utils";

console.log(pureJsMethod("world"));
console.log(sharedUtil(1, 2));

try {
  nodeOnlyMethod();
} catch (error) {
  console.error(error);
}
```

### Node.js usage

```ts
import { pureJsMethod, sharedUtil, nodeOnlyMethod } from "nkc-utils";

console.log(pureJsMethod("world"));
console.log(sharedUtil(1, 2));

const result = await nodeOnlyMethod("./example.txt");
console.log(result);
```

## API

### `pureJsMethod(name: string): string`

Returns a greeting string.

### `sharedUtil(a: number, b: number): number`

Returns the sum of two numbers.

### `nodeOnlyMethod(...)`

- In Node.js: reads a file and returns a success message
- In the browser: throws an error to indicate the API is not available there

## Package behavior

This package uses conditional exports:

- Node.js gets the Node-specific build
- Browser environments get the browser-safe build by default

## Development

```bash
npm install
npm run build
```