open-index/open-npm huggingface dataset:
npm package: @neodx/fs
Description: File system helpers
Latest version: 0.0.13

# @neodx/fs

File system enhancements and common stuff.

API`s overview:

- `scan(path, ['*.js', '*.module.ts', '!*.test.{ts,js}'])` - glob reader with multiple inputs support
- `ensureDir(path)`, `ensureFile(path)` - Safe file/dir creation with all required ancestors
- `exists(path)`, `isFile(path)`, `isDirectory(path)` - Safe path checks
- `deepReadDir(path)` - Deep version of `readdir`
- `parseJson(input)`, `serializeJson(input)` - Safe JSON parser and serializer with [JSONC](https://www.npmjs.com/package/jsonc-parser) support
- `getFileHash(path)`, `getHash(content)` - Returns file hash based on its content (HEX)

## API

### scan

Glob-based (via [tiny-glob](https://www.npmjs.com/package/tiny-glob)) multiple patterns scanner with exclusion support

```typescript
import { scan } from '@neodx/fs';

await scan(process.cwd(), ['*.js', '!*.config.js']);
await scan(process.cwd(), '**/*.ts', '**/*.js');
```

### `ensureFile(path)` and `ensureDir(path)`

Recursively creates missed file or dir with all required ancestors if one of them is not exists.

Automatically avoid duplicated calls:

```typescript
import { ensureFile, ensureDir } from '@neodx/fs';

// Everything works as expected
await Promise.all([
  ensureDir('foo/baz'),
  ensureFile('foo/bar/2.ts'),
  ensureDir('foo/bar'),
  ensureFile('foo/bar/1.ts'),
  ensureDir('foo')
]);
```

### `isFile`, `isDirectory`, `exists`

The following APIs are useful for safe paths checking.

- `exists(path)` - Returns `true` if the path exists
- `isFile(path)` - Returns `true` if the path exists, and it's a file
- `isDirectory(path)` - Returns `true` if the path exists, and it's a directory

### `deepReadDir(path, { absolute = false })`

Returns flat list with all children's paths. Paths are relative by default.

```typescript
import { deepReadDir, isFile } from '@neodx/fs';

const files = await deepReadDir(myPath);

for (const file of files) {
  if (await isFile(file)) {
    await doSmth(file);
  }
}
```

### `parseJson` and `serializeJson`

```typescript
import { parseJson, serializeJson } from '@neodx/fs';
import { writeFile, readFile } from 'fs/promises';

const json = parseJson(await readFile('tsconfig.json', 'utf-8'));

await writeFile(
  'tsconfig.json',
  serializeJson({
    ...json,
    compilerOptions: {
      ...json.compilerOptions,
      target: 'esnext'
    }
  }),
  'utf-8'
);
```

---

Inspired by fs-extra and others.
npm package: @neodx/pkg-misc
Description: Collection of utilities for common cases in package development - smart dependencies updates, simple formatting with auto-detection of prettier config, etc.
Latest version: 0.0.11

# @neodx/pkg-misc

> Work in progress, for internal purposes for now

Multiple utilities for common packages tasks:

- Add/Remove dependencies
- Format with Prettier
- Check semver

## Installation

```bash
# yarn
yarn add @neodx/pkg-misc
# pnpm
pnpm add @neodx/pkg-misc
# npm
npm install @neodx/pkg-misc
```

## Usage

### addPackageJsonDependencies

```typescript
import { addPackageJsonDependencies } from '@neodx/pkg-misc';

addPackageJsonDependencies({ dependencies: { a: '^1.2.3' } }, { dependencies: { a: '^1.2.0' } });
// null (no changes)
addPackageJsonDependencies(
  { dependencies: { a: '^1.2.3' } },
  { dependencies: { a: '^1.2.0', b: '^1.2.0' } }
);
// { dependencies: { a: '^1.2.3', b: '^1.2.0' } } (added b)
addPackageJsonDependencies(
  { dependencies: { a: '^1.2.3' } },
  { dependencies: { a: '^1.3.0', b: '^2.0.0' } }
);
// { dependencies: { a: '^1.3.0', b: '^2.0.0' } } (updated a, added b)
```

> WIP
npm package: @neodx/std
Description: Standard language helpers
Latest version: 0.4.0

# @neodx/std

This package contains a set of utilities that are used by other packages in the
`@neodx` namespace.

Currently, is not intended to be used directly by the end user.

But! Let me show one powerful API - `toCase`, all-in-one function for formatting case of strings.

> Inspired by [casex](https://github.com/dxtr-dot-dev/casex)

```typescript
import { toCase } from '@neodx/std';

const str = 'I want_to change-case';

toCase(str, 'ca_se'); // i_want_to_change_case
toCase(str, 'caSe'); // iWantToChangeCase
toCase(str, 'CaSe'); // IWantToChangeCase
toCase(str, 'CA_SE'); // I_WANT_TO_CHANGE_CASE
toCase(str, 'Ca se'); // I want to change case
```

I think you got the idea 🤓