open-index/open-npm huggingface dataset:
npm package: @sangreprimitiva/tranqui
Description: Run sync/async functions and get a typed Result: value() or error() for explicit error handling.
Author: sangreprimitiva
Latest version: 1.0.1

# tranqui

Unified wrapper (sync + async) that returns a typed **Result** with either the **value or the error** (no throws). Same API for both worlds.
`tranqui` executes the function immediately (no microtask deferral); if it returns a Promise, the Promise is awaited; if it throws synchronously, the error is captured.

## Installation

```sh
npm i @sangreprimitiva/tranqui
```

## Usage

```ts
import { tranqui } from '@sangreprimitiva/tranqui';

// Sync function
function double(n: number) {
	if (n < 0) throw new Error('Negative not allowed');
	return n * 2;
}

// Async function
async function fetchUserName(id: number): Promise<string> {
	if (id === 0) throw new Error('User not found');
	return `User-${id}`;
}

const r1 = await tranqui(double, 5);
if (r1.hasError()) {
	// Handle error
	console.error(r1.error());
}
// r1.value() has the successful result

const r2 = await tranqui(fetchUserName, 7);
if (r2.hasError()) {
	// Handle error
	console.error(r2.error());
}
// r2.value() has the successful result
```

## API

```ts
export type TranquiResult<T> = {
	value(): T | null; // returns the value when successful
	error(): Error | null; // returns the error when failed
	hasError(): boolean; // true if there was an error
	readonly ok: boolean; // same as !hasError(), convenient for logging
	readonly errorValue?: Error; // raw error for debugging/logging
};

export function tranqui<TArgs extends any[], TReturn>(
	fn: (...args: TArgs) => TReturn,
	...args: TArgs
): Promise<TranquiResult<Awaited<TReturn>>>;
```

### Behavior

-   **Immediate execution**: `fn` runs right away; if it returns a Promise, its resolution/rejection is handled.
-   **No throws to the caller**: inspect `.hasError()` (or `.ok`) and then read `.value()` or `.error()`.
-   **Error normalization**: non-`Error` rejections are converted to `Error` via `new Error(String(e))`.

## Why

-   One unified pattern for error handling across sync and async code.
-   Eliminates try/catch at call sites; makes error paths explicit and testable.
-   Ergonomic methods: `value()`, `error()`, `hasError()`, plus `ok` and `errorValue` for logging.

## Requirements

-   TypeScript 5.0+ (recommended). Node 18+ if targeting Node runtimes.

## License

MIT
npm package: @sangria-sdk/core
Description: Sangria payment network SDK for Express, Hono, Fastify, and Next.js
Latest version: 0.1.1

# @sangria-sdk/core

TypeScript SDK for accepting x402 payments. Supports Express, Fastify, and Hono.

## Install

```bash
pnpm add @sangria-sdk/core
```

## Quick Start

### Express

```typescript
import express from "express";
import { Sangria } from "@sangria-sdk/core";
import { fixedPrice } from "@sangria-sdk/core/express";

const app = express();
const sangria = new Sangria({
  apiKey: process.env.SANGRIA_SECRET_KEY,
  baseUrl: "https://api.sangria.net",
});

app.get(
  "/premium",
  fixedPrice(sangria, { price: 0.01, description: "Premium content" }),
  (req, res) => {
    // req.sangria.paid === true
    // req.sangria.transaction === "0x..."
    res.json({ data: "premium content" });
  }
);

app.listen(3000);
```

### Fastify

```typescript
import Fastify from "fastify";
import { Sangria } from "@sangria-sdk/core";
import { sangriaPlugin, fixedPrice } from "@sangria-sdk/core/fastify";

const app = Fastify();
const sangria = new Sangria({ apiKey: process.env.SANGRIA_SECRET_KEY });

await app.register(sangriaPlugin);

app.get(
  "/premium",
  { preHandler: fixedPrice(sangria, { price: 0.01 }) },
  (request, reply) => {
    // request.sangria.paid === true
    reply.send({ data: "premium content" });
  }
);

await app.listen({ port: 3000 });
```

### Hono

```typescript
import { Hono } from "hono";
import { Sangria } from "@sangria-sdk/core";
import { fixedPrice, getSangria } from "@sangria-sdk/core/hono";

const app = new Hono();
const sangria = new Sangria({ apiKey: process.env.SANGRIA_SECRET_KEY });

app.get("/premium", fixedPrice(sangria, { price: 0.01 }), (c) => {
  const payment = getSangria(c);
  // payment.paid === true
  return c.json({ data: "premium content" });
});

export default app;
```

