open-index/open-npm huggingface dataset:
npm package: @smake/args
Description: Typescript Module Template
Author: Yu Chen
Latest version: 2.1.0

## C++ args
```c++
#include <args.h>
#include <cstdlib>
#include <iostream>
#include <stdexcept>

int main(int argc, char **argv) {
  bool extra;
  auto flag_bool(verbose, false, 'v', "verbose", "xxxxxxxxxxxxx");
  flag_bool(extra, true, 'x', "extra", "xxxxxxxxxxxxx");
  auto flag_int(number, 3, 'n', "num", "xxxxxxxxxxxxx");
  auto flag_double(dv, 1.1, 'd', "double", "xxxxxxxxxxxxx");
  auto flag_uint64(u64, 2, 'u', "", "xxxxxxxxxxxxx");
  auto flag_string(s, "xx", ' ', "ss", "xxxxxxxxxxxxx");
  auto flag_bool(h, false, 'h', "help", "xxxxxxxxxxxxx");
  auto help = flag_help("Usage: exe [options] <output>");
  try {
    flag_parse(argc, argv);
  } catch (std::runtime_error &e) {
    std::cerr << e.what() << std::endl;
    std::cout << help;
    std::exit(1);
  }
  if (h) {
    std::cout << help;
    std::exit(0);
  }
  for (auto arg : flag_args)
    std::cout << arg << std::endl;

  std::cout << "Verbose mode is " << (verbose ? "ON" : "OFF") << std::endl;
  std::cout << "Extra mode is " << (extra ? "ON" : "OFF") << std::endl;
  std::cout << "n: " << number << std::endl;
  std::cout << "d: " << dv << std::endl;
  std::cout << "u: " << u64 << std::endl;
  std::cout << "s: " << s << std::endl;
}

```
npm package: @smake/cmake
Description: Typescript Module Template
Author: Yu Chen
Latest version: 1.1.5

```js
const { Conan, Cmake } = require('@smake/cmake');

const zlib = new Conan('zlib/1.2.11', 'x86_64-pc-windows-msvc');
const openssl = new Conan('openssl/1.1.1l', 'x86_64-pc-windows-msvc');
const libcurl = new Conan('libcurl/7.79.1', 'x86_64-pc-windows-msvc');
const co = new Cmake('../co', 'x86_64-pc-windows-msvc');
co.searchPaths = [
  ...zlib.installDirs,
  ...openssl.installDirs,
  ...libcurl.installDirs,
];
// co.flags = `-DBUILD_ALL=ON`;
co.flags = `-DWITH_LIBCURL=ON -DWITH_OPENSSL=ON -DBUILD_ALL=ON -DSTATIC_VS_CRT=ON`;
// co.env.LDFLAGS = '-framework Cocoa -framework SystemConfiguration -framework Security';

module.exports = [
  zlib,
  openssl,
  libcurl,
  co,
];
```
npm package: @smake/co-udp
Description: Typescript Module Template
Author: Yu Chen
Latest version: 1.0.2

