open-index/open-npm huggingface dataset:
npm package: @nichozuo/react-common
Description: ## Getting Started
Latest version: 0.0.7

# react-common

## Getting Started

Install dependencies,

```bash
$ npm i
```

Start the dev server,

```bash
$ npm start
```

Build documentation,

```bash
$ npm run docs:build
```

Run test,

```bash
$ npm test
```

Build library via `father-build`,

```bash
$ npm run build
```
npm package: @nicia-ai/typegraph
Description: TypeScript-first embedded knowledge graph library with ontological reasoning
Author: Nicia AI, Inc.
Latest version: 0.19.0

# @nicia-ai/typegraph

Type-driven embedded knowledge graph for TypeScript.

- Docs: [typegraph.dev](https://typegraph.dev)
- Repo: [github.com/nicia-ai/typegraph](https://github.com/nicia-ai/typegraph)

## Installation

```bash
npm install @nicia-ai/typegraph zod drizzle-orm better-sqlite3
```

## Quick Start

```ts
import { z } from "zod";
import Database from "better-sqlite3";
import { drizzle } from "drizzle-orm/better-sqlite3";

import { createStore, defineEdge, defineGraph, defineNode } from "@nicia-ai/typegraph";
import { createSqliteBackend, generateSqliteMigrationSQL } from "@nicia-ai/typegraph/sqlite";

const Person = defineNode("Person", { schema: z.object({ name: z.string() }) });
const knows = defineEdge("knows");

const graph = defineGraph({
  id: "social",
  nodes: { Person: { type: Person } },
  edges: { knows: { type: knows, from: [Person], to: [Person] } },
});

const sqlite = new Database(":memory:");
const db = drizzle(sqlite);
sqlite.exec(generateSqliteMigrationSQL());

const backend = createSqliteBackend(db);
const store = createStore(graph, backend);

const alice = await store.nodes.Person.create({ name: "Alice" });
const bob = await store.nodes.Person.create({ name: "Bob" });
await store.edges.knows.create(alice, bob);
```

See the repo README for more.

Examples: [github.com/nicia-ai/typegraph/tree/main/packages/typegraph/examples](https://github.com/nicia-ai/typegraph/tree/main/packages/typegraph/examples)

## Performance Smoke Check

The perf harness lives in `@nicia-ai/typegraph-benchmarks`; these commands delegate to it.

Run a deterministic SQLite perf sanity suite with guardrails:

```bash
pnpm --filter @nicia-ai/typegraph test:perf
```

Run the same guardrailed suite against PostgreSQL (requires `POSTGRES_URL`):

```bash
POSTGRES_URL=postgresql://typegraph:typegraph@127.0.0.1:5432/typegraph_test \
  pnpm --filter @nicia-ai/typegraph test:perf:postgres
```

For report-only mode (no pass/fail guardrails):

```bash
pnpm --filter @nicia-ai/typegraph bench:perf
```
npm package: @nicjohnson/eleventy-plugin-sass
Description: A plugin for sass support in Eleventy
Author: Maarten Schroeven
Latest version: 1.0.0

# eleventy-plugin-sass

A plugin that adds sass support to [Eleventy](https://github.com/11ty/eleventy)

## Installation

Available on [npm](https://www.npmjs.com/package/eleventy-plugin-sass).

```
npm install eleventy-plugin-sass --save
```

Open up your Eleventy config file (probably `.eleventy.js`) and use `addPlugin`:

```
const pluginSass = require("eleventy-plugin-sass");
module.exports = function(eleventyConfig) {
  eleventyConfig.addPlugin(pluginSass, sassPluginOptions);
};
```

Read more about [Eleventy plugins.](https://www.11ty.io/docs/plugins/)

## Options

| Key               | Type                   | Default                                    | description                                                                                                       |
| ----------------- | ---------------------- | ------------------------------------------ | ----------------------------------------------------------------------------------------------------------------- |
| `watch`           | glob or array of globs | `['**/*.{scss,sass}', '!node_modules/**']` | The sass files you wish to compile (and watch when you serve)                                                     |
| `sourcemaps`      | Boolean                | `false`                                    | Add sourcemaps next to your sass files                                                                            |
| `cleanCSS`        | Boolean                | `true`                                     | Runs the css trough [cleanCSS](https://github.com/jakubpawlowicz/clean-css)                                       |
| `cleanCSSOptions` | Object                 | `N/A`                                      | Options to pass to cleanCSS                                                                                       |
| `autoprefixer`    | Boolean                | `true`                                     | Adds browser specific prefixes if needed (adheres to [BrowserList](https://github.com/browserslist/browserslist)) |

## Disclaimer

This plugins wraps around internal Eleventy code, so if they changes their way of working it might stop working.

## Contributing

Please do contribute, I am open to any changes. Just clone the repository and open a pull request.

## License

MIT © [Maarten Schroeven](maarten@sonaryr.be)
npm package: @nick-bull/human-readable-duration
Description: Converts a number of milliseconds to a human readable time representation
Author: Nick Bull
Latest version: 0.1.3

Converts a number of milliseconds to a human readable time representation

## Installation

```
npm i @nick-bull/human-readable-duration
```

## Usage

```
import {...} from 'nick-bull/human-readable-duration'

...
```
npm package: @nick-bull/module-alias
Description: Allows for importing modules with an alias
Author: Nick Bull
Latest version: 0.0.2

Allows for importing modules with an alias. Shamelessly forked from [module-alias](https://www.npmjs.com/package/module-alias)

## Installation

```
npm i @nick-bull/module-alias
```

## Usage

Specify your module aliases in `package.json`:

```
  "moduleAliases": {
    "#app": "./src",
    "#services": "./src/services",
    "#utils": "./src/utils"
  },
```

Then register as soon as possible:

```
import '@nick-bull/module-alias/register';

- import awesomeService from '../../../src/services/awesomeService';
+ import awesomeService from '#services/awesomeService';
```

## Automate alias conversion

[Check this out!](https://github.com/s-yadav/relative-to-alias)
npm package: @nick-bull/range
Description: Creates an array or generator for a range of numbers
Author: Nick Bull
Latest version: 0.0.0

Creates an array or generator for a range of numbers

## Installation

```
npm i @nick-bull/range
```

## Usage

```
import {
  createInfiniteRangeGenerator,
  createRangeGenerator,
  range,
} from 'nick-bull/range'

assert(range(1, 3) === [1, 2, 3]);
assert(range(1, 5, 2) === [1, 3, 5]); // Third argument is `step`

const rangeGenerator = createRangeGenerator(1, 3);
assert(rangeGenerator.next() === {value: 1, done: false});
assert(rangeGenerator.next() === {value: 2, done: false});
assert(rangeGenerator.next() === {value: 3, done: false});
assert(rangeGenerator.next() === {value: undefined, done: true});

const infiniteRangeGenerator = createInfiniteRangeGenerator();
assert(infiniteRangeGenerator.next() === {value: 1, done: false});
assert(infiniteRangeGenerator.next() === {value: 2, done: false});
assert(infiniteRangeGenerator.next() === {value: 3, done: false});
// ad nauseum
...
```
npm package: @nick-bull/react-native-debug-address
Description: Get or set the debug address for a React Native app
Author: Nick Bull
Latest version: 0.1.91

Work in progress. It works, but you might get some wonderful console messages as I test :) 

## Description

⚠️  Warning - only for Android. Please feel free to add a pull request for iOS

Sets the debug host for a React Native app. This can be set using Ctrl/Cmd+M, selecting "Settings", then typing it into the "Debug server host & port for device" popup.

This can get tedious if you find yourself continuously restarting an emulator with a server on the non-default port, especially if you're running multiple emulators

## Installation

```
npm i react-native-debug-address
```

You can find an example project [here](https://github.com/nick-bull/react-native-debug-address-exemplar).

## Usage

You can do this via two environment variables, `DEBUG_HOST` (default: `127.0.0.1`) and `DEBUG_PORT` (default: `8081`). 

`DEBUG_HOST` can be used to set both the address and the port (e.g., `127.0.0.1:8081`):

Make sure to install [`babel-plugin-transform-inline-environment-variables`](https://babeljs.io/docs/en/babel-plugin-transform-inline-environment-variables) so that your environment variables are registered

```
DEBUG_HOST=127.0.0.1:8081 npx react-native start
```

You can also get and set the debug address programmatically:

```
import {getDebugAddress, setDebugAddress} from 'react-native-debug-address';

await setDebugAddress('127.0.0.1'); // Port defaults to `8081` 
await setDebugAddress('127.0.0.1', '8765');
await setDebugAddress('127.0.0.1:8765');

const debugAddress = await getDebugAddress();
console.log(debugAddress); // Outputs `127.0.0.1:8765`
```
npm package: @nick-bull/react-native-debug-address-exemplar
Description: Example React Native android app using `@nick-bull/react-native-debug-address`
Author: Nick Bull
Latest version: 0.3.0

## Initialising

```
npx react-native init ReactNativeDebugAddressExemplar
cd ReactNativeDebugAddressExemplar

npm i @nick-bull/react-native-debug-address
npm i -D babel-plugin-transform-inline-environment-variables
```

Modify your babel configuration file to add the plugin:

```
// babel.config.js
module.exports = {
  plugins: [
    "transform-inline-environment-variables",
  ],
  presets: ['module:metro-react-native-babel-preset'],
};
```

## Usage

If you are simply setting the debug address via environment variables, then import the package only:

```
import '@nick-bull/react-native-debug-address';
```

In this exemplar app, `App.js` has been modified as follows:

```
- import React from 'react';
+ import React, {
+   useEffect,
+   useState,
+ } from 'react';
+
+ import {
+   getDebugAddress,
+   setDebugAddress
+ } from '@nick-bull/react-native-debug-address';

...

 const App: () => React$Node = () => {
+  const [address, setAddress] = useState('');
+
+  useEffect(() => {
+    onAddressChanged(({debugAddress}) => {
+      console.log(`onAddressChanged: ${debugAddress}`);
+      setAddress(debugAddress)
+    });
+    const getDebugAddressAsync = async () => setAddress(await getDebugAddress());
+    getDebugAddressAsync();
+  }, []);
return (
  <>      
    <StatusBar barStyle="dark-content" />
      <SafeAreaView>
        <ScrollView
          contentInsetAdjustmentBehavior="automatic"
          style={styles.scrollView}>
          <Header />
+          <Text style={{marginBottom: 12, textAlign: 'center', ...styles.sectionTitle}}>
+              Debug Address: {JSON.stringify(address)}
+          </Text>
```

## Running

Note that environment variables are pretty persistent in React Native, so the `--reset-cache` flag is needed.

```
DEBUG_HOST=127.0.0.1:7777 npx react-native start --reset-cache --port 7777
# Both of these are equivalent, as 127.0.0.1 is the default host
# DEBUG_PORT=7777 npx react-native start --reset-cache --port 7777

npx react-native run-android --port 7777
```

The following scripts are defined in `package.json`:

```
"start:port": "f() { DEBUG_PORT=$1 npx react-native start --reset-cache --port $1; }; f",
"start:host": "f() { DEBUG_HOST=$1 npx react-native start --reset-cache --port ${1##*:}; }; f",
"android": "npx react-native run-android --port",
```

So alternatively you can run the server and app respectively by:

```
npm run start:port 7777
npm run android 7777
```

The app will unset the address too, when the server has been closed
npm package: @nick-bull/resolve-url
Description: Resolves a URL
Author: Nick Bull
Latest version: 0.0.0

Resolve a relative URL to an absolute URL

## Installation

```
npm i @nick-bull/resolve-url
```

## Usage

```
import {resolveUrl} from 'nick-bull/resolve-url'

assert(resolveUrl('/image.jpg', 'https://bull.dev') === 'https://bull.dev/image.jpg');
...
```
npm package: @nick-bull/throws
Description: Wraps a function with an error decorator
Author: Nick Bull
Latest version: 0.0.1

Wraps a function with an error decorator

## Installation

```
npm i @nick-bull/throws
```

## Usage

Simply pass a decorator or error alongside the function you want to wrap.

The decorator can be:
- a string message for an error, 
- an error object, which will have the cause error chained as a `chain` property,
- a decorator object, that may contain a `message` and `type` property only,

The callback function may be asynchronous or synchronous; `throws` will return a function of the same synchronicity.

```
import {throws} from 'nick-bull/throws'

const createUserError = {
  type: 'user:create',
  message: 'An error occurred creating the user',
};
const createUser = throws(createUserError, () => {
  return explosiveFn();
});

// `findUser` will be asynchronous, matching the provided callback synchronicity
const UserNotFoundError = new Error('No such user');
const findUser = throws(UserNotFoundError, async (username) => {
  return await find(username);
});

const fetchUserErrorMessage = 'An error occurred finding the user';
const fetchUser = throws(fetchUserErrorMessage, () => {
  throw new Error('Not implemented');
});
```
npm package: @nick-bull/unit-functions
Description: A collection of unit functions
Author: Nick Bull
Latest version: 0.0.2

A collection of unit functions

## Installation

```
npm i @nick-bull/unit-functions
```

## Usage

```
import {identity, tautology} from 'nick-bull/unit-functions'

assert(identity(value) === value);
assert(tautology()) === true);
...
```
npm package: @nick-editor/editor
Description: 文档编辑器,还原语雀的便捷操作
Author: little-thing
Latest version: 1.0.10

# @nick-editor/editor

中文 | [English](README.md)

一个强大的富文本编辑器，基于 Tiptap 构建，致力于还原语雀的便捷编辑体验。

## 特性

- 🚀 现代化直观的界面
- 📝 丰富的文本编辑功能
- 🎨 全面的格式化选项
- 🔄 基于 [Yjs](https://docs.yjs.dev/) 的实时协作支持
- 📊 强大的表格功能
- 🖼️ 图片处理
- ✅ 任务列表和清单
- 🔗 链接管理
- 🎯 占位符支持
- 🎨 基于 Tailwind CSS 的自定义样式
- 🧮 数学公式支持
- 📑 目录生成
- 🎯 节点唯一 ID 支持
- 🖱️ 拖拽句柄支持
- 😀 表情符号支持
- 📁 文件处理能力

## 安装

```bash
npm install @nick-editor/editor

# 或使用 yarn
yarn add @nick-editor/editor

# 或使用 pnpm
pnpm add @nick-editor/editor
```

## 使用方法

```jsx
import { Editor } from '@nick-editor/editor';
import '@nick-editor/editor/index.css';

function MyEditor() {
  return (
    <Editor
      content="你好，世界！"
      onChange={(editor) => {
        console.log(editor.getHTML());
      }}
    />
  );
}
```

## 对等依赖

请确保安装以下对等依赖：

```json
{
  "@nick-editor/extension-table": "^1.0.0",
  "@nick-editor/extension-table-handler": "^1.0.0",
  "@tiptap/pm": "^2.4.0",
  "lucide-react": "^0.49.0",
  "react": "^18.0.0",
  "react-dom": "^18.0.0"
}
```

## 核心功能

### 实时协作
基于 [Yjs](https://docs.yjs.dev/) 和 Hocuspocus provider 的实时协作支持。你可以轻松集成 Yjs 文档：

```jsx
import { Editor } from '@nick-editor/editor';
import * as Y from 'yjs';

const ydoc = new Y.Doc();

function MyEditor() {
  return (
    <Editor
      content="你好，世界！"
      ydoc={ydoc}
      onChange={(editor) => {
        console.log(editor.getHTML());
      }}
    />
  );
}
```

### 丰富的格式化功能
- 文本样式（粗体、斜体、下划线）
- 标题
- 列表（无序列表、有序列表、任务列表）
- 代码块（支持语法高亮）
- 表格（支持高级操作）
- 图片
- 链接
- 数学公式
- 更多...

### 高级功能
- 拖拽支持
- 焦点模式
- 字符计数
- 排版增强
- 文本对齐
- 自定义颜色和字体
- 目录生成

### 开发者体验
- 使用 TypeScript 编写
- 模块化架构
- 可扩展设计
- 完整的文档

## 许可证

MIT

## 贡献

我们欢迎各种形式的贡献！如果您有任何改进建议，请随时提交 Pull Request。
npm package: @nick-editor/extension-paragraph
Description: paragraph extension for tiptap
Author: little-thing
Latest version: 1.0.1

# @nick-editor/extension-paragraph

[![Version](https://img.shields.io/npm/v/@nick-editor/extension-paragraph.svg?label=version)](https://www.npmjs.com/package/@nick-editor/extension-paragraph)
[![Downloads](https://img.shields.io/npm/dm/@nick-editor/extension-paragraph.svg)](https://npmcharts.com/compare/@nick-editor/extension-paragraph?minimal=true)
[![License](https://img.shields.io/npm/l/@nick-editor/extension-paragraph.svg)](https://www.npmjs.com/package/@nick-editor/extension-paragraph)

## 介绍

这是一个用于 nick-editor 的段落扩展组件。它提供了基础的段落功能支持，是编辑器中最基础和重要的扩展之一。

## 特性

- 支持基础的段落文本编辑
- 提供段落的格式化和样式控制
- 与其他 nick-editor 扩展良好集成

## 安装

```bash
npm install @nick-editor/extension-paragraph
```

## 使用方法

```typescript
import { Editor } from '@nick-editor/editor'
import { Paragraph } from '@nick-editor/extension-paragraph'

const editor = new Editor({
  extensions: [
    Paragraph,
    // ... 其他扩展
  ],
})
```

## 许可证

本项目采用 [MIT license](../../LICENSE)) 开源协议。
npm package: @nick-editor/extension-table
Description: table extension for tiptap
Author: little-thing
Latest version: 1.0.3

# @nick-editor/extension-table

[![Version](https://img.shields.io/npm/v/@nick-editor/extension-table.svg?label=version)](https://www.npmjs.com/package/@nick-editor/extension-table)
[![Downloads](https://img.shields.io/npm/dm/@nick-editor/extension-table.svg)](https://npmcharts.com/compare/@nick-editor/extension-table?minimal=true)
[![License](https://img.shields.io/npm/l/@nick-editor/extension-table.svg)](https://www.npmjs.com/package/@nick-editor/extension-table)

[English](./README.md) | [简体中文](./README.zh-CN.md)

## 介绍

这是一个用于 nick-editor 的表格扩展组件。它提供了全面的表格编辑功能，是处理编辑器中表格内容的重要扩展。

## 特性

- 创建和管理可自定义行列的表格
- 支持单元格合并和拆分
- 表格格式化和样式选项
- 表格内键盘导航
- 与其他 nick-editor 扩展良好集成

## 安装

```bash
npm install @nick-editor/extension-table
```

## 使用方法

```typescript
import { Editor } from '@nick-editor/editor'
import { Table } from '@nick-editor/extension-table'

const editor = new Editor({
  extensions: [
    Table,
    // ... 其他扩展
  ],
})
```

## API

### 配置选项

```typescript
Table.configure({
  HTMLAttributes: {
    class: 'my-custom-table',
  },
})
```

### 命令

- `insertTable({ rows: number, cols: number })`: 插入新表格
- `addColumnBefore()`: 在当前列前添加列
- `addColumnAfter()`: 在当前列后添加列
- `deleteColumn()`: 删除当前列
- `addRowBefore()`: 在当前行前添加行
- `addRowAfter()`: 在当前行后添加行
- `deleteRow()`: 删除当前行
- `mergeCells()`: 合并选中的单元格
- `splitCell()`: 拆分当前单元格

## 许可证

本项目采用 [MIT license](../../LICENSE) 开源协议。
npm package: @nick-editor/extension-table-handler
Description: table handler extension for tiptap
Author: little-thing
Latest version: 1.0.4

# @nick-editor/extension-table-handler

这是一个用于处理表格操作的 Tiptap 扩展。

## 安装

```bash
npm install @nick-editor/extension-table-handler
```

## 使用

```js
import { Editor } from '@tiptap/core'
import TableHandler from '@nick-editor/extension-table-handler'

new Editor({
  extensions: [
    TableHandler,
    // ... 其他扩展
  ],
})
npm package: @nick-fox-scala/core-ui
Description: ###### Typescript support. More to come.
Author: Nick Fox
Latest version: 0.1.15

# Scala Core:UI - React

###### Typescript support. More to come.

## Install component library

```
npm i @nick-fox-scala/core-ui;
```

## Import component library

```
import { Button, Input } from '@nick-fox-scala/core-ui';
```
npm package: @nick-hill-dev/full-screen-canvas
Description: Easily create and manage any number of HTML canvas elements that fill the window and / or screen.
Author: Nick Hill
Latest version: 1.3.2

# FullScreenCanvas Library

The FullScreenCanvas library is a lightweight library that simplifies the process of creating and removing one or more full-screen HTML `<canvas />` elements. Each canvas occupies the full width and height of the window area, even if the window is resized.

To use this package in your software:

```bash
npm install @nick-hill-dev/full-screen-canvas
```

Examples are in the `demos` directory. To run them, execute the following commands:

```bash
npm install
npx tsc
npx rollup -c --bundleConfigAsCjs # Creates js file in the bin directory, and now you can open the pages in the demos directory
```

## Adding a Full-Screen Canvas

To add a full-screen canvas element to your web page, simply call the `add` method of the `FullScreenCanvas` class. By default, the canvas will be appended to the document.body element. However, you can optionally pass in a parent element to append the canvas to.

```js
const canvas = FullScreenCanvas.add(); // Appends the new Canvas element to document.body
```

or

```js
const parent = document.getElementById('my-canvas-container');
const canvas = FullScreenCanvas.add(parent);
```

It is also possible to make the canvas fill the whole screen rather than just the browser window, though it is necessary to do so as a result of a user action:

```js
window.onclick = () => {
    FullScreenCanvas.add(document.body, { fullScreen: true });
}
```

## Removing a Full-Screen Canvas

To remove a full-screen canvas element from your web page, simply call the remove method of the FullScreenCanvas class and pass in the canvas element that you wish to remove.

```js
FullScreenCanvas.remove(canvas);
```

## Example

```html
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>FullScreenCanvas Example</title>
</head>
<body>
    <script src="fullScreenCanvas.js"></script>
    <script>
        const canvas = FullScreenCanvas.add();
        const ctx = canvas.getContext('2d');
        ctx.fillStyle = 'red';
        ctx.fillRect(0, 0, canvas.width, canvas.height);
    </script>
</body>
</html>
```

## License

The FullScreenCanvas library was written by Nick Hill and is released under the MIT license. See LICENSE for more information.
npm package: @nick-huang/popo
Description: 胡搞亂搞的套件，任意下載後不付任何責任
Author: Nick Huang
Latest version: 0.0.6

# @nick-huang/popo

一個不知道在幹甚麼的套件，裡面有Vue3、Element-plus、Sass、Vite。

## Install
```bash
# 安裝前須先安裝 Element-plus、Scss
yarn add element-plus
yarn add sass

# 安裝本套件
yarn add @nick-huang/popo
```

## Use
#### template
```javascript
<template>
    <un-known />
</template>
```
#### script
```javascript
import { UnKnown } from '@nick-huang/popo';
import '@nick-huang/popo/style';
```
## License

[MIT](https://opensource.org/licenses/MIT)

Copyright (c) 2023-present, Nick Huang
npm package: @nick-iotex/g3o
Description: verify siwe msg and generate proof of location
Latest version: 2.0.1

## Install

Run `npm i @nick-iotex/g3o`

## HIW

Instantiate a new instance of a geolocation, like this: `const geolocation = new GeolocationVerifier()`. This constructor doesn't take any parameters for testnet. 

In order to call the mainnet API you'll need to specify it like this: `new GeolocationVerifier({isMainnet: true})`. 

In order to generate a Siwe message, you'll have to first create a location, like this: 

```typescript
geolocation.location = { 
    latitude: 47.658872,    // range [-90, 90]
    longitude: -27.4444,    // range [-180, 180]
    distance: 1000,         // range [0, infinity), meters
    from: 1676305034021,    // timestamp, unix milliseconds
    to: 1676305034488       // timestamp, unix milliseconds
    }
 ```
 
Or for scaled coordinates (e.g. latitude: 47658872, etc...) you can set a `scaledLocationArea` like this: 

```typescript
// sets location area
geolocation.scaledLocation = {
    scaled_latitude: -45500000,
    scaled_longitude: 123000000,
    distance: 100,
    from: 1676305034,   // timestamp, unix seconds
    to: 1676305035      // timestamp, unix seconds
    }
```

These values will be validated under the hood, and will be used in the `generateSiweMessage()` method: 


```typescript
// generates Siwe message and returns it as a string
const msg = geolocation.generateSiweMessage({
    domain: string,
    uri: string,
    address: string,
    })
```

You can now use any library of choice to sign this message and retrieve its signature. 

You can now set the signature you just retrieved like this: 

```typescript
// sets the signature
geolocation.signature = signature
```

You're now ready to call the `verifyLocation()` method which will not need any params. 

```typescript
const verifiedLocation = await geolocation.verifyLocation();
```

## Get Started

For a quick example of how this package works, check out this step-by-step *get-started* on the [iotex developers portal]()
npm package: @nick-iotex/w3bstream-http-client-simulator
Description: This README provides an overview of the Simulator module, which is designed to generate and send simulated data points to the W3BSTREAM server.
Author: Nicky Ru
Latest version: 1.2.2

# Simulator README

This README provides an overview of the Simulator module, which is designed to generate and send simulated data points to the W3BSTREAM server.

## Table of Contents

- Getting Started
- Usage
  - [Message Generator](#create-message-generator)
  - [Initialization](#simulator-initialization)
  - [Sending Messages](#sending-messages)

## Getting Started

To use the Simulator module, you need to import it along with some dependencies:

```javascript
import {
  Simulator,
  DataPointGenerator,
} from "@nick-iotex/w3bstream-http-client-simulator";
```

## Usage

### Create message generator

Deside what the shape of the data point should be:

```javascript
type TemperatureDataPoint = {
  temperature: number;
  timestamp: number;
};
```

And how the data point should be generated, you can use `randomizer` or `timestampGenerator` methods of DataPointGenerator: 

```javascript
const generatorFunction = () => ({
  temperature: DataPointGenerator.randomizer(0, 100),
  timestamp: DataPointGenerator.timestampGenerator(),
});
```

And finally, to generate messages, instantiate data generator:

```javascript
const dataGenerator = new DataPointGenerator<TemperatureDataPoint>(
  generatorFunction
);
```

### Simulator initialization

Create a new instance of the `Simulator` class, initialize it and set a `DataPointGenerator` that you created earlier:

```javascript
const simulator = new Simulator(pubId, pubToken, w3bstreamEndpoint);
simulator.init();
simulator.dataPointGenerator = dataGenerator;
```

You can also provide an optional `pathToPrivateKey` parameter:

```javascript
simulator.init(pathToPrivateKey);
```

Now you can generate a message with a single or multiple events:

```javascript
const message = simulator.generateEvents(numberOfDataPoints);
```

### Sending Messages

To send a single message to the server, call the `sendSingleMessage` method:

```javascript
const res = simulator.sendSingleMessage();
```

To send messages at a specified interval, use the `powerOn` method:

```javascript
simulator.powerOn(intervalInSec);
```

To stop sending messages, call the `powerOff` method:

```javascript
simulator.powerOff();
```