## Bypass Payments

All adapters support a `bypassPaymentIf` option to skip payment for certain requests. This is useful if you want to let API key users access your endpoints for free while charging anonymous or agent-based callers via x402:

```typescript
fixedPrice(
  sangria,
  { price: 0.01 },
  {
    bypassPaymentIf: (req) => !!req.headers["x-api-key"],
  }
);
```

## Configuration

```typescript
const sangria = new Sangria({
  apiKey: "sg_live_...", // Required. Your Sangria merchant API key.
  baseUrl: "https://...", // Optional. Defaults to http://localhost:8080.
});
```

## How It Works

The `fixedPrice` middleware handles the x402 negotiation loop:

1. **First request** (no `payment-signature` header): calls Sangria's `/v1/generate-payment` endpoint, returns `402 Payment Required` with payment terms to the client.
2. **Retry** (with `payment-signature` header): forwards the signed payload to Sangria's `/v1/settle-payment` endpoint. On success, attaches payment data to the request and calls your handler.

## Requirements

- Node.js >= 18
- One of: Express >= 4, Fastify >= 4, or Hono >= 4
npm package: @sangtian152/html2pdf
Description: 将html生成pdf，依赖html2canvas和jspdf
Author: sangtian152
Latest version: 1.0.4

# html2pdf

## 介绍
将html生成pdf，依赖html2canvas和jspdf

### 安装
```
npm install @sangtian152/html2pdf --save
# or 
yarn add @sangtian152/html2pdf
```

### 使用
```
import html2pdf from '@sangtian152/html2pdf';

html2pdf(element, options);
```

### 参数

| 参数      | 说明    | 类型      | 可选值       | 默认值   |
|---------- |-------- |---------- |-------------  |-------- |
| element   | 要生成pdf的dom元素   | Element     |  —   |   —   |
| options   | 配置参数，详见options   | Object  |  —   |  —   |


### options

| 参数      | 说明    | 类型      | 可选值       | 默认值   |
|---------- |-------- |---------- |-------------  |-------- |
| title   | 生成的pdf文件名   | String        |  —   |   pdf   |
| scale   | html2canvas的放大倍数，值越大生成的pdf越清晰，但相应的会影响性能   | Number  |  —   |  —   |
| padding   | pdf页边距   | Array  |  —   |  —   |
| format   | pdf纸型   | String  |  —   |  A4   |
| orientation   | 方向（纵向、横向）   | String  |  P,L   |  P   |
| unit   | 单位   | String  |  —   |  pt   |
| stretch   | 当打印内容宽度小于pdf宽度时，是否拉伸   | Boolean  |  —   |  true  |
| background   | pdf背景色   | String  |  —   |  #ffffff   |
| useCORS   | 是否尝试使用CORS从服务器加载图像（需后端开启跨域）   | Boolean  |  —   |  false   |
| minimumUnit   | 最小分割单元，分页时最小分割单元不会被分成半截（如果单个最小分割单元高度已经超出PDF页面高度也会被分割）   | String  |  css选择器   |  —   |
| ignoreElements   | 设置排除元素，参数为当前dom元素，要求返回 Boolean   | Function  |  —   |  —   |


### 最新版本

