open-index/open-npm huggingface dataset:
npm package: @fvilers/are-same
Description: A TypeScript helper function that compare arguments for sameness
Author: Fabian Vilers
Latest version: 2.0.0

# @fvilers/are-same

A TypeScript helper function that compare arguments for sameness

## Installation

```
npm install @fvilers/are-same
```

or

```
yarn add @fvilers/are-same
```

# ECMAScript module

Starting with version 2.0.0, this library will be published as an ECMAScript module.

## Usage

```ts
import { areSame } from "@fvilers/are-same";

const x = {
  dob: new Date(2022, 5, 1, 9, 34),
  foo: "bar",
  n: 42,
  score: { values: [0, 1, 1, 2, 3, 5] },
};
const y = {
  dob: new Date(2022, 5, 1, 9, 34),
  foo: "bar",
  n: 42,
  score: { values: [0, 1, 1, 2, 3, 5] },
};

console.log("'x' and 'y' are", areSame(x, y) ? "the same" : "different");
```

```
'x' and 'y' are the same
```
npm package: @fvilers/assert
Description: A TypeScript type guard to asserts that the given value is not undefined nor null
Author: Fabian Vilers
Latest version: 2.0.0

# @fvilers/assert

A TypeScript type guard to asserts that the given value is not undefined nor null

## Installation

```
npm install @fvilers/assert
```

or

```
yarn add @fvilers/assert
```

# ECMAScript module

Starting with version 2.0.0, this library will be published as an ECMAScript module.

## Usage

```ts
import { assert } from "@fvilers/assert";

const foo = null;

assert(foo);
```

Will throw an error

```
Uncaught Error: `value` is null
```
npm package: @fvilers/cls
Description: An helper function for constructing className strings conditionally
Author: Fabian Vilers
Latest version: 2.0.0

# @fvilers/cls

An helper function for constructing className strings conditionally

## Installation

```
npm install @fvilers/cls
```

or

```
yarn add @fvilers/cls
```

# ECMAScript module

Starting with version 2.0.0, this library will be published as an ECMAScript module.

## Usage

```ts
import cls from "@fvilers/cls";

// Strings (variadic)
cls("foo", true && "bar", "baz");
// It will output: 'foo bar baz'

// Objects
cls({ foo: true, bar: false, baz: isTrue() });
// It will output: 'foo baz'

// Objects (variadic)
cls({ foo: true }, { bar: false }, null, { "--foobar": "hello" });
// It will output: 'foo --foobar'

// Arrays
cls(["foo", 0, false, "bar"]);
// It will output: 'foo bar'

// Arrays (variadic)
cls(["foo"], ["", 0, false, "bar"], [["baz", [["hello"], "there"]]]);
// It will output: 'foo bar baz hello there'

// Kitchen sink (with nesting)
cls(
  "foo",
  [1 && "bar", { baz: false, bat: null }, ["hello", ["world"]]],
  "cya"
);
// It will output: 'foo bar hello world cya'
```
npm package: @fvilers/debounce
Description: A TypeScript friendly function debouncer
Author: Fabian Vilers
Latest version: 1.0.0

# @fvilers/debounce

A TypeScript friendly function debouncer

## Installation

```
npm install @fvilers/debounce
```

or

```
yarn add @fvilers/debounce
```

## Usage

```ts
import { debounce } from "@fvilers/debounce";

function doWork(id: number) {
  console.log("Working on", id);
}

const debounced = debounce(doWork, 1000);

debounced(1);
debounced(2);
debounced(3);
debounced(4);
```

It will output (after approximately 1000 ms):

```
Working on 4
```
npm package: @fvilers/disable-react-devtools
Description: A simple method to disable the React Developer Tools addon to access your application
Author: Fabian Vilers
Latest version: 1.3.0

# disable-react-devtools

A simple method to disable the React Developer Tools addon to access your application

## Support

If you use and like this library, feel free to support my Open Source projects.