# C++ UDP Class
## Dependencies
- [co](https://github.com/kuyoonjo/smake-lib-co.git)
- [buffer](https://github.com/kuyoonjo/smake-lib-buffer.git)

## ipaddr.h
```c++
namespace ex {

struct ipv {};

struct v4 : ipv {
  using sockaddr_t = sockaddr_in;
  static inline auto domain = AF_INET;
};
struct v6 : ipv {
  using sockaddr_t = sockaddr_in6;
  static inline auto domain = AF_INET6;
};

template <typename T> struct ipaddr {
  static_assert(std::is_base_of<ipv, T>::value, "T must inherit from ipv");
  explicit ipaddr() {}
  explicit ipaddr(const fastring &ip, uint16 port);
  explicit ipaddr(const typename T::sockaddr_t &addr);
  fastring ip() const;
  uint16 port() const;
  typename T::sockaddr_t sockaddr;
};

inline bool operator==(const ex::ipaddr<ex::v4> &c1,
                       const ex::ipaddr<ex::v4> &c2);

inline bool operator!=(const ex::ipaddr<ex::v4> &c1,
                       const ex::ipaddr<ex::v4> &c2);
inline bool operator==(const ex::ipaddr<ex::v6> &c1,
                       const ex::ipaddr<ex::v6> &c2);

inline bool operator!=(const ex::ipaddr<ex::v6> &c1,
                       const ex::ipaddr<ex::v6> &c2);
```

## udp.h
```c++
namespace ex {
template <typename T> class udp {
  static_assert(std::is_base_of<ipv, T>::value, "T must inherit from ipv");

public:
  explicit udp();

  int bind(const ipaddr<T> &ia);
  int recvfrom(int ms = -1);

  int sendto(char const *str, const ipaddr<T> &dst_ipaddr, int ms = -1) {
    return co::sendto(m_socket, str, std::strlen(str), &dst_ipaddr.sockaddr,
                      sizeof(dst_ipaddr.sockaddr), ms);
  }

  template <typename U>
  int sendto(U *buf, size_t size, const ipaddr<T> &dst_ipaddr, int ms = -1);

  template <typename U>
  int sendto(const U &t, const ipaddr<T> &dst_ipaddr, int ms = -1) const;

  template <typename U>
  int sendto(U &&t, const ipaddr<T> &dst_ipaddr, int ms = -1) const;

  template <typename U>
  int sendto(std::initializer_list<U> t, const ipaddr<T> &dst_ipaddr,
             int ms = -1);

  ex::shared_buffer recv_buffer();
  ipaddr<T> &rmt_ipaddr();
};

} // namespace ex

```
npm package: @smake/fmt
Description: Typescript Module Template
Author: Yu Chen
Latest version: 2.2.2

# SMake C++ lib fmt
[fmt v9.1.0](https://github.com/fmtlib/fmt/tree/9.1.0)

```js
const { LLVM } = require('@smake/llvm');
const { vscode } = require('@smake/llvm-vscode');
const { LibFmt } = require('@smake/fmt');

const target = 'aarch64-apple-darwin';
const fmt = new LibFmt(target);
const test = new LLVM('test', target);
test.files = ['src/test.cc'];
LibFmt.config(test);
vscode(test);

module.exports = [fmt, test];
```
npm package: @smake/json5
Description: Typescript Module Template
Author: Yu Chen
Latest version: 2.0.1

# SMake C++ lib json5
[json5pp](https://github.com/kimushu/json5pp/tree/master)

```js
const { LLVM } = require('@smake/llvm');
const { vscode } = require('@smake/llvm-vscode');
const { LibJson5 } = require('@smake/json5');

const test = new LLVM('test', 'aarch64-apple-darwin');
test.files = ['src/test.cc'];
LibJson5.config(test);
vscode(test);

module.exports = [test];
```
npm package: @smake/libs
Description: SMake thirdparty libraries support
Author: Yu Chen
Latest version: 1.2.1

# SMake 三方库支持

## 安装
```
npm i -D @smake/libs
```
## 使用方法
```js
const { LLVM_Darwin } = require('smake');
const { addLibs } = require('@smake/libs');

class A extends LLVM_Darwin {
  files = ['src/main.cc'];
}

A = addLibs(A, lib1, lib2, ...);
```
npm package: @smake/llvm
Description: smake LLVM toolchain
Author: Yu Chen
Latest version: 1.2.5

# @smake/llvm

```js
// smake.js
const { Fn, Shell } = require('@smake/utils');

const target = 'armv7-unknown-linux-gnu';

const executable = new LLVM('executable', target);
executable.files = ['examples/src/main.c'];

const static = new LLVM('static', target);
static.type = 'static';
static.files = ['examples/src/lib.cpp'];

const static_executable = new LLVM('static_executable', target);
static_executable.files = ['examples/src/libmain.cpp'];
static_executable.libs.push(static);

const shared = new LLVM('shared', target);
shared.type = 'shared';
shared.files = ['examples/src/dll.cpp'];

const shared_executable = new LLVM('shared_executable', target);
shared_executable.files = ['examples/src/dllmain.cpp'];
shared_executable.libs.push(shared);

module.exports = [
  executable,
  static,
  static_executable,
  shared,
  shared_executable,
];
```
npm package: @smake/llvm-vscode
Description: smake LLVM vscode implementation
Author: Yu Chen
Latest version: 1.0.1

# @smake/llvm-vscode

```js
// smake.js
const { LLVM } = require('@smake/llvm');
const { vscode } = require('@smake/llvm-vscode');

const target = 'x86_64-unknown-linux-gnu';

const executable = new LLVM('executable', target);
executable.files = ['examples/src/main.c'];

vscode(executable);

module.exports = [executable];
```
npm package: @smake/log
Description: Typescript Module Template
Author: Yu Chen
Latest version: 2.1.1

# C++ Log Library
```c++
#include <ex/log.h>
#include <iostream>
#include <thread>

int main() {
  ex::log::init("test.log");
  ex::log::level = ex::log::Level::info;
  ex::log::rotate_max_size = 1024 * 10;
  ex::log::rotate_retain = 5;
  ex::log::print_file_line = false;
  ex::log::rotate_compress = true;
  ex::log::start();

  for (int i = 0; i < 10; ++i) {
    std::thread([]() {
      for (int j = 0;; ++j) {
        Logi(j);
        std::this_thread::sleep_for(10ms);
      }
    }).detach();
  }

  for (int i = 0; i < 500; ++i) {
    std::this_thread::sleep_for(10ms);
    ex::log::flush();
    std::cout << "flush: " << i << std::endl;
  }
  ex::log::close();
  std::this_thread::sleep_for(1s);
  return 0;
}
```
npm package: @smake/node-addon
Description: smake node.js addon implementation
Author: Yu Chen
Latest version: 1.0.1

# @smake/node-addon

```js
// smake.js
const { NodeAddon } = require('@smake/node-addon');

const target = 'armv7-unknown-linux-gnu';

const node_addon = new NodeAddon('node_addon', target);
node_addon.files = ['examples/src/addon.cc', 'examples/src/Greeter.cc'];

module.exports = [
  node_addon,
];
```
npm package: @smake/os
Description: Typescript Module Template
Author: Yu Chen
Latest version: 2.3.0

# C++ OS library
[toc]

## std::string ex::os::arch()
```c++
#include <ex/os.h>
#include <iostream>

int main() {
  auto arch = ex::os::arch();
  std::cout << arch << std::endl;
    return 0;
}
```
## std::string ex::os::homedir()
```c++
#include <ex/os.h>
#include <iostream>

int main() {
  auto dir = ex::os::homedir();
  std::cout << dir << std::endl;
    return 0;
}
```
## std::vector<network_interface_t> ex::os::network_interfaces()
```c++
#include <cstdio>
#include <ex/os.h>
#include <iostream>

int main(int argc, char **argv)
{
  auto nis = ex::os::network_interfaces();
  auto hasIp = ex::os::filter_network_interfaces(nis, ex::os::network_interface_filter::has_ip, ex::os::ip_family::all);
  for (auto it = hasIp.begin(); it != hasIp.end(); ++it)
  {
    std::printf("%s %02x:%02x:%02x:%02x:%02x:%02x\n", it->name.c_str(), it->mac[0], it->mac[1], it->mac[2], it->mac[3], it->mac[4], it->mac[5]);
    for (auto itr = it->ips.begin(); itr != it->ips.end(); ++itr)
    {
      std::string family = "unknown";
      switch (itr->family)
      {
      case ex::os::ip_family::ipv4:
        family = "ipv4";
        break;
      case ex::os::ip_family::ipv6:
        family = "ipv6";
        break;
      default:
        break;
      }
      std::cout << "\t" << family << " " << itr->addr << " " << (int)itr->cidr << std::endl;
    }
  }

  return 0;
}
```
## std::string ex::os::tmpdir()
```c++
#include <ex/os.h>
#include <iostream>

int main() {
  auto dir = ex::os::tmpdir();
  std::cout << dir << std::endl;
    return 0;
}
```
npm package: @smake/queue
Description: Typescript Module Template
Author: Yu Chen
Latest version: 2.3.0

# C++ Queue Library
```c++

namespace ex {
class safe_queue; // 线程安全队列
} // namespace ex
```
```c++
#include <chrono>
#include <ex/safe_queue.h>
#include <iostream>
#include <string>
#include <thread>

using namespace std::chrono_literals;

ex::safe_queue<std::string> q;

int main() {
  std::thread t1([]() {
    while (true) {
      std::this_thread::sleep_for(1s);
      q.enqueue("I will kill you!");
    }
  });

  std::thread t2([]() {
    while (true) {
      auto msg = q.dequeue();
      std::cout << msg << std::endl;
    }
  });

  t1.join();
  t2.join();
  return 0;
}
```
npm package: @smake/socket
Description: Typescript Module Template
Author: Yu Chen
Latest version: 2.3.2

# C++ Socket 扩平台

## 例子
```c++
#include <cassert>
#include <iostream>
#include <ex/udp.h>

int main() {
  ex::ipaddr ia1("0.0.0.0", 8080);
  ex::ipaddr ia2("0.0.0.0", 8081);
  ex::ipaddr ia3("127.0.0.2", 8080);
  ex::ipaddr ia4("0.0.0.0", 8080);
  ex::ipaddr<ex::v6> i6a1("::1", 8080);
  ex::ipaddr<ex::v6> i6a2("::1", 8081);
  ex::ipaddr<ex::v6> i6a3("::2", 8080);
  ex::ipaddr<ex::v6> i6a4("::1", 8080);

  assert(ia1 != ia2);
  assert(ia1 != ia3);
  assert(ia1 == ia4);

  assert(i6a1 != i6a2);
  assert(i6a1 != i6a3);
  assert(i6a1 == i6a4);

  std::cout << "IP Pass!" << std::endl;
  
  ex::socket::startup();

  ex::udp u1;
  u1.bind(ia1);

  ex::udp<ex::v6> u2;
  u2.bind(i6a2);

  auto &u = u1;
  while (1) {
    u.recvfrom();
    auto rb = u.recv_buffer();
    std::cout << rb << std::endl;
    u.sendto(rb, u.rmt_ipaddr());
    u.sendto({2, 1, 1}, u.rmt_ipaddr());
    u.sendto("456", u.rmt_ipaddr());
  }

  u.close();
  u.shutdown(SHUT_RDWR);
  ex::socket::cleanup();
  return 0;
}
```
npm package: @smake/string
Description: Typescript Module Template
Author: Yu Chen
Latest version: 2.0.0

# C++ string tools
```c++
#include <array>
#include <cassert>
#include <ex/string.h>
#include <iostream>
#include <regex>
#include <string>
#include <tuple>
#include <vector>

int main() {
  std::string s1 = "  abc de fg ";
  std::string s2 = "  abc de fg ";
  std::string s3 = "  abc de fg ";
  ex::string::trim_start(s1);
  ex::string::trim_end(s2);
  ex::string::trim(s3);
  assert(s1 == "abc de fg ");
  assert(s2 == "  abc de fg");
  assert(s3 == "abc de fg");

  ex::string::replace(s1, "abc", "");
  assert(s1 == " de fg ");

  auto v1 = ex::string::split(s1, ' ');
  assert(v1.size() == 4);
  assert(v1[0] == "");
  assert(v1[1] == "de");
  assert(v1[2] == "fg");
  assert(v1[3] == "");

  ex::string::trim(s1);
  assert(ex::string::match(s1, "^d.*g$"));

  std::string s4 = "de 3dy de";
  assert(ex::string::starts_with(s4, "d"));
  assert(ex::string::starts_with(s4, "de"));
  assert(ex::string::ends_with(s4, "dy de"));
  assert(ex::string::ends_with(s4, "e"));

  ex::string::to_upper_case(s4);
  assert(s4 == "DE 3DY DE");
  ex::string::to_lower_case(s4);
  assert(s4 == "de 3dy de");

  ex::string::pad_start(s4, 12, '-');
  assert(s4 == "---de 3dy de");
  ex::string::pad_end(s4, 15, '!');
  assert(s4 == "---de 3dy de!!!");

  std::vector v2{0, 1, 2};
  auto s5 = ex::string::join(v2.begin(), v2.end(), "-");
  assert(s5 == "0-1-2");
  const char* v3[] = {"1", "2", "ss"};
  auto s6 = ex::string::join(v3, v3 + 3, ":");
  assert(s6 == "1:2:ss");
  std::array<char, 3> v4{'1', '2', 's'};
  auto s7 = ex::string::join(v4.begin(), v4.end(), "/");
  assert(s7 == "1/2/s");
  auto s8 = ex::string::join(std::make_tuple(1, 2, "xx"), "/");
  assert(s8 == "1/2/xx");

  std::cout << "pass!" << std::endl;
  return 0;
}
```
npm package: @smake/utils
Description: Typescript Module Template
Author: Yu Chen
Latest version: 1.0.3

# @smake/utils

```js
// smake.js
const { Fn, Shell } = require('@smake/utils');

module.exports = [
  new Fn('1', () => console.log('Fn OK')),
  new Shell('2', 'echo', ['Shell OK']),
  new Shell('3', 'ls'),
];
```
npm package: @smakss/convert-numbers
Description: Convert Numbers transforms Arabic and Persian numerals to English, ensuring data uniformity in multilingual environments. Ideal for user input standardization and database consistency.
Author: SMAKSS
Latest version: 2.1.0

# Convert Numbers

![npm](https://img.shields.io/npm/v/@smakss/convert-numbers) ![NPM](https://img.shields.io/npm/l/@smakss/convert-numbers) ![npm](https://img.shields.io/npm/dt/@smakss/convert-numbers) ![npm bundle size (scoped)](https://img.shields.io/bundlephobia/min/@smakss/convert-numbers)

Convert Numbers is a utility package designed to ensure consistency in data transfer by converting Arabic and Persian numerals to English numerals. This tool is essential when user inputs might originate from different keyboard settings, requiring standardization of all digits to English format before further processing or database storage.

## Demo

Check out the working demo on CodeSandbox:

[![View @smakss/convert-numbers](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/smakss-convert-numbers-bstmfj?fontsize=14&hidenavigation=1&theme=dark)

## Installation

Install the package using npm or yarn:

```bash
npm i @smakss/convert-numbers
# or
yarn add @smakss/convert-numbers
```

## Usage

Import `convertNumbers` into your project as a CommonJS or ECMAScript module:

ECMAScript Modules:

```js
import ConvertNumbers from '@smakss/convert-numbers';
```

Then, use the function like this:

```js
// Converts Persian numbers to '1234567890'
console.log(ConvertNumbers('۱۲۳۴۵۶۷۸۹۰'));

// Converts Arabic numbers to '1234567890'
console.log(ConvertNumbers('١٢٣٤٥٦٧٨٩٠'));

// Returns an empty string for no input
console.log(ConvertNumbers());
```

## Features

- Robust conversion: Utilizes a mapping approach for efficiency and readability, with a fallback to regular expressions for longer strings.
- Error resilience: In case of unforeseen errors or compatibility issues, the function gracefully falls back to a basic `for-of` loop iteration.
- Wide compatibility: Designed to work across a variety of JavaScript environments.

## Documentation

For more detailed examples and information about the function usage, refer to the JSDoc comments in the source code.

## Contributing

We welcome contributions! For guidelines on how to contribute, please check [CONTRIBUTING.md](./CONTRIBUTING.md).

## Code of Conduct

We are committed to fostering a welcoming and positive community. Please see our [Code of Conduct](./CODE_OF_CONDUCT.md) for more information.
npm package: @smakss/random-array-element
Description: Efficiently select unique, non-repeating random elements from arrays with @smakss/random-array-element. Ideal for varied applications needing random but exhaustive array item selection.
Author: SMAKSS
Latest version: 2.0.3

# Random Array Element without Repetition

![npm](https://img.shields.io/npm/v/@smakss/random-array-element) ![NPM](https://img.shields.io/npm/l/@smakss/random-array-element) ![npm](https://img.shields.io/npm/dt/@smakss/random-array-element) ![npm bundle size (scoped)](https://img.shields.io/bundlephobia/min/@smakss/random-array-element)

Selecting a random element from an array is simple with `Math.random()`. However, if you need to ensure that each element is only selected once until all elements have been chosen, `@smakss/random-array-element` is the ideal solution. Utilizing closures, this package allows you to initialize a function once and then repeatedly obtain unique, randomly-selected elements from your array, without repeats until the array is exhausted.

## Demo

You can check the [working demo](https://runkit.com/smakss/random-array-element) on RunKit.

or

[![View @smakss/random-array-element](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/smakss-random-array-element-7yizos?fontsize=14&hidenavigation=1&theme=dark)

## Installation

Install the package using npm or Yarn:

```bash
npm i @smakss/random-array-element
# or
yarn add @smakss/random-array-element
```

## Usage

To include it with CommonJS module you can do this:

```js
const randomArrayElement = require('@smakss/random-array-element');
```

For ECMAScript modules:

```js
import randomArrayElement from '@smakss/random-array-element';
```

Example usage:

```js
// Initialize once for an array
const getRandomElement = randomArrayElement(['apple', 'banana', 'cherry']);

console.log(getRandomElement()); // Result: 'banana' (example output)
console.log(getRandomElement()); // Result: 'apple' (example output)
// ...after all items have been returned, it resets.
console.log(getRandomElement()); // Result: 'cherry' (example output)
// ...continues to return a new random item.
```

If an empty or non-array input is passed, the function will return -1, indicating no selection can be made:

```js
const getRandomElement = randomArrayElement([]);
console.log(getRandomElement()); // Result: -1
```

## Contributing

Contributions are welcome! Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines and details.

## Code of Conduct

To ensure a welcoming and safe community, our [Code of Conduct](./CODE_OF_CONDUCT.md) outlines expected behaviors for all participants.
npm package: @smakss/random-string
Description: Effortlessly generate customizable random strings with @smakss/random-string. Ideal for creating dummy strings, custom-length passwords, or unique identifiers. Integrates seamlessly with both CommonJS and ECMAScript modules.
Author: SMAKSS
Latest version: 2.0.2

# Generate random string

![npm](https://img.shields.io/npm/v/@smakss/random-string) ![NPM](https://img.shields.io/npm/l/@smakss/random-string) ![npm](https://img.shields.io/npm/dt/@smakss/random-string) ![npm bundle size (scoped)](https://img.shields.io/bundlephobia/min/@smakss/random-string)

This package will generate a random dummy string based on the available set of characters or provided ones, and you can also indicate the length of your desired random string. In case you don't care about uniqueness and don't want to use UUID, this package will help you to achieve what you want.

If you're in need of a UUID generation library, take a look at [@smakss/uuid](https://www.npmjs.com/package/@smakss/uuid), which offers robust UUID creation capabilities. For those who require more tailored options, [@smakss/password-generator](https://www.npmjs.com/package/@smakss/password-generator) provides a versatile solution for crafting custom passwords to fit a variety of needs.

## Demo

You can check the [working demo](https://runkit.com/smakss/random-string) in runkit.

or

[![View @smakss/random-string](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/smakss-random-string-xlf6d2?fontsize=14&hidenavigation=1&theme=dark)

## How it works?

To install it you can simply do the following command:

```bash
npm i @smakss/random-string
or
yarn add @smakss/random-string
```

To include it with a common js module you should do this:

```js
const randomString = require('@smakss/random-string');
```

And to include it with an ECMAScript module you can simply do this one:

```js
import randomString from '@smakss/random-string';
```

## Examples of usage

Then to use it within your application you can do it just like this:

Generate a random string with default parameters:

```js
randomString();

// Result example: 'GkL9#z$P!2'
```

**NOTE:** If the `length` is not provided, it will be selected randomly between 1 and 20.

Generate a random string with a specified length:

```js
randomString({ length: 10 });

// Result example: 'Sg67&ZpQ8!'
```

You can provide both length and allowed characters:

```js
randomString({ length: 10, allowedCharacters: 'abCD#@' });

// Result example: 'b@@#aDaC##'
```

## Contributing

Interested in making contributions to this project? Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines and details.

## Code of Conduct

We value and prioritize the well-being of all our contributors and users. To ensure that this project remains a welcoming space for everyone, please refer to our [Code of Conduct](./CODE_OF_CONDUCT.md).
npm package: @smakss/uuid
Description: Generates random unique UUID string based on RFC 4122 approach.
Author: SMAKSS
Latest version: 2.1.0

# UUID

![npm](https://img.shields.io/npm/v/@smakss/uuid) ![NPM](https://img.shields.io/npm/l/@smakss/uuid) ![npm](https://img.shields.io/npm/dt/@smakss/uuid) ![npm bundle size (scoped)](https://img.shields.io/bundlephobia/min/@smakss/uuid)

In order to create a unique identifier, it's common to use a UUID (Universally Unique Identifier). This package generates a version 4 UUID compliant with [RFC 4122](https://www.ietf.org/rfc/rfc4122.txt) standards using pure JavaScript. The codebase for this project is inspired by the collective wisdom of the StackOverflow community.

<sub>**New in version `v2.1.0`**: Added an option to use cryptographic randomness via the Web Crypto API, enhancing the randomness quality of UUIDs where supported. This feature is optional and can be enabled during UUID generation.</sub>

## Demo

Check out the working demo on CodeSandbox:

[![View @smakss/uuid](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/smakss-uuid-x5cqpb?fontsize=14&hidenavigation=1&theme=dark)

## How it works?

To install the package, run the following command:

```bash
npm i @smakss/uuid
# or
yarn add @smakss/uuid
```

For CommonJS modules, include it like this:

```javascript
const uuid = require('@smakss/uuid');
```

For ECMAScript modules, import it as follows:

```javascript
import uuid from '@smakss/uuid';
```

Then, you can use it within your application like this:

```javascript
// Generate a new UUID using pseudo-random numbers
const uniqueID = uuid();
console.log(uniqueID); // Outputs: '123e4567-e89b-12d3-a456-426614174000' (example output)

// Generate a new UUID using cryptographic randomness (if supported)
const cryptoID = uuid(true);
console.log(cryptoID); // Outputs a UUID generated with cryptographic randomness
```

<sub>**NOTE:** Each call to `uuid()` generates a unique UUID, so the output will vary with each call. The cryptographic randomness option enhances the unpredictability of UUIDs in environments that support the Web Crypto API.</sub>

## Contributing

Interested in contributing to this project? Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines and details.

## Code of Conduct

To ensure a welcoming and positive experience for all contributors and users, we adhere to a [Code of Conduct](./CODE_OF_CONDUCT.md). Your cooperation is appreciated.
npm package: @smalk/analytics
Description: Smalk AI Analytics — Express middleware and React component for AI bot tracking
Latest version: 0.1.0

# @smalk/analytics

Smalk AI Analytics for Node.js — Express middleware for server-side AI bot tracking and a React component for client-side tracking.

## Installation

```bash
npm install @smalk/analytics
```

## Quick Start

### 1. Server-Side Tracking (Express Middleware)

Add the middleware early in your Express app to track AI bot visits server-side (ChatGPT, Perplexity, Claude, Gemini, etc.):

```typescript
import express from "express";
import { smalkTracking } from "@smalk/analytics";

const app = express();

// Add Smalk tracking — fires non-blocking requests, zero latency impact
app.use(smalkTracking({
  apiKey: process.env.SMALK_API_KEY,
}));

// ... rest of your app
```

The middleware:
- Sends a non-blocking POST to the Smalk API on every page request
- Forwards visitor headers (User-Agent, IP, Referer) for bot detection
- Skips static assets (`.css`, `.js`, `.png`, etc.) and health checks automatically
- Never blocks or slows down your response (fire-and-forget with 500ms timeout)

### 2. Client-Side Tracking (React Component)

Add the `SmalkTracker` component to inject the Smalk `tracker.js` script:

```tsx
import { SmalkTracker } from "@smalk/analytics/react";

function App() {
  return (
    <>
      <SmalkTracker projectKey="your-project-uuid" />
      {/* rest of your app */}
    </>
  );
}
```

Or add the script tag directly in your HTML:

```html
<script src="https://api.smalk.ai/tracker.js?PROJECT_KEY=your-project-uuid" async></script>
```

### 3. Get Your Project Key

Use the `fetchWorkspaceInfo` helper to retrieve your project key from the API key:

```typescript
import { fetchWorkspaceInfo } from "@smalk/analytics";

const workspace = await fetchWorkspaceInfo(
  process.env.SMALK_API_KEY,
  "https://api.smalk.ai"
);
console.log(workspace.projectKey); // UUID to use with SmalkTracker
```

## Options

### `smalkTracking(options)`

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `apiKey` | `string` | `process.env.SMALK_API_KEY` | Your Smalk API key |
| `apiBaseUrl` | `string` | `"https://api.smalk.ai"` | API base URL |
| `timeout` | `number` | `500` | Request timeout in ms |
| `excludePaths` | `string[]` | `[]` | Additional path prefixes to skip |
| `debug` | `boolean` | `false` | Log tracking errors to console |

### `<SmalkTracker />`

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `projectKey` | `string` | required | Your Smalk project UUID |
| `apiBaseUrl` | `string` | `"https://api.smalk.ai"` | API base URL |

## Why Both Server-Side and Client-Side?

- **Server-side** catches AI agents (ChatGPT, Perplexity, Claude) that don't execute JavaScript
- **Client-side** provides browser fingerprinting and session tracking for human visitors

Both layers work together to give you complete visibility into AI and human traffic.

## License

MIT — [Smalk](https://smalk.ai)
npm package: @small-components/flying-menu-plugin
Description: Plugin to enable flying animation on any text element
Author: Samuel Silva
Latest version: 0.3.2

# Flying Menu

This project was inspired on a linkedin post from [SuryaKant Borad](https://www.linkedin.com/in/suryakant-borad-085361240?miniProfileUrn=urn%3Ali%3Afs_miniProfile%3AACoAADvaUSUBtg3w6iu4S3aSauDjigA37HyFZ_c&lipi=urn%3Ali%3Apage%3Ad_flagship3_search_srp_all%3BDZdPN6kpTQefe8GxJEuaxA%3D%3D) where he created a similar animation, seen that I also wanted to experiment and give it a try on my own.

## Preview

https://user-images.githubusercontent.com/13966565/235767865-5916af51-1fcb-4d9f-920b-e2d7b88c06c6.mp4

## Run Locally

[Install Node](https://nodejs.org/en/download), [Install yarn](https://classic.yarnpkg.com/lang/en/docs/install/#mac-stable) and then clone the project:

```bash
  git clone https://github.com/samuelsilvadev/flying-menu-inspiration
```

Go to the project directory

```bash
  cd ./flying-menu-inspiration
```

Install dependencies

```bash
  yarn
```

Start the server

```bash
  yarn start
```

## Deployment

The examples are deployed automatically using github pages

## Contributing

Contributions are always welcome!

See `contributing.md` for ways to get started.

Please adhere to this project's `code of conduct`.

## License

[MIT](https://choosealicense.com/licenses/mit/)

## Acknowledgements

- [Suryakant Borad](https://github.com/Suryaset)
npm package: @small-monsters/show-toast
Description: 一个简单的Toast提示组件
Latest version: 0.0.1

# Show Toast

一个简单、轻量的 Toast 提示组件，用于在 Web 应用中显示提示信息。

## 特性

- 🚀 轻量级，无依赖
- 🎨 支持自定义样式和位置
- 🛡️ 支持阻止页面点击事件
- 📦 支持 ES 模块和 UMD 格式
- 🔄 使用 TypeScript 编写，提供完整类型支持
- 📏 支持多种尺寸单位配置（px, rem, em, %等）

## 安装

```bash
npm install @small-monsters/show-toast
```

或

```bash
yarn add @small-monsters/show-toast
```

## 使用方法

### 基本使用

```javascript
import showToast from '@small-monsters/showToast';

// 显示一个简单的 Toast
showToast('这是一条提示消息');
```

### 高级使用

```javascript
import showToast from '@small-monsters/showToast';

// 使用自定义选项
showToast('这是一条提示消息', {
  duration: 3000,            // 持续时间（毫秒）
  position: 'top',           // 位置：'top', 'center', 'bottom'
  preventClick: true,        // 是否阻止点击事件
  className: 'custom-toast', // 自定义类名
  width: '300px',            // 自定义宽度
  maxWidth: '80%',           // 自定义最大宽度
  fontSize: '16px',          // 自定义字体大小
  padding: '10px 20px'       // 自定义内边距
});
```

## API

### showToast(message, options?)

显示一个 Toast 提示消息。

#### 参数

- **message** `string` - 要显示的消息
- **options** `object` (可选) - 配置选项
  - **duration** `number` - Toast 显示的持续时间（毫秒），默认为 2000
  - **position** `'top' | 'center' | 'bottom'` - Toast 的位置，默认为 'center'
  - **preventClick** `boolean` - 是否阻止页面点击事件，默认为 true
  - **className** `string` - 自定义类名
  - **width** `string` - Toast的宽度，支持各种CSS单位（px, rem, em, %等），默认为 'auto'
  - **maxWidth** `string` - Toast的最大宽度，支持各种CSS单位（px, rem, em, %等），默认为 '80%'
  - **fontSize** `string` - Toast的字体大小，支持各种CSS单位（px, rem, em等），默认为 '16px'
  - **padding** `string` - Toast的内边距，支持各种CSS单位（px, rem, em等），默认为 '10px 20px'

## 浏览器直接引用

```html
<link rel="stylesheet" href="path/to/show-toast/dist/showToast/index.css">
<script src="path/to/show-toast/dist/showToast/index.umd.js"></script>
<script>
  // 通过全局变量 ShowToast 使用
  ShowToast.showToast('这是一条提示消息');
</script>
```
npm package: @small-project/collection
Description: Type-safe Collection utilities for JS/TS
Author: Sébastien Kus
Latest version: 1.0.0

# @small-project/collection

A lightweight, dependency-free **TypeScript collection library** offering convenient manipulation and transformation utilities for lists, maps, numbers, and strings.

---

## Documentation

| Module | Description |
|--------|--------------|
| [Collection](./doc/collection.md) | Base generic collection class |
| [NumberCollection](./doc/number-collection.md) | Mathematical utilities for numeric arrays |
| [StringCollection](./doc/string-collection.md) | String transformation and filtering tools |

---

## 🚀 Installation

```bash
npm install @small-project/collection
```

---

## Usage Example

```ts
import NumberCollection from "@small-project/collection/dist/esm/collection/number-collection.js";

const nums = new NumberCollection([1, 2, 3, 4]);
console.log(nums.mean()); // 2.5
console.log(nums.multiply(2).values()); // [2, 4, 6, 8]
```

---

## Key Features

- 🔧 Type-safe and lightweight
- 🧮 Numeric operations (sum, mean, std, variance)
- 🔤 String operations (trim, case, slug, replace, etc.)
- 🧱 No dependencies
- ⚡ Ready for Node.js & ESM/CJS

---

## 📄 License
MIT License © 2025 Sébastien Kus
npm package: @small-project/nest-keycloak
Description: A lightweight, type-safe NestJS module integrating Keycloak authentication (JWT, roles, guards, and login flow).
Author: Sébastien Kus
Latest version: 0.7.1

# Small Nest Keycloak

Minimal, type-safe NestJS integration with Keycloak. ESM-only, strict TypeScript, no build output.
Includes a ready-to-use `AuthController`, JWT strategy (cookie/header), role decorator and guards.

## Quick Start (NestJS)

```ts
import { Module } from '@nestjs/common';
import { KeycloakModule } from '@small/nest-keycloak';

@Module({
  imports: [
    KeycloakModule.register({
      baseUrl: process.env.KEYCLOAK_BASE_URL ?? 'http://localhost:8080/auth',
      realm: process.env.KEYCLOAK_REALM ?? 'master',
      clientId: process.env.KEYCLOAK_CLIENT_ID ?? 'nest-app'
    }),
  ],
})
export class AppModule {}
```

### Guards and roles

```ts
import { Controller, Get, UseGuards } from '@nestjs/common';
import { JwtAuthGuard, RolesGuard, Roles } from '@small/nest-keycloak';

@Controller('users')
@UseGuards(JwtAuthGuard, RolesGuard)
export class UserController {
  @Get()
  @Roles('admin')
  list() { return ['user1']; }
}
```

## Example `.env`

```bash
KEYCLOAK_BASE_URL=http://localhost:8080/auth
KEYCLOAK_REALM=master
KEYCLOAK_CLIENT_ID=nest-app
ACCESS_COOKIE=access_token
REFRESH_COOKIE=refresh_token
PORT=3000
```

## License

MIT © 2025 Sébastien Kus