open-index/open-npm huggingface dataset:
npm package: @l31t/reddit-meme-fetcher
Description: A TypeScript library to fetch random memes from Reddit subreddits with proper type definitions, filtering options, and dynamic subreddit management.
Author: TheHellTower
Latest version: 2.1.1

# Reddit-Meme-Fetcher

> ! **Notice**
> This package is just a rewrite of https://github.com/TheHellTower/Reddit-Meme-Fetcher in TypeScript. 
> The original package seemst to be no longer maintained, and this package will not receive any updates.

[![CodeFactor](https://www.codefactor.io/repository/github/thehelltower/reddit-meme-fetcher/badge)](https://www.codefactor.io/repository/github/thehelltower/reddit-meme-fetcher)

## Installation

[![npm package](https://nodei.co/npm/reddit-meme-fetcher.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/reddit-meme-fetcher)<br>
`npm install --save reddit-meme-fetcher`

# Preview
[![](https://i.imgur.com/jDmtbyT.gif)](https://youtu.be/2ZtPQcKcdo0)

# Stargazers
[![Stargazers repo roster for @TheHellTower/Reddit-Meme-Fetcher](https://reporoster.com/stars/dark/notext/TheHellTower/Reddit-Meme-Fetcher)](https://github.com/TheHellTower/Reddit-Meme-Fetcher/stargazers)

# Forkers
[![Forkers repo roster for @TheHellTower/Reddit-Meme-Fetcher](https://reporoster.com/forks/dark/notext/TheHellTower/Reddit-Meme-Fetcher)](https://github.com/TheHellTower/Reddit-Meme-Fetcher/network/members)
npm package: @l3dev/abac
Description: Type-safe attribute-based access control library
Author: l3dotdev
Latest version: 0.3.0

# abac

## Description

A type-safe ABAC library.

## Installation

```bash
npm install @l3dev/abac
```

```bash
pnpm add @l3dev/abac
```

## Example

```ts
import { ABAC } from "@l3dev/abac";

type User = {
	id: string;
	username: string;
	admin: boolean;
};

type Organisation = {
	id: string;
	name: string;
	public: boolean;
	owner: User;
};

// Define ABAC resources

const OrganisationABAC = ABAC.createResource("organisation")
	.withSubject<User>()
	.withObject<Organisation>()
	.setActions([
		ABAC.createAction("create").withoutObject(),
		ABAC.createAction("view.public").addTag("public"),
		ABAC.createAction("join")
			.setTitle("Allow Joining")
			.setDescription("Allow users to join the organisation")
			.setConfigurable(true),
		ABAC.createAction("delete")
	]);

// Define ABAC policies

export const abac = ABAC.create([OrganisationABAC])
	.addPolicy((policy) =>
		policy
			.setName("Admins")
			.setMatch(({ subject }) => "admin" in subject && subject.admin)
			.allowAll()
	)
	.addPolicy((policy) =>
		policy
			.setName("Default")
			.allow("organisation.*", ABAC.Filter.ifgranted())
			.allow("organisation:delete", (ctx) => ctx.subject.id === ctx.object.owner.id)
	);

// Getting tagged actions

abac.getTaggedActions("public");
/* [
	{
		path: "organisation:view.public",
		action: ...,
		own: false
	}
] */

abac.getTaggedActions("configurable");
/* [
	{
		path: "organisation:join",
		action: ...,
		own: false
	}
] */

// Checking permissions

const adminUser: User = {
	id: "1",
	username: "Admin",
	admin: true
};

const myUser: User = {
	id: "2",
	username: "User",
	admin: false
};

const otherUser: User = {
	id: "3",
	username: "Other User",
	admin: false
};

const myOrganisation: Organisation = {
	id: "1",
	name: "My Organisation",
	public: false,
	owner: myUser
};

abac.can(myUser, "organisation:delete").granted(myOrganisation); // true

abac.can(otherUser, "organisation:delete").granted(myOrganisation); // false

abac.can(adminUser, "organisation:delete").granted(myOrganisation); // true
```
npm package: @l3dev/api-result
Description: Result objects for API responses
Author: l3dotdev
Latest version: 0.4.0

# api-result

## Description

An extension of [@l3dev/result](https://www.npmjs.com/package/@l3dev/result) for creating result shaped API responses.

Mainly to be used with @l3dev type-safe api libraries:

- [@l3dev/svelte-api](https://www.npmjs.com/package/@l3dev/svelte-api)

## Installation

```bash
npm install @l3dev/api-result
```

```bash
pnpm add @l3dev/api-result
```

## Documentation

### `ok`

Creates an `OkResponse` object, alias: `ApiResult.ok`

```ts
ok<T>(value: T): OkResponse<T, 200>
ok<T, S>(value: T, status: S): OkResponse<T, S>
```

#### Example

```ts
import { ok } from "@l3dev/api-result";

const result = ok({
	message: "Hello world"
});

result.ok; // true
result.value; // { message: "Hello world" }
result.status; // 200
```

> Use `EMPTY` as a shorthand for a 204 No Content response, it is equivalent to `OkResponse<null, 204>`

### `err`

Create an `ErrResponse` object, alias: `ApiResult.err`

```ts
err<T>(type: T): ErrResponse<T, null, 500>
err<T, S>(type: T, status: S): ErrResponse<T, null, S>
err<T, D>(type: T, context: D): ErrResponse<T, D, 500>
err<T, D, S>(type: T, context: D, status: S): ErrResponse<T, D, S>
```

#### Example

```ts
import { err } from "@l3dev/api-result";

const result = err("error");

result.ok; // false
result.type; // 'error'
result.context; // null
result.status; // 500

const resultNotFound = err("not found", 404);

resultNotFound.ok; // false
resultNotFound.type; // 'not found'
resultNotFound.status; // 404
```

### `Result.fromErr`

Convert an `Err` object into an `ErrResponse`

```ts
fromErr<T, D>(err: Err<T, D>): ErrResponse<T, D, 500>
fromErr<T, D, S>(err: Err<T, D>, status: S): ErrResponse<T, D, S>
```

### `redirect`

Create a `RedirectResponse` object, alias: `ApiResult.redirect`

```ts
redirect<T, S>(url: T, status: S): RedirectResponse<T, S>
```

#### Example

```ts
import { redirect } from "@l3dev/api-result";

const result = redirect("/home", 302);

result.ok; // true
result.redirect; // true
result.value; // { target: "/home" }
result.status; // 302
```

### `ApiResult.isOk`

Returns `true` if the result is an `OkResponse` object

```ts
isOk(result: ResponseResult<...>): boolean
```

### `ApiResult.isErr`

Returns `true` if the result is an `ErrResponse` object

```ts
isErr(result: ResponseResult<...>): boolean
```

### `ApiResult.isRedirect`

Returns `true` if the result is a `RedirectResponse` object

```ts
isRedirect(result: ResponseResult<...>): boolean
```
npm package: @l3dev/discord-bot-tickets-plugin
Description: A plugin for discord bot tickets
Author: l3dotdev
Latest version: 0.4.7

# discord-bot-tickets-plugin

## Usage

Add the plugin to the bot config and pass in the plugin config

```ts
import botTickets from "@l3dev/discord-bot-tickets-plugin";
import { createBot } from "@l3dev/discord.js-helpers";

const bot = createBot({
    ...
    plugins: [botTickets({ db })]
});
```

Create a schema file (e.g. `bot-tickets.schema.ts`) in the drizzle schema folder

```ts
export * from "@l3dev/discord-bot-tickets-plugin/db-schema";
```
npm package: @l3dev/discord.js-helpers
Description: Helpers for working with discord.js and building bots
Author: l3dotdev
Latest version: 0.11.1
Deprecated: This package is deprecated. Please migrate to 'discordthing', see https://github.com/l3dotdev/discordthing

# discord.js-helpers

> `@l3dev/discord.js-helpers` is deprecated.
> You should use `discordthing` as the new alternative.
>
> See [discordthing](https://github.com/l3dotdev/discordthing) for more information.

## Description

A lightweight framework and collection of helpers for building a discord bot with [`discord.js`](https://www.npmjs.com/package/discord.js)

## Installation

```bash
npm install @l3dev/discord.js-helpers
```

```bash
pnpm add @l3dev/discord.js-helpers
```

## Create a bot

```ts
import { createBot, createCommandExecutor, okMessage } from "@l3dev/discord.js-helpers";
import { EmbedBuilder, Colors } from "discord.js";

import { commands } from "./commands";
import { eventListeners } from "./eventListeners";

const commandExecutor = createCommandExecutor({
	getErrorMessage(msg, _err, _interaction) {
		const embed = new EmbedBuilder()
			.setColor(Colors.Red)
			.setTitle(":warning: Error")
			.setDescription(msg);

		return okMessage({
			embeds: [embed]
		});
	}
});

const client = createBot({
	clientOptions: {
		intents: ["Guilds", "GuildMembers"]
	},
	commandExecutor,
	commands,
	eventListeners
});

client.login(process.env.DISCORD_TOKEN);
```

### Define a command

```ts
// hello-world.command.ts

import { defineCommand } from "@l3dev/discord.js-helpers";
import { Result } from "@l3dev/result";

export default defineCommand({
	name: "hello-world",
	define(builder) {
		return builder.setName(this.name).setDescription("Say hello!");
	},
	async execute(interaction) {
		return await Result.fromPromise(
			{ onError: { type: "HELLO_WORLD_REPLY" } },
			interaction.reply("Hello world!")
		);
	}
});
```

Export commands as a single object:

```ts
// commands.ts

export const commands = {
	helloWorld: await import("./hello-world.command")
};

// or if you are using a bundler like Vite:

export const commands = import.meta.glob<true, string>("./*.command.ts", { eager: true });
```

### Define an event listener

```ts
// welcome.event.ts

import { defineEventListener } from "@l3dev/discord.js-helpers";
import { Result } from "@l3dev/result";
import { Events } from "discord.js";

export default defineEventListener({
	event: Events.GuildMemberAdd,
	async listener(member) {
		const joinChannel = await getJoinChannel(member.guild);

		return await Result.fromPromise(
			{ onError: { type: "WELCOME_MESSAGE" } },
			joinChannel.send(`Welcome <@${member.user.id}>!`)
		);
	}
});
```

Export event listeners as a single object:

```ts
// eventListeners.ts

export const eventListeners = {
	welcome: await import("./welcome.event")
};

// or if you are using a bundler like Vite:

export const eventListeners = import.meta.glob<true, string>("./*.event.ts", { eager: true });
```
npm package: @l3dev/djsx
Description: JSX syntax for Discord.js builders
Author: l3dotdev
Latest version: 0.1.1

# djsx

## About

JSX syntax for Discord.js builders.

## Installation

```bash
npm install @l3dev/djsx
yarn add @l3dev/djsx
pnpm add @l3dev/djsx
```

## Example Usage

Configure typescript to use `@l3dev/djsx` as the JSX runtime:

`tsconfig.json`

```json
{
	"compilerOptions": {
		"jsx": "react-jsx",
		"jsxImportSource": "@l3dev/djsx"
	}
}
```

You can now use djsx in your `jsx` and `.tsx` files:

```tsx
import { Modal, Label, TextInput } from "@l3dev/djsx/elements";

export function MyModal() {
	return (
		<Modal title="Modal">
			<text>Tell us about yourself!</text>
			<Label label="What's your favourite colour?">
				<TextInput style="Short" customId="favourite-colour" />
			</Label>
		</Modal>
	);
}
```
npm package: @l3dev/mixins
Description: Convenient polyfills/mixins for javascript built-ins
Author: l3dotdev
Latest version: 0.2.5

# mixins

### `String.prototype.toTitleCase`

Converts the first letter of a string to uppercase and the rest to lowercase.

```ts
"hello world".toTitleCase(); // "Hello world"
```

### `String.prototype.toSlug`

Converts a string to a slug

```ts
"Hello World ".toSlug(); // "hello-world"
```

### `Number.prototype.toBytesString`

Converts a number of bytes to a human-readable string.

```ts
(1024).toBytesString(); // "1 KB"
```

### `Number.prototype.toDurationComponents`

Converts a number of milliseconds to individual components of a duration.

```ts
const hour = 1000 * 60 * 60;
const minute = 1000 * 60;
const duration = hour + minute * 27 + 5050;

const components = duration.toDurationComponents();
components; // { days: 0, hours: 1, minutes: 27, seconds: 5, milliseconds: 50 }
```

### `Number.prototype.toDuration`

Converts a number of milliseconds to a human-readable duration string.

```ts
const oneHour = 1000 * 60 * 60;
oneHour.toDuration(); // "1 hour"

const oneDayAnd30Seconds = 1000 * 60 * 60 * 24 + 30 * 1000;
oneDayAnd30Seconds.toDuration(); // "1 day 30 seconds"
```

### `Date.prototype.toRelativeString`

Creates a human-readable string representing the relative time between two dates.

```ts
const inOneHour = new Date(Date.now() + 60 * 60 * 1000);
inOneHour.toRelativeString(); // "in 1 hour"

const yesterday = new Date(Date.now() - 24 * 3600 * 1000);
yesterday.toRelativeString(); // "Yesterday"
```

### `Date.prototype.isToday`

Checks if a date is today.

```ts
const today = new Date();
today.isToday(); // true
```

### `Date.prototype.isTomorrow`

Checks if a date is tomorrow.

```ts
const tomorrow = new Date(Date.now() + 24 * 3600 * 1000);
tomorrow.isTomorrow(); // true
```

### `Date.prototype.isYesterday`

Checks if a date is yesterday.

```ts
const yesterday = new Date(Date.now() - 24 * 3600 * 1000);
yesterday.isYesterday(); // true
```

### `RegExp.escape`

Escapes a string for use in a regular expression.

```ts
RegExp.escape("www.google.com/?q=hello+world"); // "www\.google\.com\/\?q=hello\+world"
```
npm package: @l3dev/result
Description: Type-safe result-based error handling
Author: l3dotdev
Latest version: 0.6.2

# result

## Description

A `Result` based error handling library. Inspired by Rust's `Result` type and [neverthrow](https://www.npmjs.com/package/neverthrow).

This package aims to simplify neverthrow's API while still offering the result type-safety.

## Installation

```bash
npm install @l3dev/result
```

```bash
pnpm add @l3dev/result
```

## Documentation

### `ok`

Creates an `Ok` object, alias: `Result.ok`

```ts
ok<T>(value: T): Ok<T>
```

#### Example

```ts
import { ok } from "@l3dev/result";

const result = ok(42);

result.ok; // true
result.value; // 42
```

> Use `NONE` for a void ok result: `Ok<void>`

### `err`

Create an `Err` object, alias: `Result.err`

```ts
err<T>(type: T): Err<T, null>
err<T, D>(type: T, context: D): Err<T, D>
```

#### Example

```ts
import { err } from "@l3dev/result";

const result = err("error");

result.ok; // false
result.type; // 'error'
result.context; // null

const resultWithContext = err("error", { message: "Something went wrong" });

result.ok; // false
result.type; // 'error'
result.context; // { message: 'Something went wrong' }
```

### `Result.isOk`

Returns `true` if the result is an `Ok` object

```ts
isOk(result: ReturnResult<any, any>): boolean
```

### `Result.isErr`

Returns `true` if the result is an `Err` object

```ts
isErr(result: ReturnResult<any, any>): boolean
```

### `Result.fn`

Wraps a function requiring that the ReturnType be a `ReturnResult` type.

```ts
fn<T, F extends (...) => T>(fn: F): F
```

#### Example

```ts
import { ok, err, Result } from "@l3dev/result";

const myFunction = Result.fn((roll: number) => {
	if (roll < 1 || roll > 6) {
		return err("Invalid roll");
	}
	return ok(roll);
});

const result = myFunction(3); // Ok<3> | Err<"Invalid roll", null>
```

### `Result.fromPromise`

Catches any errors thrown by a promise into `Err` objects.

```ts
fromPromise<T>(promise: T): Promise<ReturnResult<Awaited<T>, ResultErrorDefinition<null, { error: TError }>>>
```

### `Result.unwrapOrDefault`

Unwraps the result, returning the value if it is an `Ok` object, or the default value if it is an `Err` object.

```ts
unwrapOrDefault<T>(result: ReturnResult<T, any>, defaultValue: T): T
```