[![donate](https://www.paypalobjects.com/en_US/BE/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=JZ26X897M9V9L&currency_code=EUR)

## How to install

```
npm i @fvilers/disable-react-devtools
```

or

```
yarn add @fvilers/disable-react-devtools
```

## How to use

Call the `disableReactDevTools()` method before React is loaded, in your main file.

```
import React from 'react';
import ReactDOM from 'react-dom';
import { disableReactDevTools } from '@fvilers/disable-react-devtools';
import App from './App';

if (process.env.NODE_ENV === 'production') {
  disableReactDevTools();
}

ReactDOM.render(<App />, document.getElementById('root'));

```

## How it works

The `disableReactDevTools()` method will look for the React Developer Tools global hook and replace its properties and methods to prevent the plugin registration process.
npm package: @fvilers/disposable
Description: Provide a mechanism for releasing resources
Author: Fabian Vilers
Latest version: 2.1.1

# disposable

Provide a mechanism for releasing resources

## Installation

```
npm install @fvilers/disposable
```

or

```
yarn add @fvilers/disposable
```

# ECMAScript module

Starting with version 2.0.0, this library will be published as an ECMAScript module.

## Usage

```ts
import { Disposable, using } from "@fvilers/disposable";

class Foo implements Disposable {
  doSomething() {
    console.log("I'm doing something");
  }

  dispose() {
    console.log("I'm now disposed");
  }
}

using(new Foo(), (foo) => {
  foo.doSomething();
});
```

```
Hello, world!
I'm now disposed
```
npm package: @fvilers/fetch-interceptor
Description: An helper function to create and register interceptors on fetch
Author: Fabian Vilers
Latest version: 1.1.0

# @fvilers/fetch-interceptor

An helper function to create and register interceptors on fetch

## Usage

```ts
import { applyInterceptor, Interceptor } from "@fvilers/fetch-interceptor";

// Simply add a custom header to the request
const addCustomHeader =
  (key: string, value: string): Interceptor =>
  (fetch) =>
  (input, init) =>
    fetch(input, { ...init, headers: { ...init?.headers, [key]: value } });

// Log elapsed time during request fetching
const logElapsedTime: Interceptor = (fetch) => async (input, init) => {
  const start = performance.now();
  const result = await fetch(input, init);
  const elapsedTime = performance.now() - start;

  console.log("Elapsed time", elapsedTime, "ms");

  return result;
};

// Apply the interceptors on the original fetch implementation
window.fetch = applyInterceptor(
  addCustomHeader("X-Test", "42"),
  logElapsedTime
)(window.fetch);
```

## Premade interceptors

### setHeader

This interceptor accepts as parameters a `key` (string) and `value` (string) that you want to add to the headers collection. By default, it won't overwrite an existing value but you can force it using the third parameter: `overwrite` (boolean).

```ts
import { applyInterceptor } from "@fvilers/fetch-interceptor";
import {
  setHeader,
  SetBehavior,
} from "@fvilers/fetch-interceptor/premade/setHeader";

window.fetch = applyInterceptor(
  setHeader("X-Test", "42", SetBehavior.Overwrite)
)(window.fetch);
```

### observePerformance

This interceptor accepts a callback as a parameter. The callback function accepts a `start` and `end` parameters which correspond to the `performance.now()` value at the start and the end of the fetch execution.

```ts
import { applyInterceptor } from "@fvilers/fetch-interceptor";
import {
  observePerformance,
  PerformanceCallback,
} from "@fvilers/fetch-interceptor/premade/observePerformance";

const onPerformanceObserved: PerformanceCallback = (start, end) => {
  const elapsedTime = end - start;
  console.log("Elapsed time", elapsedTime, "ms");
};

window.fetch = applyInterceptor(observePerformance(onPerformanceObserved))(
  window.fetch
);
```
npm package: @fvilers/force-transfer
Description: A JavaScript helper to force downloading file in the browser
Author: Fabian Vilers
Latest version: 1.0.0

# force-transfer

A JavaScript helper to force downloading file in the browser

## How to install

```
npm install @fvilers/force-transfer
```

or

```
yarn add @fvilers/force-transfer
```

## How to use

```
const forceDownload = require('@fvilers/force-transfer');

forceDownload('https://somewhere.org/document.pdf', 'A file to download');
```
npm package: @fvilers/heroicons-svelte
Description: Beautiful hand-crafted SVG icons, by the makers of Tailwind CSS (for Svelte)
Author: Fabian Vilers
Latest version: 2.1.5-fix.3

<p align="center">
  <a href="https://heroicons.com" target="_blank">
    <picture>
      <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/tailwindlabs/heroicons/HEAD/.github/logo-dark.svg">
      <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/tailwindlabs/heroicons/HEAD/.github/logo-light.svg">
      <img alt="Heroicons" width="315" height="117" style="max-width: 100%" src="https://raw.githubusercontent.com/tailwindlabs/heroicons/HEAD/.github/logo-light.svg">
    </picture>
  </a>
</p>

<p align="center">Beautiful hand-crafted SVG icons, by the makers of Tailwind CSS.<p>

<p align="center">
  <a href="https://heroicons.com"><strong>Browse at Heroicons.com &rarr;</strong></a>
</p>

## Basic Usage

First, install `@fvilers/heroicons-svelte` from npm:

```sh
npm install @fvilers/heroicons-svelte
```

Now each icon can be imported individually as a Svelte component:

```html
<script lang="ts">
  import { BeakerIcon } from "@fvilers/heroicons-svelte/24/solid";
</script>

<div>
  <BeakerIcon className="size-6 text-blue-500" />
  <p>...</p>
</div>
```

The 24x24 outline icons can be imported from `@fvilers/heroicons-svelte/24/outline`, the 24x24 solid icons can be imported from `@fvilers/heroicons-svelte/24/solid`, the 20x20 solid icons can be imported from `@fvilers/heroicons-svelte/20/solid`, and 16x16 solid icons can be imported from `@fvilers/heroicons-svelte/16/solid`.

Icons use an upper camel case naming convention and are always suffixed with the word `Icon`.

[Browse the full list of icon names on UNPKG &rarr;](https://unpkg.com/browse/@fvilers/heroicons-svelte/24/outline/)

## License

This library is MIT licensed.
npm package: @fvilers/is-boolean
Description: A TypeScript type guard that validates if the given value is a boolean
Author: Fabian Vilers
Latest version: 2.0.0

# @fvilers/is-boolean

A TypeScript type guard that validates if the given value is a boolean

## Installation

```
npm install @fvilers/is-boolean
```

or

```
yarn add @fvilers/is-boolean
```

# ECMAScript module

Starting with version 2.0.0, this library will be published as an ECMAScript module.

## Usage

```ts
import { isBoolean } from "@fvilers/is-boolean";

const variable: any = true;

if (isBoolean(variable)) {
  // From here, variable is strongly typed as a boolean
  console.log("Variable is a boolean that returns", variable);
} else {
  console.log("Variable is not a boolean");
}
```

It will output:

```
Variable is a boolean that returns true
```
npm package: @fvilers/is-date
Description: A TypeScript type guard that validates if the given value is a Date
Author: Fabian Vilers
Latest version: 2.0.2

# @fvilers/is-date

A TypeScript type guard that validates if the given value is a Date

## Installation

```
npm install @fvilers/is-date
```

or

```
yarn add @fvilers/is-date
```

# ECMAScript module

Starting with version 2.0.0, this library will be published as an ECMAScript module.

## Usage

```ts
import { isDate } from "@fvilers/is-date";

const variable: any = new Date("December 17, 1995 03:24:00");

if (isDate(variable)) {
  // From here, variable is strongly typed as a string
  console.log("Variable is a date set to", variable);
} else {
  console.log("Variable is not a date");
}
```

It will output:

```
Variable is a date set to Sun Dec 17 1995 03:24:00 GMT+0100 (Central European Standard Time)
```
npm package: @fvilers/is-function
Description: A TypeScript type guard that validates if the given value is a function
Author: Fabian Vilers
Latest version: 2.0.0

# @fvilers/is-function

A TypeScript type guard that validates if the given value is a function

## Installation

```
npm install @fvilers/is-function
```

or

```
yarn add @fvilers/is-function
```

# ECMAScript module

Starting with version 2.0.0, this library will be published as an ECMAScript module.

## Usage

```ts
import { isFunction } from "@fvilers/is-function";

const variable: any = (): string => {
  return "Hello, world!";
};

if (isFunction(variable)) {
  // From here, variable is strongly typed as a function
  console.log("Variable is a function that returns", variable());
} else {
  console.log("Variable is not a function");
}
```

It will output:

```
Variable is a function that returns Hello, world!
```
npm package: @fvilers/is-map
Description: A TypeScript type guard that validates if the given value is a Map
Author: Fabian Vilers
Latest version: 2.0.0

# @fvilers/is-map

A TypeScript type guard that validates if the given value is a Map

## Installation

```
npm install @fvilers/is-map
```

or

```
yarn add @fvilers/is-map
```

# ECMAScript module

Starting with version 2.0.0, this library will be published as an ECMAScript module.

## Usage

```ts
import { isMap } from "@fvilers/is-map";

const variable: any = new map();

if (isMap(variable)) {
  // From here, variable is strongly typed as a map
  console.log("Variable is a map with size of", map.size);
} else {
  console.log("Variable is not a map");
}
```

```
Variable is a map with size of 0
```
npm package: @fvilers/is-nil
Description: A TypeScript type guard that validates if the given value is nil
Author: Fabian Vilers
Latest version: 1.1.0

# is-nil

A TypeScript type guard that validates if the given value is nil

## Installation

```
npm install @fvilers/is-nil
```

or

```
yarn add @fvilers/is-nil
```

## Usage

```ts
import { isNil, isNotNil } from "@fvilers/is-nil";

const variable: string | null = "This is a string";

if (isNil(variable)) {
  console.log("Variable is null");
} else {
  // From here, variable is strongly typed as a non null string
  console.log("Variable is a string with length of", variable.length);
}

if (isNotNil(variable)) {
  // From here, variable is strongly typed as a non null string
  console.log("Variable is a string with length of", variable.length);
} else {
  console.log("Variable is null");
}
```

It will output:

```
Variable is a string with length of 16
Variable is a string with length of 16
```
npm package: @fvilers/is-number
Description: A TypeScript type guard that validates if the given value is a number
Author: Fabian Vilers
Latest version: 2.0.0

# @fvilers/is-number

A TypeScript type guard that validates if the given value is a string

## Installation

```
npm install @fvilers/is-number
```

or

```
yarn add @fvilers/is-number
```

# ECMAScript module

Starting with version 2.0.0, this library will be published as an ECMAScript module.

## Usage

```ts
import isNumber from "@fvilers/is-number";

const variable: any = 42;

if (isNumber(variable)) {
  // From here, variable is strongly typed as a number
  console.log(
    "Variable is a number with an exponential value of",
    variable.toExponential(10)
  );
} else {
  console.log("Variable is not a number");
}
```

It will output:

```
Variable is a number with an exponential value of 4.2000000000e+1
```
npm package: @fvilers/is-object
Description: A TypeScript type guard that validates if the given value is an object
Author: Fabian Vilers
Latest version: 2.0.0

# @fvilers/is-object

A TypeScript type guard that validates if the given value is an object

## Installation

```
npm install @fvilers/is-object
```

or

```
yarn add @fvilers/is-object
```

# ECMAScript module

Starting with version 2.0.0, this library will be published as an ECMAScript module.

## Usage

```ts
import { isObject } from "@fvilers/is-object";

const variable: any = { hello: "world" };

if (isObject(variable)) {
  // From here, variable is strongly typed as an object
  console.log(
    "Variable is an object with key(s)",
    Reflect.ownKeys({ hello: "world" })
  );
} else {
  console.log("Variable is not an object");
}
```

It will output:

```
Variable is an object with key(s) [ 'hello' ]
```
npm package: @fvilers/is-prod
Description: An helper method that returns true if the process use the production environment
Author: Fabian Vilers
Latest version: 2.0.0

# @fvilers/is-prod

An helper method that returns true if the process use the production environment

## Installation

```
npm install @fvilers/is-prod
```

or

```
yarn add @fvilers/is-prod
```

# ECMAScript module

Starting with version 2.0.0, this library will be published as an ECMAScript module.

## Usage

```ts
import isProd from "@fvilers/is-prod";

console.log(isProd());
```

It will output (if the `NODE` environment variable is set to `production`):

```
true
```
npm package: @fvilers/is-reg-exp
Description: A TypeScript type guard that validates if the given value is a RegExp
Author: Fabian Vilers
Latest version: 1.0.1

# @fvilers/is-reg-exp

A TypeScript type guard that validates if the given value is a RegExp

## Installation

```
npm install @fvilers/is-reg-exp
```

or

```
yarn add @fvilers/is-reg-exp
```

## Usage

```ts
import isRegExp from "@fvilers/is-reg-exp";

const variable: any = /This is a regexp/;

if (isRegExp(variable)) {
  // From here, variable is strongly typed as a string
  console.log(
    "Variable is a reg exp that",
    variable.test("This is a regexp") ? "matches" : "does not  match",
    "the provided string"
  );
} else {
  console.log("Variable is not a reg exp");
}
```

It will output:

```
Variable is a reg exp that matches the provided string
```
npm package: @fvilers/is-set
Description: A TypeScript type guard that validates if the given value is a Set
Author: Fabian Vilers
Latest version: 2.0.1

# @fvilers/is-set

A TypeScript type guard that validates if the given value is a Set

## Installation

```
npm install @fvilers/is-set
```

or

```
yarn add @fvilers/is-set
```

# ECMAScript module

Starting with version 2.0.0, this library will be published as an ECMAScript module.

## Usage

```ts
import { isSet } from "@fvilers/is-set";

const variable: any = new Set();

if (isSet(variable)) {
  // From here, variable is strongly typed as a Set
  console.log("Variable is a set with size of", set.size);
} else {
  console.log("Variable is not a set");
}
```

```
Variable is a set with size of 0
```
npm package: @fvilers/is-string
Description: A TypeScript type guard that validates if the given value is a string
Author: Fabian Vilers
Latest version: 2.0.0

# @fvilers/is-string

A TypeScript type guard that validates if the given value is a string

## Installation

```
npm install @fvilers/is-string
```

or

```
yarn add @fvilers/is-string
```

# ECMAScript module

Starting with version 2.0.0, this library will be published as an ECMAScript module.

## Usage

```ts
import { isString } from "@fvilers/is-string";

const variable: any = "This is a string";

if (isString(variable)) {
  // From here, variable is strongly typed as a string
  console.log("Variable is a string with length of", variable.length);
} else {
  console.log("Variable is not a string");
}
```

It will output:

```
Variable is a string with length of 16
```
npm package: @fvilers/listen-once
Description: A Node.js web server that listen only once
Author: Fabian Vilers
Latest version: 1.0.0

# listen-once

A Node.js web server that listen only once

## Purpose

This library expose a simple method that spins a web server that accept only one request. It can be used to retrieve a query string parameter or body from a authorization redirect (OAuth 2 for example).

# ECMAScript module

This library is published as an ECMAScript module.

## Usage

```typescript
import http from "node:http";
import { listenOnce } from "@fvilers/listen-once";

const PORT = 3000;
const HOSTNAME = "localhost";

function onListening() {
  console.log("Server listening on", `http://${HOSTNAME}:${PORT}`);
}

function onRequest(req: http.IncomingMessage, res: http.ServerResponse) {
  console.log("Incoming request", req.url);

  // TODO: do something with the request

  res.statusCode = 200;
  res.end();
}

await listenOnce(PORT, HOSTNAME, onListening, onRequest);

console.log("Server closed");
```
npm package: @fvilers/mongoose-shortid
Description: A Mongoose plugin that adds a virtual property with a shorter document ID
Author: Fabian Vilers
Latest version: 1.1.0

# mongoose-shortid

A Mongoose plugin that adds a virtual property with a shorter document ID

## How to install

```
npm install @fvilers/mongoose-shortid
```

or

```
yarn add @fvilers/mongoose-shortid
```

## How to use

```
const mongoose = require('mongoose');
const shortId = require('@fvilers/mongoose-shortid');

// This will add a virtual property `shortId` to all schemas
mongoose.plugin(shortId);
```

## Options

You can choose the name of the virtual property by passing an option object and specifying the `propertyName` key.

```
const mongoose = require('mongoose');
const shortId = require('@fvilers/mongoose-shortid');

// This will add a virtual property `myProperty` to all schemas
mongoose.plugin(shortId, { propertyName: 'myProperty' });
```

## How does it work

The generated ObjectId will be transformed into a base62 representation which is url-safe as it doesn't contain characters like `+` or `/`. For example, a value of `5c614931a1f4b30021fa212b` will be transformed to a shortId value of `BbkLuPjY756F4VMT`.
npm package: @fvilers/normalize-port
Description: An helper function to normalize a port number expressed as a string
Author: Fabian Vilers
Latest version: 2.0.0

# @fvilers/normalize-port

An helper function to normalize a port number expressed as a string

## Installation

```
npm install @fvilers/normalize-port
```

or

```
yarn add @fvilers/normalize-port
```

# ECMAScript module

Starting with version 2.0.0, this library will be published as an ECMAScript module.

## Usage

```ts
import { normalizePort } from "@fvilers/normalize-port";

const port = normalizePort(process.env.PORT || "3000");
app.set("port", port); // `app` is an express app
```