open-index/open-npm huggingface dataset:
npm package: @grammer/split-array
Description: splits an array in half or at specified index
Author: Juan Carlos Gonzalez
Latest version: 2.0.0

# @grammer/split-array

<!-- badges -->
[![npm (scoped)](https://img.shields.io/npm/v/@grammer/split-array.svg)](https://github.com/jsdev17/split-array)

<!-- content -->

## About

A small method to split an array in half or at a specified index. Returns object containing two arrays, like so:

```js
{
  first_half: [ ... ],
  second_half: [ ... ]
}
```

Written entirely in vanilla JS with zero dependencies.

## Install

```bash
$ npm install @grammer/split-array
```

## Usage

```js
const splitArray = require('@grammer/split-array');

// Example 1 - Split in half
let arr1 = [1,2,3,4,5,6];
console.log( splitArray(arr1) );
// { first_half: [ 1,2,3 ], second_half: [ 4,5,6 ] }

// Example 2 - Split at given index
let arr2 = [1,2,3,4,5,6,7,8,9];
console.log( splitArray(arr2, 7) );
// { first_half: [ 1,2,3,4,5,6,7 ], second_half: [ 8,9 ] }

// Example 3 - Split in half with odd # of elements
let arr3 = [1,2,3,4,5,6,7];
console.log( splitArray(arr3) );
// { first_half: [ 1,2,3 ], second_half: [ 4,5,6,7 ] }
```
npm package: @grammyjs/create-grammy
Description: Scaffold grammY projects in minute
Author: Satont WorldWide
Latest version: 0.2.15

# Create grammy

Fast and simple command line tool to setup the needed files to quickly create
Telegram bots powered by the [grammY bot framework](https://grammy.dev). This
tool allows you to create projects from several [templates](./templates.json),
maintained by both official team and third-party users.

Here is a preview of the tool: https://asciinema.org/a/504541

## Install

Install using npm
```shell
npm i -g @grammyjs/create-grammy@latest
```

Install using [Go](https://go.dev).

```shell
go install github.com/grammyjs/create-grammy@latest
```

After installation, run **create-grammy** command to use the tool. You can provide a
project name as the first argument.

## Templates

Open a pull request by adding your own templates to the
[templates.json](./templates.json) file. There are currently three platforms
that you can add templates to: Deno, Node.js, and other templates.

Each template should contain the following fields:

- `name` — Name to be shown in the templates list in CLI. Recommended to use
  "owner/repository" as the name if it's a repository.
- `type` — **repository** or **subfolder**. If your template is an entire
  repository, use `repository` as type, or if it is a subfolder in a repository
  use `subfolder` as the type.
- `owner` — GitHub repository owner.
- `repository` — GitHub repository name.
- `docker_prompt` — Should the CLI prompt the user to add
  [default docker files](./internal/files/dockerfiles.go).
- `tsconfig_prompt` — Should the CLI prompt the user to add the default
  [tsconfig.json](./configs/tsconfig.json) file.

You also need to add the following fields according to your template:

#### "repository" type

- `branch` — Primary repository branch name. Try your best to keep that branch
  up-to-date.

#### "subfolder" type

- `path` — Path to the subfolder where the template is located at.

#### For Deno templates

- `cache_file` — When the user chose to cache dependencies, `deno cache` command
  will get executed for the specified file. Point to deps.ts, or the entry point
  of the template.
npm package: @grammyjs/emoji
Description: Use emoji names instead of Unicode strings. Copy-pasting emoji sucks.
Author: André Silveira
Latest version: 1.2.0

# grammY emoji

Adds emoji parsing for [grammY](https://github.com/grammyjs/grammY).
Check out the [official documentation](https://grammy.dev/plugins/emoji.html) to learn more about this plugin.

## Installation

Using npm:

```bash
npm install @grammyjs/emoji
```

Using Yarn:

```bash
yarn add @grammyjs/emoji
```

Using Deno:

```ts
import {/* ... */} from "https://deno.land/x/grammy_emoji/mod.ts";
```

## Usage

```ts
import { Bot, Context } from "grammy";
import { EmojiFlavor, emojiParser } from "@grammyjs/emoji";

type MyContext = EmojiFlavor<Context>;
const bot = new Bot<MyContext>(""); // <-- put your bot token between the ""

bot.use(emojiParser());

bot.command("ping", async (ctx) => {
    // Don't know emoji names? No problem!
    // Press Ctrl + Space on supported editors to
    // see IntelliSense auto-completion magic.
    await ctx.reply(ctx.emoji`Pong! ${"ping_pong"}`);
    // > Pong! 🏓
});

bot.command("start", async (ctx) => {
    await ctx
        .replyWithEmoji`Welcome to my bot! ${"grinning_face_with_big_eyes"}`;
    // > Welcome to my bot! 😀
});

bot.start();
```

## Contribute

Contributions are more than welcome! Just make sure if there is already a similar PR, so you can contribute from there.
npm package: @grammyjs/files
Description: Files plugin for grammY
Author: KnorpelSenf
Latest version: 1.2.0

# File handling simplified in grammY

This plugin allows you to easily download files from Telegram servers.
Check out [the official plugin page](https://grammy.dev/plugins/files.html) for further documentation.

## Example

```ts
import { Bot, type Context } from "grammy";
import { type FileFlavor, hydrateFiles } from "@grammyjs/files";

// Transformative API flavor
type MyContext = FileFlavor<Context>;

// Create bot
const bot = new Bot<MyContext>("");

// Install plugin
bot.api.config.use(hydrateFiles(bot.token));

// Download videos and GIFs to temporary files
bot.on([":video", ":animation"], async (ctx) => {
    // Prepare file for download
    const file = await ctx.getFile();
    // Download file to temporary location on your disk
    const path = await file.download();
    // Print file path
    console.log("File saved at", path);
});
```

You can pass a string with a file path to `download` if you don't want to create a temporary file.
Just do `await file.download('/path/to/file')`.
npm package: @grammyjs/hydrate
Description: Hydration plugin for grammY
Author: KnorpelSenf
Latest version: 1.6.0

# Hydration plugin for grammY

Please confer the [official documentation](https://grammy.dev/plugins/hydrate.html) for this plugin to learn more about this plugin, including about its **Installation**.

Here is a brief description, though:
This plugin installs useful methods on two types of objects, namely

1. the results of API calls, and
2. the objects on the context object `ctx`.

The purpose of this plugin is best illustrated by an example.

**WITHOUT** this plugin:

```ts
bot.on(":photo", async (ctx) => {
    const statusMessage = await ctx.reply("Processing your image, please wait");
    await doWork(); // some long image processing
    await ctx.api.deleteMessage(statusMessage.message_id);
});
bot.on("callback_query", async (ctx) => {
    await ctx.answerCallbackQuery();
});
```

**WITH** this plugin:

```ts
bot.on(":photo", async (ctx) => {
    const statusMessage = await ctx.reply("Processing your image, please wait");
    await doWork(); // some long image processing
    await statusMessage.delete(); // so easy!
});
bot.on("callback_query", async (ctx) => {
    await ctx.callbackQuery.answer(); // this works now, too
});
```
npm package: @grammyjs/menu
Description: Interactive menus for grammY
Author: KnorpelSenf
Latest version: 1.3.1

# Interactive menus for grammY

Check out the [official documentation](https://grammy.dev/plugins/menu.html) for this plugin.

A menu is a set of interactive buttons that is displayed beneath a message.
It uses an [inline keyboard](https://grammy.dev/plugins/keyboard.html) for that, so in a sense, a menu is just an inline keyboard spiced up with interactivity (such as navigation between multiple pages).

## Quickstart

Here is a small example.

```ts
// Creating a simple menu
const menu = new Menu("my-menu-identifier")
    .text("A", (ctx) => ctx.reply("You pressed A!")).row()
    .text("B", (ctx) => ctx.reply("You pressed B!"));

// Make it interactive
bot.use(menu);

bot.command("start", async (ctx) => {
    // Send the menu:
    await ctx.reply("Check out this menu:", { reply_markup: menu });
});
```

You can find more examples and documentation on [the plugin page on the website](https://grammy.dev/plugins/menu.html).
npm package: @grammyjs/parse-mode
Description: Plugin for constructing Formatted Texts in Telegram
Author: KnightNiwrem
Latest version: 2.3.0

# Parse Mode plugin for grammY

This library provides simplified formatting utilities for the [grammY](https://grammy.dev) Telegram Bot framework. It enables you to compose richly formatted messages using a declarative, type-safe API.

With this plugin, you can:

- Use tagged template literals and formatters (like bold, italic, link, etc) to build formatted messages and captions
- Apply formatting to text and media captions using the fmt function

The plugin is compatible with both Deno and Node.js, and is designed to work as a drop-in enhancement for grammY bots that need robust formatting capabilities.

## Usage (Using fmt)

```ts
import { Bot } from "grammy";
import { b, fmt, u } from "@grammyjs/parse-mode";

const bot = new Bot("");

bot.command("demo", async (ctx) => {
  // Using return values of fmt
  const combined = fmt`${b}bolded${b} ${ctx.msg.text} ${u}underlined${u}`;
  await ctx.reply(combined.text, { entities: combined.entities });
  await ctx.replyWithPhoto(photo, {
    caption: combined.caption,
    caption_entities: combined.caption_entities,
  });
});

bot.start();
```

## Usage (Using FormattedString)

```ts
import { Bot } from "grammy";
import { FormattedString } from "@grammyjs/parse-mode";

const bot = new Bot("");

bot.command("demo", async (ctx) => {
  // Using return values of Fmt
  const combined = FormattedString.b("bolded").plain(ctx.msg.text).u(
    "underlined",
  );
  await ctx.reply(combined.text, { entities: combined.entities });
  await ctx.replyWithPhoto(photo, {
    caption: combined.caption,
    caption_entities: combined.caption_entities,
  });
});

bot.start();
```
npm package: @grammyjs/runner
Description: Scale grammY bots that use long polling
Author: KnorpelSenf
Latest version: 2.0.3

# <h1 align="center">grammY runner</h1>

---

While the core of [grammY](https://github.com/grammyjs/grammY) is extremely efficient, the package does not ship with a built-in mechanism for long polling at scale.
(It does scale well with webhooks, though.)

The grammY runner solves this by providing you with a sophisticated mechanism that can pull updates concurrently from the Telegram servers, and in turn execute your bot's middleware stack concurrently, all while catching errors, timeouts, and giving you full control over how much load is applied to your server.

## Do I Need This?

Use the grammY runner package if

- your bot needs to process a lot of updates (more than 1K/hour), or
- your bot performs long-running operations such as large file transfers.

Do **not** use grammY runner if

- you are just getting started with grammY, or
- your bot is running on webhooks.

## Quickstart

Here is a quickstart for you, but [the real documentation is here on the website](https://grammy.dev/plugins/runner.html).
The runner package has many more features, and they are documented there.

```bash
npm i @grammyjs/runner
```

Import `run` from `@grammyjs/runner`, and replace `bot.start()` with `run(bot)`. It is that simple. Done!

---

Okay okay, here is some example code:

```ts
import { Bot } from "grammy";
import { run } from "@grammyjs/runner";

// Create bot
const bot = new Bot("<token>");

// Add the usual middleware, yada yada
bot.on("message", (ctx) => ctx.reply("Got your message."));

// Run it concurrently!
run(bot);
```

## Concurrency Is Hard

grammY runner makes it trivial to have very high update throughput.
However, concurrency is generally very hard to get right, so please read [this section in the docs](https://grammy.dev/advanced/scaling.html#concurrency-is-hard).

## Resources

### [grammY runner in the grammY documentation](https://grammy.dev/plugins/runner.html)

—more verbose documentation about concurrency in grammY.

### [grammY runner API Reference](https://deno.land/x/grammy_runner/mod.ts)

—documentation of everything that grammY runner exports.

### [grammY Example Bots](https://github.com/grammyjs/examples)

—repository full of example bots, look our for those that demonstrate how to use grammY runner.
npm package: @grammyjs/storage-firestore
Description: Google Firestore storage adapter for grammY
Author: KnorpelSenf
Latest version: 2.4.2

# Google Firestore storage adapter for grammY

Storage adapter that can be used to [store your session data](https://grammy.dev/plugins/session.html) on [Google Cloud Firestore](https://cloud.google.com/firestore) when using sessions.

## Installation

```bash
npm install @grammyjs/storage-firestore --save
```

You should also have [`@google-cloud/firestore`](https://www.npmjs.com/package/@google-cloud/firestore) installed.

## Introduction

> Set up your Firestore database by following <https://cloud.google.com/firestore/docs/quickstart-servers#node.js>.

You should now have:

1. A project ID for you google cloud project
2. A keyfile containing the firestore authentication credentials
3. A Telegram bot token

Put those values into the following example code:

```ts
import { Bot, Context, session, SessionFlavor } from "grammy";
import { adapter } from "@grammyjs/storage-firestore";
import { Firestore } from "@google-cloud/firestore";

interface SessionData {
  counter: number;
}
type MyContext = Context & SessionFlavor<SessionData>;

// Connect to Firestore
const db = new Firestore({
  // adjust these values:
  projectId: "YOUR_PROJECT_ID",
  keyFilename: "firestore-keyfile.json",
});

// Create bot and register session middleware
const bot = new Bot<MyContext>("");
bot.use(
  session({
    initial: () => ({ counter: 0 }),
    storage: adapter(db.collection("sessions")),
  })
);

// Register your usual middleware, and start the bot
bot.command("stats", (ctx) =>
  ctx.reply(`Already got ${ctx.session.counter} photos!`)
);
bot.on(":photo", (ctx) => ctx.session.counter++);

bot.start();
```

On firestore, you are billed per operation.
If your bot does not need the session data for most of the messages it processes, this would cause a lot of superfluous reads and writes.
Imagine your bot is in a group chat where it only counts photos but otherwise ignores all messages.
Then it would not make sense to retrieve the session data for every request, and to write back the identical data.
The solution is to use the built-in lazy mode of grammY, so just replace `bot.use(session ...)` by `bot.use(lazySession ...)`, and remember to `await ctx.session` whenever you use it.
You must also flavor your context with `LazySessionFlavor` instead of just `SessionFlavor`.
npm package: @grammyjs/storage-mongodb
Description: MongoDB storage for grammy library.
Author: Satont
Latest version: 2.5.1

# MongoDB storage adapter for grammY

Storage adapter that can be used to
[store your session data](https://grammy.dev/plugins/session.html) with
[MongoDB](https://www.mongodb.com/) when using sessions.

Compatible with deno and node!

## Installation

Node

```bash
npm install @grammyjs/storage-mongodb --save
```

Deno

```ts
import {
  ISession,
  MongoDBAdapter,
} from "https://deno.land/x/grammy_storages/mongodb/src/mod.ts";
```

## Usage

You can see [examples/](https://github.com/grammyjs/storages/tree/main/packages/mongodb/examples) which contains both Deno and Node examples.

### Mongoose

If you use Mongoose for operations with mongodb, you can still use this adapter.
You need to get a native connection and use it:

```ts
import mongoose from "mongoose";
import { MongoDBAdapter, ISession } from "@grammyjs/storage-mongodb";

await mongoose.connect("mongodb://localhost:27017/test");

const collection = mongoose.connection.db.collection<ISession>(
  "sessions",
);

bot.use(session({
    initial: (): SessionData => ({
        pizzaCount: 0,
    }),
    storage: new MongoDBAdapter({ collection }),
}))
```
npm package: @grammyjs/validator
Description: Validation logic for Telegram Web Bots and Login Widgets
Author: KnorpelSenf
Latest version: 1.0.1

# <h1 align="center">grammY validator</h1>

---

## What is this

This package solves two problems at once:

- [Validating data received via **Web Apps for a Telegram Bot**](https://core.telegram.org/bots/webapps#validating-data-received-via-the-web-app)
- [Checking authorization data for **Telegram Login Widget**](https://core.telegram.org/widgets/login#checking-authorization)

## How to use

**Deno**: import from this URL: `https://deno.land/x/grammy_validator/mod.ts`

**Node.js**: `npm install @grammyjs/validator`

### Web Bots: Validation

Web Bots can get access to `window.Telegram.WebApp.initData` which must be sent to the server for validation.
The string value of `initData` is a query string that you can simply append to a URL to fetch.
Example:

```ts
const url = "https://grammy.dev?" + window.Telegram.WebApp.initData;
await fetch(url);
```

This library helps you validate the resulting search query in the backend.

```ts
import { validateWebAppData } from "./src/mod.ts";

const token = ""; // <-- put your bot token here
const url = ctx.request.url; // get `URL` object from your web framework

if (validateWebAppData(token, url.searchParams)) { // pass `URLSearchParams` object
    // data is from Telegram
}
```

### Login Widget: Authorization

You can also check the signature if you are using a Telegram Login Widget.

```ts
import { checkSignature } from "./src/mod.ts";

const token = ""; // <-- put your bot token here

const payload = {
    id: "424242424242",
    first_name: "John",
    last_name: "Doe",
    username: "username",
    photo_url: "https://t.me/i/userpic/320/username.jpg",
    auth_date: "1519400000",
    hash: "87e5a7e644d0ee362334d92bc8ecc981ca11ffc11eca809505",
};

if (checkSignature(token, payload)) {
    // data is from Telegram
}
```
npm package: @grampelberg/next-styles
Description: CSS / LESS / SASS / CssModules in Next.js
Author: Boris Kotov
Latest version: 0.0.1

# @webdeb/next-styles

### CSS + LESS + SASS + Modules in Next.js

---

## Description

This module allows you to use css (+ optional [less, sass, modules]) all in one package.
It uses the latest modules available css-loader, less-loader, sass-loader, postcss. Check out the sources, its dead simple.

## Why?

Because I found it cumbersome to deal with the official packages from next-plugins to setup css + less + sass + modules.
So I created this one. It has everything I need for my project, most projects, I believe.

## Install

```sh
npm install @webdeb/next-styles
```

## Use

```js
// next.config.js
const withStyles = require('@webdeb/next-styles')

module.exports = withStyles({
  less: true, // use .less files
  sass: true, // use .scss files
  modules: true, // style.(m|module).css & style.(m|module).scss for module files
  lessLoaderOptions: {
    javascriptEnabled: true,
  },
  sassLoaderOptions: {
    sassOptions: {
      includePaths: ["src/styles"], // @import 'variables'; # loads (src/styles/varialbes.scss), you got it..
    },
  },
  cssLoaderOptions: {...},
  postcssLoaderOptions: {...},
  miniCssExtractOptions: {...} // ignoreOrder:true for https://github.com/webpack-contrib/mini-css-extract-plugin/issues/250#issuecomment-544898772
})
```

_Hint: Look at the source of truth: `withStyles.js`_

## Known Issues

This project inherits a known next-css problem. https://github.com/zeit/next-plugins/issues/282

If your pages where you are importing css are not working, you are probably facing exactly this problem. The workaround is to load a css/scss file (can be even empty) into your \_app.js.

```js
import "../styles/global.scss"

export default function MyApp({ Component, pageProps }) {
  return <Component {...pageProps} />
}
```

## How to contribute

1. fork the project `~master`
1. locally clone the project in your machine ( `git clone https/ssh github link to your fork` )
1. create a new branch in your fork ( `git checkout -b your/branch/name` )
1. run `npm install` in your local clone of the repo
1. apply your code changes ( keep `CHANGELOG.md` and the `README.md` file up to date, also modify `package.json` `version` as fit!)
1. run `npm pack` in your local clone of the repo
1. test your changes against a next.js project that uses your local repo ( use `npm install --save path/to/local/repo/{version}.tgz` to test your locally changed code)
1. if your code work as expected, remove the packed tgz file from the repo and commit to your fork
1. create a PR to apply your fork in this repository

## Credits

Most of the code was taken from the official `next-css` & `next-sass` package.
npm package: @grampelberg/react-feather
Description: React component for Feather icons
Author: Carmelo Pullara
Latest version: 2.0.8

## React Feather Icons

[![npm version](https://img.shields.io/npm/v/react-feather.svg?style=flat-square)](https://www.npmjs.com/package/react-feather)
[![npm downloads](https://img.shields.io/npm/dm/react-feather.svg?style=flat-square)](https://www.npmjs.com/package/react-feather)

#### What is react-feather?
react-feather is a collection of simply beautiful open source icons for React.js. Each icon is designed on a 24x24 grid with an emphasis on simplicity, consistency and readability.

[Explore icons](https://bit.dev/feathericons/react-feather) and play with examples.
<p align="center">
  <a href="https://bit.dev/feathericons/react-feather"><img src="https://i.imagesup.co/images2/371e9a2b398a5d7cef54a956d959e4534b290a55.gif"></a>
</p>

#### Based on Feather Icons  ```v4.26.0```

#### Version `2.0.0` adds support for tree-shaking, to help you reduce bundle size.

### Installation
    npm install react-feather --save

### Usage

```javascript
import React from 'react';
import { Camera } from 'react-feather';

const App = () => {
  return <Camera />
};

export default App;
```

Icons can be configured with inline props:
```javascript
<Camera color="red" size={48} />
```

If you can't use ES6 imports, it's possible to include icons from the compiled folder ./dist.
```javascript
var Camera = require('react-feather/dist/icons/camera').default;

var MyComponent = React.createClass({
  render: function () {
    return (
      <Camera />
    );
  }
});
```
You can also include the whole icon pack:

```javascript
import React from 'react';
import * as Icon from 'react-feather';

const App = () => {
  return <Icon.Camera />
};

export default App;
```
npm package: @gramps/data-source-xkcd
Description: GrAMPS GraphQL data source to load xkcd comics.
Latest version: 2.0.0

<a href="https://ibm.biz/gramps-graphql"><img src="https://gramps-graphql.github.io/gramps-express/assets/img/gramps-banner.png" alt="GrAMPS · An easier way to manage the data sources powering your GraphQL server" width="450"></a>

# GrAMPS GraphQL Data Source for [xkcd](https://xkcd.com)
[![license](https://img.shields.io/npm/l/@gramps/data-source-xkcd.svg)](https://github.com/gramps-graphql/data-source-xkcd/blob/master/LICENSE) [![npm version](https://img.shields.io/npm/v/@gramps/data-source-xkcd.svg?style=flat)](https://www.npmjs.com/package/@gramps/data-source-xkcd) [![Build Status](https://travis-ci.org/gramps-graphql/data-source-xkcd.svg?branch=master)](https://travis-ci.org/gramps-graphql/data-source-xkcd) [![Maintainability](https://api.codeclimate.com/v1/badges/ac264833fac1fbd1afe0/maintainability)](https://codeclimate.com/github/gramps-graphql/data-source-xkcd/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/ac264833fac1fbd1afe0/test_coverage)](https://codeclimate.com/github/gramps-graphql/data-source-xkcd/test_coverage) [![Greenkeeper badge](https://badges.greenkeeper.io/gramps-graphql/data-source-xkcd.svg)](https://greenkeeper.io/)

Load the latest [xkcd](https://xkcd.com) comic, or look one up by its ID.

This is a [GrAMPS](https://ibm.biz/gramps-graphql) data source for GraphQL.

## Example Queries

To get all available fields for this data source, try out these two queries in GraphiQL. (See [the quickstart](#quickstart) for details on starting GraphiQL.)

```graphql
query getLatestComic {
  getLatestComic {
    ...ComicFields
  }
}

query getComicById($id: ID!) {
  getComicById(id: $id) {
    ...ComicFields
  }
}

fragment ComicFields on XKCD_Comic {
  num
  title
  safe_title
  img
  alt
  transcript
  year
  month
  day
  link
  news
}
```

Use the following arguments:

```json
{
  "id": 1900
}
```

## Quickstart

```sh
# Clone the repo
git clone git@github.com:gramps-graphql/data-source-xkcd.git

# Move into it
cd data-source-xkcd/

# Install dependencies
yarn install
```

### To Develop with Mock Data

Start the app with the following command:

```sh
# Develop with mock data
yarn dev:mock-data
```

Open the URL displayed in your console to see GraphiQL.

### To Develop with Live Data

Once you’ve got your data source configured to load live data, you can enable live data in development:

```sh
# Develop with live data
yarn dev
```

Open the URL displayed in your console to see GraphiQL.

### Notes for Developers

Currently, there is no watch capability (PRs welcome!), so the service needs to be stopped (`control` + `C`) and restarted (`yarn [dev:mock-data|dev]`) to reflect new changes to the data source.