open-index/open-npm huggingface dataset:
npm package: @papb/assorted-ts-utils
Description: Personal collection of assorted TypeScript utility types
Author: Pedro Augusto de Paula Barbosa
Latest version: 2.0.0

# @papb/assorted-ts-utils ![Build Status](https://github.com/papb/assorted-ts-utils/workflows/CI/badge.svg)

> Personal collection of assorted TypeScript utility types


## Highlights

* `StrictEqual<A, B>`
* `IfAny<T, ThenType, ElseType>`
* `IfUnknown<T, ThenType, ElseType>`
* `IfNever<T, ThenType, ElseType>`
* `ParseArray<A, B>`
* `SetKeyType<BaseType, Key, NewType, AsOptional>`
* `ReplaceKeyType<BaseType, Key, NewType, AsOptional>`


## Install

```
$ npm install @papb/assorted-ts-utils
```


## Usage

```ts
import {
	StrictEqual,
	ReplaceKeyType,
	ParseArray,
	ReplaceAllTypeOccurrences,
	IfAny,
	IfNever
} from '@papb/assorted-ts-utils';

import {
	tsAssertTrue,
	tsAssertTypeAcceptsValue,
	tsAssertTypesExactlyEqual,
	tsAssertExtends
} from '@papb/assorted-ts-utils/assert';

type T1 = StrictEqual<{ a: 1 }, { a: 1 }>;
//=> type T1 = true

type T2 = StrictEqual<{ a: 1 }, { a: 1; b: undefined }>;
//=> type T2 = false

type T3 = ReplaceKeyType<
	{ foo: string; bar: number },
	'bar',
	Date,
	true
>;
//=> type T3 = { foo: string; bar?: Date }

type T4 = StrictEqual<
	ParseArray<readonly [string, Date, number, null, ...boolean[]]>,
	{
		isReadonly: true;
		first: string;
		last: boolean;
		minLength: 4;
		maxLength: undefined;
		tuplePrefix: readonly [string, Date, number, null];
		arrayTail: readonly boolean[];
	}
>;
//=> type T4 = true

tsAssertTrue<T4>(); // Compiles without error
tsAssertTrue<T2>(); // Does not compile

type T5 = ReplaceAllTypeOccurrences<
	{ foo: string; bar: () => string },
	string,
	number
>;
//=> type T5 = { foo: number; bar: () => number }

type T6 = IfAny<any, 'hello', 'world'>;
//=> type T6 = 'hello';

type T7 = IfAny<unknown, 'hello', 'world'>;
//=> type T7 = 'world';

type T8 = IfNever<1 & 2, 'hello', 'world'>;
//=> type T8 = 'hello';

type T9 = { a: string; b: string | number };
const someValue =
	tsAssertTypeAcceptsValue()<T9>()(
		// Autocomplete for `a` and `b` available on the object below
		{ a: 'hello', b: 123 } as const
	);
tsAssertTypesExactlyEqual()<typeof someValue>()<{ a: 'hello'; b: 123 }>();
tsAssertExtends()<typeof someValue>()<T9>();
```


## Documentation

TODO


## License

MIT © [Pedro Augusto de Paula Barbosa](https://github.com/papb)
npm package: @papb/linter
Description: My custom linter configs and dependencies collected in one place to avoid repetition.
Author: Pedro Augusto de Paula Barbosa
Latest version: 0.4.4

# @papb/linter

> My custom linter configs and dependencies collected in one place to avoid repetition.

## Why?

Until some time ago I was just using [XO](https://github.com/xojs/xo) in my repos and overwriting a few rule configurations manually. However, XO now requires the project to be ESM and I don't want to do that. I don't want to stay locked in an old XO version either.

## Install

```bash
# With npm
$ npm install --save-dev eslint@^8 prettier@^2 @papb/linter

# With yarn
$ yarn add --dev eslint@^8 prettier@^2 @papb/linter
```

## Usage

```js
// .eslintrc.cjs
module.exports = require('@papb/linter').eslintrc();

// .prettierrc.cjs
module.exports = require('@papb/linter').prettierrc();
```

```bash
# Will lint all `.js`, `.ts`, `.cjs` and `.md` files.
$ npx eslint . --max-warnings 0

# Will check all `.js`, `.ts`, `.cjs` and `.md` for prettier style.
$ npx prettier --check .

# Will overwrite in-place all `.js`, `.ts`, `.cjs` and `.md` for prettier style.
$ npx prettier --write .
```

**Note:** It is possible for ESLint to pass while `prettier --check` still fails, so you should run both.

Recommended npm scripts:

```json
{
    "scripts": {
        "lint": "eslint . --max-warnings 0 && prettier --check .",
        "prettier": "prettier --write .",
    }
}
```

## License

MIT © [Pedro Augusto de Paula Barbosa](https://github.com/papb)
npm package: @papb/zip
Description: Zipping & unzipping, simplified.
Author: Pedro Augusto de Paula Barbosa
Latest version: 3.0.0

# @papb/zip ![Build Status](https://github.com/papb/zip/workflows/CI/badge.svg)

> Zipping & unzipping, simplified.

## Highlights

* Written in TypeScript
* Cross-platform
* [Simple Promise-based API](https://github.com/papb/zip#api), for your simple zipping needs
* No external binaries needed
* Outputs to temporary folder if you do not specify an output path


## Install

```
$ npm install @papb/zip
```


## Usage

```js
const { zip, zipDirContents, unzip } = require('@papb/zip');

(async () => {
	await zip('path/to/file.txt', 'file.zip');
	await zip('path/to/folder/foo123', 'foo.zip');
	await zipDirContents('path/to/folder/bar', 'bar.zip');
	await unzip('baz.zip', 'path/to/folder/baz');

	// If you don't specify an output path, a temp path is used:
	const zipped = await zip('path/to/folder/foo');
	console.log(zipped);
	//=> '/path/to/some/temp/folder/output.zip'
	const unzipped = await unzip('foo.zip');
	console.log(unzipped);
	//=> '/path/to/some/temp/folder' (which will contain a
	//   single folder called 'foo123' in this example)
})();
```


## TypeScript usage

@papb/zip is written in TypeScript and comes with complete type declarations. This means that you will have great code completions right in your editor, and also means that you can use it perfectly with TypeScript:

```ts
import { zip, zipDirContents, unzip } from '@papb/zip';
// ...
```


## API

### zip(fileOrFolderPath, \[destinationPath\])
> *TypeScript signature:* `zip(fileOrFolderPath: string, destinationPath?: string): Promise<string>`

Creates a zip archive of the given file or folder, saving it in `destinationPath`. If `destinationPath` is not given, the zip file will be saved as `output.zip` in a freshly-created temporary folder.

This async function returns the absolute path to the generated zip file.

### zipDirContents(folderPath, \[destinationPath\])
> *TypeScript signature:* `zipDirContents(folderPath: string, destinationPath?: string): Promise<string>`

Creates a zip archive of the contents of the given folder, saving it in `destinationPath`. If `destinationPath` is not given, the zip file will be saved as `output.zip` in a freshly-created temporary folder.

This async function returns the absolute path to the generated zip file.

### unzip(zipFilePath, \[destinationContainerPath\])
> *TypeScript signature:* `unzip(zipFilePath: string, destinationContainerPath?: string): Promise<string>`

Extracts the zip file in `zipFilePath` into the folder specified in `destinationContainerPath`. If `destinationContainerPath` is not given, a freshly-created temporary folder will be used as container.

This async function returns the absolute path to the destination container folder.


## License

MIT © [Pedro Augusto de Paula Barbosa](https://github.com/papb)