[![NPM version](https://img.shields.io/npm/v/@sangtian152/html2pdf)](https://www.npmjs.com/package/@sangtian152/html2pdf)
npm package: @sangtian152/stl
Description: 由于`vue`无法监听es6中`Map`和`Set`对象方法，js模拟实现Map和Set对象
Latest version: 1.0.0

### js实现Map和Set


由于`vue`无法监听es6中`Map`和`Set`对象方法，js模拟实现Map和Set对象
npm package: @sangtian152/svg-icon
Description: git地址：http://172.31.119.30/roc2.0-ui/roc2.0-component/roc2.0-component-platform
Latest version: 0.1.3

# `SAAS` 平台 `roc-component-platform`

git地址：http://172.31.119.30/roc2.0-ui/roc2.0-component/roc2.0-component-platform

本地调试： http://localhost:9527/#/login?memberId=28098&appId=2332&orgId=58

平台接口文档：http://172.31.119.68:9001/platform/doc.html#/home

## 一、说明
+ 项目技术栈：vue@2.6.x + vue-router@3.2.x + vuex@3.4.x + element-ui@2.15.x
+ `vue create roc-component-platform`
+ `cd roc-component-platform`
+ `yarn install` or `npm install`
+ `yarn add element-ui`

## 二、开发说明
+ `master` 分支为主分支，只在发版时将开发分支代码合并到此分支
+ `develop2.0` 分支为开发的基线分支，开发时基于些分支切分支进行开发，完成功能开发后将代码合并到此分支发布到开发环境
npm package: @sangtian152/vue3-sign
Description: ## 介绍 一个简易签名组件，基于vue3和canvas。
Author: sangtian152
Latest version: 0.0.6

# vue3-sign

## 介绍
一个简易签名组件，基于vue3和canvas。

### 安装
```
npm i @sangtian152/vue3-sign -S
# or 
yarn add @sangtian152/vue3-sign
```

### 引入
```
import { createApp } from 'vue'
import vue3Sign from '@sangtian152/vue3-sign';
import "@sangtian152/vue3-sign/lib/style.css";

const app = createApp(App)

app.use(vue3Sign)
app.mount('#app')
```

### Attributes

| 参数      | 说明    | 类型      | 可选值       | 默认值   |
|---------- |-------- |---------- |-------------  |-------- |
| line-color     | 签名颜色   | String  |  —   |   #000000   |
| line-width    | 线条宽度   | Number  |  —   |  3  |
| canvas-width    | 画布宽度   | Number  |  —   |  —  |
| canvas-height   | 画布高度   | Number  |  —   |  —  |
| bg-color    | 画布背景色   | String  |  —   |  #f7f7f7  |
| img-bg-color    | 生成图片背景色   | String  |  —   |  tranparent  |
| erasable    | 是否启用橡皮擦   | Boolean  |  —   |  true  |
| eraser-radius    | 橡皮擦半径   | Number  |  —   |  6  |
| crop    | 是否裁剪图片   | Boolean  |  —   |  true  |
| footer    | 是否显示底部   | Boolean  |  —   |  false  |
| before-done    | 签名完成前调用，如果返回false会阻止默认签名完成事件   | Function  |  —   |  canvas  |


### Events

| 事件名      | 说明    | 返回值      |
|---------- |-------- |---------- |
| orientationchange | 移动设备旋转事件 | orientation  |
| on-clear | 清空画布事件  |  —   |
| on-done | 完成签名事件，返回签名生成的图片 | data:image/png;base64  |

### Methods

| 事件名      | 说明    | 返回值      |
|---------- |-------- |---------- |
| clear | 清空画布  |  —   |
| done | 完成签名 |  —   |

### 最新版本

[![NPM version](https://img.shields.io/npm/v/@sangtian152/vue3-sign)](https://www.npmjs.com/package/@sangtian152/vue3-sign)

### 文档

[说明文档](https://sangtian152.github.io/vue3-sign/).
npm package: @sangtian152/watermark
Description: 图片加文字水印、图片水印，支持多行
Author: sangtian152
Latest version: 1.0.9


[![OSCS Status](https://www.oscs1024.com/platform/badge/sangtian152/watermark.svg?size=small)](https://www.murphysec.com/dr/dmBdvWQwRPWkT1TNsW)

## 介绍
图片加水印，支持文字水印、图片水印，支持多行

### 安装
```
npm install @sangtian152/watermark --save
# or 
yarn add @sangtian152/watermark
```

### 使用
```
import watermark from '@sangtian152/watermark';

const can = new watermark(url, options);
can.addText('文字水印', {repeat: true, lineSpacing: 146, markSpacing: '50%' })
can.addText('测试水印居中', {repeat: false, fontSize: 36, position: {right: '50%', bottom:  '50%'}, translate: '50%,50%'})
can.addImage(mark, {repeat: true, markHeight: 26, lineSpacing: 146, start: 36})
can.draw(function() {
    console.log('水印设置成功')
    const img = can.getBase64()
})
```

### 参数

| 参数      | 说明    | 类型      | 可选值       | 默认值   |
|---------- |-------- |---------- |-------------  |-------- |
| url   | 要添加水印的图片地址   | String     |  —   |   —   |
| options   | 全局配置参数，详见options   | Object  |  —   |  —   |


### 方法

| 名称      | 说明    | 参数      |
|---------- |-------- |---------- |
| addText   | 添加文字水印   | text, options（当前水印配置参数）  |
| addImage   | 添加图片水印   | url, options（当前水印配置参数）  |
| draw   | 绘制图片，在addText/addImage之后调用   | callback:Function  |
| getBase64   | 获取图片base64地址，需在draw方法的回调函数内调用  | ——  |
| getBlob   | 获取Blob对象，需在draw方法的回调函数内调用   | ——  |
| getFile   | 获取File对象，需在draw方法的回调函数内调用   | ——  |

### options

| 参数      | 说明    | 类型      | 可选值       | 默认值   |
|---------- |-------- |---------- |-------------  |-------- |
| clip   | 添加水印区域，如：{type: 'rect', padding: '10%'}，type形状，可选值rect和circle，padding边距（参考css中padding用法），接受数组或逗号（,）隔开的字符串，支持百分数和数字  | Object        |  —   |   —   |
| defineClip   | 自定义水印区域，参数为canvas的context对象，支持调用canvas原生方法，绘制任意形状水印区域   | Function        |  —   |   —   |
| fontSize   | 文字水印字体大小   | Number        |  —   |   26   |
| fillStyle   | 文字水印字体颜色   | String  |  —   |  #ffffff   |
| globalAlpha   | 水印透明度   | Number  |  0-1之间小数   |  0.2   |
| position   | 水印位置   | Object  |  —   |  {left: 10, top: 10}   |
| crossOrigin   | 是否开启跨域（需后端支持）   | Boolean  |  —   |  false  |
| translate   | 水印根据给定的参数，从当前元素位置移动   | String/Array  |  —   |  0   |
| repeat   | 水印是否重复   | Boolean  |  —   |  false  |
| rotate   | 水印旋转角度，repeat为true时有效  | Number  |  —   |  -45   |
| start   | 水印起始位置，repeat为true时有效   | Number  |  —   |  0   |
| markSpacing   | 两个相邻水印间隔，repeat为true时有效  | Number/String  |  —   |  50%   |
| lineSpacing   | 两行相邻水印间隔，repeat为true时有效   | Number/String  |  —   |  60   |


### 最新版本

[![NPM version](https://img.shields.io/npm/v/@sangtian152/watermark)](https://www.npmjs.com/package/@sangtian152/watermark)
npm package: @sangtrandev/kompact
Description: Kompact is a TypeScript backend library for Express that leverages metadata programming using decorators. Inspired by NestJS, it provides a clean and declarative way to define routes, middleware, and request handlers, without using an Inversion of Control
Author: tranquangsang12.7@gmail.com
Latest version: 0.0.19

# Kompact

Kompact is a TypeScript backend library for Express that leverages metadata programming using decorators. Inspired by NestJS, it provides a clean and declarative way to define routes, middleware, and request handlers, without using an Inversion of Control (IoC) container.

## Features

- **Decorators for Routes**: Define your Express routes using decorators.
- **Middleware Support**: Easily attach middleware to your routes.
- **Request Handlers**: Simplify the process of handling requests and responses.
- **Metadata Programming**: Utilize metadata to manage route configurations and middleware.

## Installation

You can install Kompact via npm:

```bash
npm install @sangtrandev/kompact
```

## Usage

Here's an example of how to create a simple Express server using Kompact.

1. Setting Up Your Project

First, ensure your tsconfig.json has the following settings enabled:

```json
{
  "compilerOptions": {
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "target": "ES6",
    "module": "commonjs",
    "strict": true,
    "esModuleInterop": true
  }
}
```

2. Example 
   
Controller 

```ts
import {
  Auth,
  Controller,
  CurrentUser,
  Get,
  Post,
  Request,
  Response,
} from "@sangtrandev/kompact";

@Controller("cat")
export class CatController {
  @Get()
  getCat(req: Request, res: Response) {
    res.send("hello, I sent you a cat");
  }

  @Auth
  @Post()
  addCat(req: Request, res: Response, @CurrentUser user: any) {
    console.log(user);
  }
}
```

In app.ts

```ts
import { KompactApp } from "@sangtrandev/kompact";
import { CatController } from "@controllers/cat.controller";

const app = new KompactApp({
  controllers: [CatController],
  authenticator: (req, res, next) => {
    // const accessToken = req.headers["authorization"];
    // if (!accessToken) res.status(401);
    req.user = {
      name: "Sang tran",
    };
    return next();
  },
});

app.start(3001, () => {
  console.log(`running at ${3001}`);
});
```

Sorry 😢😢😢😢 I will update the docs later 🙏🙏🙏🙏

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## License

This project is licensed under the MIT License.

This `README.md` provides a clear overview of Kompact, including installation instructions, usage examples, and information on how to set up and run the project.
npm package: @sanguogege/calendar
Description: ts版本的日历生成器 LTS
Author: sanguogege
Latest version: 1.3.10


[![NPM Version](https://img.shields.io/npm/v/@sanguogege/calendar.svg?style=for-the-badge)](https://www.npmjs.com/package/@sanguogege/calendar)
[![](https://img.shields.io/npm/dm/@sanguogege/calendar.svg?style=for-the-badge)](https://www.npmjs.com/package/@sanguogege/calendar)



<p align="center"> <b>万年历生成器</b> </p>

### web构建工具使用:
`npm i @sanguogege/calendar`

```
import calendar from "@sanguogege/calendar";

const today  =  calendar.solar2lunar(2021, 3, 21)

```


### 传统页面直接复制/dist/index.iife.js 或者 /dist/index.umd.cjsindex.iife.js

```
<script src="./dist/index.iife.js"></script>
<script>
    const today  =  calendar.solar2lunar(2021, 3, 21)
</script>

 ```

### calendar 所有的方法。

##### 这两个是最主要的方法，常用的，还有一个自定义休息与调休日

- solar2lunar(y: number, m: number, d: number)
    - 未传参获得当天，传入阳历年月日获得详细的公历、农历object信息
- lunar2sola(y: number, m: number, d: number, isLeapMonth: boolean)
    - 传入农历年月日以及传入的月份是否闰月获得详细的公历、农历object信息


- Rest 查看当前的休息日与调休日，若没有添加则是插件自带。

- setRest= { } 
    - 设置休息日与调休日
    - 格式为: ` {
        2023:{
            xiu:['0101'],
            ban:['0202,0203'] 
        } 
    }`

- Festival 查看当前的节日信息，若没有添加则是插件自带。

- setFestival= { } 
    - 设置农历、公历节日信息，sFtv为公历，lFtv为农历
    - 格式为: `  {
            sFtv: {
                "0123": ["节日名称"]
            },
            lFtv: {
                "0109": ["节日名称"]
            }
        }`


- lYearDays (y: number) 
    - 返回农历y年一整年的总天数
- leapMonth (y: number)
    - 返回农历y年闰月是哪个月；若y年没有闰月 则返回0
- leapDays (y: number)
    - 返回农历y年闰月的天数 若该年没有闰月则返回0
- lMonthDays(y: number, m: number)
    - 返回农历y年m月（非闰月）的总天数，计算m为闰月时的天数请使用leapDays方法
- toChinaMonth (m: number)
    - 传入农历数字月份返回汉语通俗表示法
- toChinaDay(d: number)
    - 传入农历日期数字返回汉字表示法
- solarDays (y: number, m: number)
    - 返回公历(!)y年m月的天数
- solarFirstWeek (y: number, m: number)
    - 返回公历(!)y年m月的第一天是星期几
- toAstro(m: number, d: number)
    - 公历月、日判断所属星座
- getAnimal(y: number)
    - 年份转生肖[!仅能大致转换]  精确划分生肖分界线是“立春”
npm package: @sangupta/bedrock
Description: Bedrock: UI Component Library
Author: Sandeep Gupta
Latest version: 0.0.1

# Bedrock React Components

[![Build status](https://img.shields.io/github/actions/workflow/status/sangupta/bedrock/ci.yml?branch=main)](https://github.com/sangupta/bedrock/actions/workflows/ci.yml)
[![Coverage Status](https://coveralls.io/repos/github/sangupta/bedrock/badge.svg?branch=main)](https://coveralls.io/github/sangupta/bedrock?branch=main)

Bedrock is a [ReactJS][reactjs] UI component library built using [Typescript][typescript].
It uses [Bootstrap 5][bootstrap] CSS framework for styling. `bedrock` still follows the
classic way of including CSS in HTML file to decouple the design system from component
library and also to improve load performance by leveraging browser caching.

The library is built and tested against the latest versions (as of date):

* React 18.2.0
* Bootstrap 5.2.3
* Node 18

### NOTE: Rewrite in progress. Old code is in `bedrock-old` branch.

## Usage

1. Add `@sangupta/bedrock` as a dependency in your `package.json`

2. Update dependencies as:
```sh
# using npm
$ npm install --save @sangupta/bedrock

# using yarn
$ yarn add @sangupta/bedrock
```

3. Use the components in your application:

```js
import React from 'react';
import ReactDOM from 'react-dom';
import { Button } from '@sangupta/bedrock';

const HelloWorld = () => {
    return <Button label='Hello World' />
}

// for React 16/17
ReactDOM.render(<HelloWorld />, document.getElementById('root'));
```

## License

MIT License. Copyright (c) 2022, Sandeep Gupta.


<!-- Do not add any visible content below this line -->

[reactjs]: https://reactjs.org/
[typescript]: https://www.typescriptlang.org/
[bootstrap]: https://getbootstrap.com/