This commit is contained in:
Raven Scott
2026-02-19 17:20:02 -05:00
parent 3bc8a5eaaf
commit 8182ec1ea3
56 changed files with 3849 additions and 68 deletions
+68
View File
@@ -0,0 +1,68 @@
# libcrc
CRC32 implementation with ARM hardware acceleration and portable fallback.
## Install
Build as a C library; see repository for build instructions.
## Overview
- CRC32 with optional hardware acceleration.
- Portable fallback for unsupported platforms.
## Architecture
```mermaid
flowchart LR
A[Buffer] --> B[libcrc]
B --> C[CRC32]
```
## API
See `include/crc.h` for the public C API.
## Examples
### 1) Include header
```c
#include "crc.h"
```
### 2) Compute checksum
```text
Use the functions in crc.h to compute CRC32 values.
```
### 3) Verify data
```text
Compare computed CRC32 with expected value.
```
## Best Practices
- Use hardware acceleration where available.
## Performance Notes
- ARM acceleration improves throughput for large buffers.
## Security Considerations
- CRC32 is not cryptographic.
## Integration Notes
- Used by `crc-native` and `crc-universal`.
## Error Handling
- Check return codes from the C API.
## License
Apache-2.0
+67
View File
@@ -0,0 +1,67 @@
# libdaemon
Simple daemon spawning and management library in C.
## Install
Build as a C library; see repository for build instructions.
## Overview
- Start and manage background processes.
## Architecture
```mermaid
flowchart LR
A[Process] --> B[libdaemon]
B --> C[Daemon]
```
## API
See `include/daemon.h` for the public C API.
## Examples
### 1) Include header
```c
#include "daemon.h"
```
### 2) Spawn daemon
```text
Use daemon.h helpers to fork and detach.
```
### 3) Manage lifecycle
```text
Use API helpers to monitor or stop.
```
## Best Practices
- Ensure log redirection for daemon outputs.
## Performance Notes
- Minimal overhead beyond process creation.
## Security Considerations
- Drop privileges after daemonization when possible.
## Integration Notes
- Useful for background services in native apps.
## Error Handling
- Check return codes for spawn failures.
## License
Apache-2.0
+67
View File
@@ -0,0 +1,67 @@
# libdynload
Utilities for loading versioned dynamic libraries.
## Install
Build as a C library; see repository for build instructions.
## Overview
- Versioned dynamic library resolution and loading.
## Architecture
```mermaid
flowchart LR
A[Library name] --> B[libdynload]
B --> C[dlopen/LoadLibrary]
```
## API
See `include/dynload.h` for the public C API.
## Examples
### 1) Include header
```c
#include "dynload.h"
```
### 2) Load library
```text
Use dynload helpers to resolve a versioned library path.
```
### 3) Lookup symbols
```text
Use dynload APIs to get function pointers.
```
## Best Practices
- Validate library paths and versions.
## Performance Notes
- Dynamic loading cost occurs at startup.
## Security Considerations
- Avoid loading untrusted libraries.
## Integration Notes
- Useful for plugin systems and optional deps.
## Error Handling
- Check error messages from dlopen calls.
## License
Apache-2.0
+67
View File
@@ -0,0 +1,67 @@
# libfs
File system library for C built on libuv.
## Install
Build as a C library; see repository for build instructions.
## Overview
- Provides async filesystem APIs via libuv.
## Architecture
```mermaid
flowchart LR
A[FS call] --> B[libfs]
B --> C[libuv]
```
## API
See `include/fs.h` for the public C API.
## Examples
### 1) Include header
```c
#include "fs.h"
```
### 2) Open file
```text
Use fs.h helpers for async file IO.
```
### 3) Read directory
```text
Use directory traversal helpers from fs.h.
```
## Best Practices
- Use libuv loops consistently across modules.
## Performance Notes
- Async operations reduce blocking.
## Security Considerations
- Validate input paths for untrusted sources.
## Integration Notes
- Used by several native bindings.
## Error Handling
- Check callback error codes.
## License
Apache-2.0
+68
View File
@@ -0,0 +1,68 @@
# libfx
Low-level cross-platform GUI library for desktop and mobile.
## Install
Build as a C library; see repository for build instructions.
## Overview
- Core UI primitives used by `fx-native` bindings.
## Architecture
```mermaid
flowchart LR
A[libfx] --> B[Windows]
A --> C[macOS]
A --> D[Linux]
```
## API
See `include/fx.h` for the public C API.
## Examples
### 1) Include header
```c
#include "fx.h"
```
### 2) Create window
```text
Use fx.h APIs to create windows and views.
```
### 3) Render loop
```text
Use platform event loop integration.
```
## Best Practices
- Keep UI updates on main thread.
## Performance Notes
- UI rendering performance depends on platform backends.
## Security Considerations
- Validate external content for embedded web views.
## Integration Notes
- Backing library for `fx-native`.
## Error Handling
- Use return codes for error detection.
## License
Apache-2.0
+67
View File
@@ -0,0 +1,67 @@
# libhex
Hex encoder/decoder library in C.
## Install
Build as a C library; see repository for build instructions.
## Overview
- Converts between binary buffers and hex strings.
## Architecture
```mermaid
flowchart LR
A[Bytes] --> B[libhex]
B --> C[Hex]
```
## API
See `include/hex.h` for the public C API.
## Examples
### 1) Include header
```c
#include "hex.h"
```
### 2) Encode
```text
Use hex_encode functions to convert to hex strings.
```
### 3) Decode
```text
Use hex_decode functions to convert to bytes.
```
## Best Practices
- Check buffer sizes before encoding.
## Performance Notes
- Linear time on input length.
## Security Considerations
- Hex encoding is not encryption.
## Integration Notes
- Useful in crypto tooling and logging.
## Error Handling
- Check return values for invalid input.
## License
Apache-2.0
+67
View File
@@ -0,0 +1,67 @@
# libintrusive
Allocation-free intrusive data structures for C.
## Install
Header-only library; include in your C project.
## Overview
- Intrusive lists and containers without allocations.
## Architecture
```mermaid
flowchart LR
A[Struct] --> B[libintrusive]
B --> C[Intrusive list]
```
## API
See `include/intrusive.h` for the public C API.
## Examples
### 1) Include header
```c
#include "intrusive.h"
```
### 2) Embed node
```text
Embed intrusive nodes in your structs.
```
### 3) Iterate
```text
Use list macros to traverse without allocations.
```
## Best Practices
- Ensure nodes are removed before freeing structs.
## Performance Notes
- O(1) insert/remove; no allocations.
## Security Considerations
- Validate pointer lifetimes.
## Integration Notes
- Useful for low-level runtimes and schedulers.
## Error Handling
- No dynamic allocation errors.
## License
Apache-2.0
+68
View File
@@ -0,0 +1,68 @@
# libjerry
ABI-compatible replacement for `libjs` built on JerryScript.
## Install
Build as a C library; see repository for build instructions.
## Overview
- Lightweight JS engine alternative to V8.
- Targeted at embedded/IoT environments.
## Architecture
```mermaid
flowchart LR
A[libjerry] --> B[JerryScript]
A --> C[libjs ABI]
```
## API
ABI compatible with `libjs`.
## Examples
### 1) Choose engine
```text
Use libjerry when V8 footprint is too heavy.
```
### 2) Integrate
```text
Link against libjerry instead of libjs.
```
### 3) Compatibility
```text
Use the same ABI handles as libjs.
```
## Best Practices
- Validate JS feature support for your workload.
## Performance Notes
- Smaller footprint than V8; throughput differs by workload.
## Security Considerations
- Keep engine up to date for security patches.
## Integration Notes
- Alternative engine alongside libqjs and libjsc.
## Error Handling
- Uses libjs ABI error conventions.
## License
Apache-2.0
+67
View File
@@ -0,0 +1,67 @@
# libjnitl
C++ template library for the Java Native Interface (JNI).
## Install
Header-only library; include in your C++ project.
## Overview
- Provides safer JNI bindings via templates.
## Architecture
```mermaid
flowchart LR
A[C++ code] --> B[libjnitl]
B --> C[JNI]
```
## API
See repository headers for public API.
## Examples
### 1) Include header
```cpp
#include "jnitl.h"
```
### 2) Wrap JNI types
```text
Use template helpers for JNI calls.
```
### 3) Safer handles
```text
Prefer RAII wrappers where provided.
```
## Best Practices
- Keep JNI env handling on correct threads.
## Performance Notes
- Template wrappers have minimal overhead.
## Security Considerations
- Validate Java input types and sizes.
## Integration Notes
- Useful for Android native modules.
## Error Handling
- Check JNI exceptions after calls.
## License
Apache-2.0
+68
View File
@@ -0,0 +1,68 @@
# libjs
ABI-stable C bindings to V8 built on libuv.
## Install
Build with bare-make and V8 prebuilds or custom GN output.
## Overview
- Stable ABI for embedding V8.
- Integrates with libuv event loops.
## Architecture
```mermaid
flowchart LR
A[libjs] --> B[V8]
A --> C[libuv]
```
## API
See `include/js.h` for the public C API.
## Examples
### 1) Configure GN paths
```bash
bare-make generate -D GN_DIR=<chromium>/src -D GN_OUT_DIR=<chromium>/src/<out>
```
### 2) Use API
```text
Call js_* functions from js.h and handle exceptions.
```
### 3) Alternatives
```text
libjsc, libqjs, and libjerry are ABI-compatible alternatives.
```
## Best Practices
- Always clear pending exceptions when handling errors.
## Performance Notes
- V8 performance depends on prebuild configuration.
## Security Considerations
- Sandboxing is required for untrusted code.
## Integration Notes
- Used by libnapi and JSI wrappers.
## Error Handling
- Negative return values indicate exceptions.
## License
Apache-2.0
+68
View File
@@ -0,0 +1,68 @@
# libjsc
ABI-compatible replacement for `libjs` built on JavaScriptCore.
## Install
Build as a C library; see repository for build instructions.
## Overview
- Uses JavaScriptCore on Darwin platforms.
- ABI compatible with libjs.
## Architecture
```mermaid
flowchart LR
A[libjsc] --> B[JavaScriptCore]
A --> C[libjs ABI]
```
## API
ABI compatible with `libjs`.
## Examples
### 1) Link alternative engine
```text
Use libjsc when JavaScriptCore is preferred.
```
### 2) Swap engines
```text
Replace libjs with libjsc without code changes.
```
### 3) Platform focus
```text
Useful on macOS/iOS where JSC is native.
```
## Best Practices
- Validate engine feature parity for your use case.
## Performance Notes
- Performance depends on JSC version.
## Security Considerations
- Keep platform security updates current.
## Integration Notes
- Alternative to libjs for Darwin.
## Error Handling
- Uses libjs ABI error conventions.
## License
Apache-2.0
+67
View File
@@ -0,0 +1,67 @@
# libjsi
React Native JavaScript Interface (JSI) on top of libjs.
## Install
Build as a C library; see repository for build instructions.
## Overview
- Implements JSI using libjs ABI.
## Architecture
```mermaid
flowchart LR
A[React Native] --> B[libjsi]
B --> C[libjs]
```
## API
See `include/jsi.h` for the public C API.
## Examples
### 1) Include header
```cpp
#include "jsi.h"
```
### 2) Bind to RN
```text
Use JSI runtime with libjs-backed engine.
```
### 3) Build integration
```text
Link libjsi and libjs in your RN native module.
```
## Best Practices
- Match React Native JSI version expectations.
## Performance Notes
- Performance depends on underlying libjs engine.
## Security Considerations
- Follow RN security practices for native modules.
## Integration Notes
- Bridges RN to libjs ABI.
## Error Handling
- Check JSI API return values.
## License
Apache-2.0
+67
View File
@@ -0,0 +1,67 @@
# libjson
Small and memory-efficient JSON library in C.
## Install
Build as a C library; see repository for build instructions.
## Overview
- JSON parsing and serialization with low memory use.
## Architecture
```mermaid
flowchart LR
A[JSON] --> B[libjson]
B --> C[Structured data]
```
## API
See `include/json.h` for the public C API.
## Examples
### 1) Include header
```c
#include "json.h"
```
### 2) Parse
```text
Use json.h APIs to parse strings into objects.
```
### 3) Serialize
```text
Use json.h APIs to write JSON output.
```
## Best Practices
- Validate input sizes before parsing.
## Performance Notes
- Optimized for low memory usage.
## Security Considerations
- Handle invalid JSON inputs safely.
## Integration Notes
- Useful in native Pear libraries.
## Error Handling
- Check parse result codes.
## License
Apache-2.0
+68
View File
@@ -0,0 +1,68 @@
# libjstl
C++ template helpers for the libjs ABI.
## Install
Header-only library; include in your C++ project.
## Overview
- Type-safe wrappers for `js_value_t *` handles.
- Marshalling between C++ and JS values.
## Architecture
```mermaid
flowchart LR
A[C++ types] --> B[libjstl]
B --> C[libjs ABI]
```
## API
See repository headers and README for detailed type support.
## Examples
### 1) Include header
```cpp
#include "jstl.h"
```
### 2) Use type info
```text
Define js_type_info_t<T> to marshal custom types.
```
### 3) Persistent refs
```text
Use js_persistent_t<T> for handle lifetime management.
```
## Best Practices
- Keep marshalling code free of side effects.
## Performance Notes
- Templates add little overhead when inlined.
## Security Considerations
- Validate inputs from JS before converting.
## Integration Notes
- Designed to pair with libjs.
## Error Handling
- Check return codes from marshalling calls.
## License
Apache-2.0
+68
View File
@@ -0,0 +1,68 @@
# liblog
Unified logging library for OS log backends.
## Install
Build as a C library; see repository for build instructions.
## Overview
- Unified interface for os_log, syslog, logcat, and TraceLogging.
## Architecture
```mermaid
flowchart LR
A[log_*] --> B[liblog]
B --> C[OS backend]
```
## API
See `include/log.h` for the public C API.
## Examples
### 1) Log a message
```c
#include <log.h>
log_debug("pid: %u", getpid());
```
### 2) Filter logs
```text
Use OS-specific tools (log, journalctl, logcat, tracelog).
```
### 3) Windows trace
```text
Use tracelog/tracefmt to collect logs.
```
## Best Practices
- Use structured log levels consistently.
## Performance Notes
- Logging cost depends on backend.
## Security Considerations
- Avoid logging secrets.
## Integration Notes
- Works across macOS, Linux, Android, Windows.
## Error Handling
- Backend failures are platform-specific.
## License
Apache-2.0
+66
View File
@@ -0,0 +1,66 @@
# libmem
General-purpose memory allocator built on mimalloc.
## Install
Build as a C library; see repository for build instructions.
## Overview
- Explicit heaps, no global allocation by default.
## Architecture
```mermaid
flowchart LR
A[libmem] --> B[mimalloc]
```
## API
See `include/mem.h` for the public C API.
## Examples
### 1) Include header
```c
#include "mem.h"
```
### 2) Create heap
```text
Use mem.h to create and manage explicit heaps.
```
### 3) Allocate
```text
Allocate and free from explicit heaps.
```
## Best Practices
- Use explicit heaps for subsystem isolation.
## Performance Notes
- mimalloc provides good multi-threaded performance.
## Security Considerations
- Validate sizes and check for overflow.
## Integration Notes
- Used by native Pear components.
## Error Handling
- Check allocation results for NULL.
## License
Apache-2.0
+68
View File
@@ -0,0 +1,68 @@
# libnapi
Node-API compatibility layer for libjs.
## Install
Build as a C library; see repository for build instructions.
## Overview
- ABI compatible with a subset of Node-API.
- Uses JS exceptions for error handling.
## Architecture
```mermaid
flowchart LR
A[Node-API] --> B[libnapi]
B --> C[libjs]
```
## API
See `include/napi.h` and `include/napi/module.h`.
## Examples
### 1) Handle exceptions
```c
napi_status status = napi_get_and_clear_last_exception(env, &err);
```
### 2) Module registration
```c
void napi_module_register(napi_module *mod) { /* ... */ }
```
### 3) Link with libjs
```text
Link libnapi and libjs in your native addon.
```
## Best Practices
- Always clear pending exceptions when status is not ok.
## Performance Notes
- Minimal overhead beyond libjs calls.
## Security Considerations
- Validate inputs from JS to native.
## Integration Notes
- Designed for libjs-based runtimes.
## Error Handling
- Only `napi_ok` and `napi_pending_exception` are returned.
## License
Apache-2.0
+67
View File
@@ -0,0 +1,67 @@
# libparseline
Parse streaming lines in C.
## Install
Build as a C library; see repository for build instructions.
## Overview
- Incremental line parsing for streaming input.
## Architecture
```mermaid
flowchart LR
A[Stream] --> B[libparseline]
B --> C[Lines]
```
## API
See `include/parseline.h` for the public C API.
## Examples
### 1) Include header
```c
#include "parseline.h"
```
### 2) Parse lines
```text
Feed buffers and emit complete lines.
```
### 3) Use in IO loop
```text
Combine with libuv read callbacks.
```
## Best Practices
- Handle partial lines between chunks.
## Performance Notes
- Designed for streaming and low allocations.
## Security Considerations
- Validate maximum line length.
## Integration Notes
- Useful for log and protocol parsers.
## Error Handling
- Check return codes for invalid state.
## License
Apache-2.0
+67
View File
@@ -0,0 +1,67 @@
# libpath
Low-level filesystem path manipulation library in C.
## Install
Build as a C library; see repository for build instructions.
## Overview
- Path parsing and normalization helpers.
## Architecture
```mermaid
flowchart LR
A[Path] --> B[libpath]
B --> C[Components]
```
## API
See `include/path.h` for the public C API.
## Examples
### 1) Include header
```c
#include "path.h"
```
### 2) Normalize
```text
Use path.h helpers for normalization and joins.
```
### 3) Resolve
```text
Resolve relative paths against a base.
```
## Best Practices
- Treat input paths as untrusted.
## Performance Notes
- Lightweight string processing.
## Security Considerations
- Avoid path traversal issues in callers.
## Integration Notes
- Used by native runtimes and tools.
## Error Handling
- Check return codes for invalid inputs.
## License
Apache-2.0
+71
View File
@@ -0,0 +1,71 @@
# libpear
Native utilities for Pear applications.
## Install
```bash
npm i -g bare-make
npm i
bare-make generate
bare-make build
```
## Overview
- Native helper library for Pear platform tooling.
## Architecture
```mermaid
flowchart LR
A[Pear app] --> B[libpear]
```
## API
See `include/pear.h` for the public C API.
## Examples
### 1) Build library
```bash
bare-make build
```
### 2) Link native app
```text
Link libpear into your Pear native shell.
```
### 3) Use helpers
```text
Call pear.h APIs for platform utilities.
```
## Best Practices
- Keep build toolchain aligned with Pear versions.
## Performance Notes
- Low-level helpers are lightweight.
## Security Considerations
- Treat platform discovery keys as sensitive.
## Integration Notes
- Used by Pear shells and tooling.
## Error Handling
- Check return codes from C APIs.
## License
Apache-2.0
+71
View File
@@ -0,0 +1,71 @@
# libpearsync
Message passing between a libuv thread and another thread.
## Install
Build as a C library; see repository for build instructions.
## Overview
- Lock-free message queues.
- No allocations in common cases.
## Architecture
```mermaid
flowchart LR
A[Thread] --> B[pearsync]
B --> C[libuv loop]
```
## API
See repository headers and `example.c`.
## Examples
### 1) Initialize
```c
pearsync_t sync;
pearsync_init(&sync);
```
### 2) Open ports
```c
pearsync_open_uv(&sync, uv_loop, on_recv_uv);
pearsync_open_thread(&sync, signal_thread, on_recv_thread);
```
### 3) Send/recv
```c
pearsync_send(port, &msg);
while (pearsync_recv(port, &msg)) { /* ... */ }
```
## Best Practices
- Call `pearsync_destroy` exactly once.
## Performance Notes
- Very low overhead for frequent messages.
## Security Considerations
- Validate message lengths and data pointers.
## Integration Notes
- Designed for libuv-based components.
## Error Handling
- Handle wakeup and close callbacks carefully.
## License
Apache-2.0
+68
View File
@@ -0,0 +1,68 @@
# libqjs
ABI-compatible replacement for `libjs` built on QuickJS.
## Install
Build as a C library; see repository for build instructions.
## Overview
- QuickJS-based alternative to V8.
- Useful for constrained environments.
## Architecture
```mermaid
flowchart LR
A[libqjs] --> B[QuickJS]
A --> C[libjs ABI]
```
## API
ABI compatible with `libjs`.
## Examples
### 1) Swap engine
```text
Link libqjs instead of libjs.
```
### 2) Use ABI
```text
Use the same ABI handles as libjs.
```
### 3) Embedded focus
```text
Prefer for embedded and IoT deployments.
```
## Best Practices
- Validate QuickJS feature set for your app.
## Performance Notes
- QuickJS trades performance for footprint.
## Security Considerations
- Keep engine updated with security fixes.
## Integration Notes
- Alternative to libjs alongside libjsc and libjerry.
## Error Handling
- Uses libjs ABI error conventions.
## License
Apache-2.0
+68
View File
@@ -0,0 +1,68 @@
# libquickbit
SIMD-accelerated bit field operations with indexing support.
## Install
Build as a C library; see repository for build instructions.
## Overview
- Fast bit operations with optional index trees.
- Supports sparse index APIs.
## Architecture
```mermaid
flowchart LR
A[Bitfield] --> B[libquickbit]
B --> C[Index]
```
## API
See `include/quickbit.h` for the public C API.
## Examples
### 1) Initialize index
```c
quickbit_index_init(index, field, len);
```
### 2) Update index
```c
quickbit_index_update(index, field, bit);
```
### 3) Sparse index
```text
Use quickbit_index_init_sparse for chunked fields.
```
## Best Practices
- Align bitfield memory for SIMD where possible.
## Performance Notes
- Indexing enables fast skipping of uninteresting ranges.
## Security Considerations
- Validate bit positions to avoid out-of-bounds.
## Integration Notes
- Used by quickbit-native bindings.
## Error Handling
- Check return values for invalid updates.
## License
Apache-2.0
+67
View File
@@ -0,0 +1,67 @@
# librabin
Rabin fingerprinting for content-defined chunking.
## Install
Build as a C library; see repository for build instructions.
## Overview
- Implements Rabin fingerprinting based on rabin-cdc.
## Architecture
```mermaid
flowchart LR
A[Stream] --> B[librabin]
B --> C[Fingerprints]
```
## API
See `include/rabin.h` for the public C API.
## Examples
### 1) Include header
```c
#include "rabin.h"
```
### 2) Compute fingerprint
```text
Use rabin.h APIs to update and compute rolling hashes.
```
### 3) CDC integration
```text
Use fingerprints to choose chunk boundaries.
```
## Best Practices
- Use consistent polynomial parameters across peers.
## Performance Notes
- Rolling hash is efficient for streaming.
## Security Considerations
- Fingerprints are not cryptographic hashes.
## Integration Notes
- Useful for chunking and deduplication.
## Error Handling
- Check return codes from API calls.
## License
Apache-2.0
+67
View File
@@ -0,0 +1,67 @@
# librlimit
Manage process-wide resource limits in C.
## Install
Build as a C library; see repository for build instructions.
## Overview
- Convenience wrappers for rlimit management.
## Architecture
```mermaid
flowchart LR
A[Limits] --> B[librlimit]
B --> C[OS rlimit]
```
## API
See `include/rlimit.h` for the public C API.
## Examples
### 1) Include header
```c
#include "rlimit.h"
```
### 2) Set limits
```text
Use rlimit APIs to set file or memory limits.
```
### 3) Query limits
```text
Use rlimit APIs to read current limits.
```
## Best Practices
- Set conservative limits for untrusted workloads.
## Performance Notes
- Minimal overhead.
## Security Considerations
- Limits help contain runaway processes.
## Integration Notes
- Useful for native runtime sandboxes.
## Error Handling
- Check return values for permission errors.
## License
Apache-2.0
+68
View File
@@ -0,0 +1,68 @@
# librocksdb
Async C bindings to RocksDB with batch support.
## Install
Build as a C library; see repository for build instructions.
## Overview
- Async API for RocksDB operations.
- Supports batched writes.
## Architecture
```mermaid
flowchart LR
A[API] --> B[librocksdb]
B --> C[RocksDB]
```
## API
See `include/rocksdb.h` for the public C API.
## Examples
### 1) Include header
```c
#include "rocksdb.h"
```
### 2) Open DB
```text
Use rocksdb.h helpers to open a database.
```
### 3) Batch write
```text
Use batch APIs to group writes.
```
## Best Practices
- Use batches for high-throughput writes.
## Performance Notes
- Async operations reduce blocking on IO.
## Security Considerations
- Validate paths to avoid unintended DB access.
## Integration Notes
- Useful for native storage backends.
## Error Handling
- Check return codes and error strings.
## License
Apache-2.0
+67
View File
@@ -0,0 +1,67 @@
# librpc
Low-level RPC codec implemented in C.
## Install
Build as a C library; see repository for build instructions.
## Overview
- Codec for RPC framing and serialization.
## Architecture
```mermaid
flowchart LR
A[Message] --> B[librpc]
B --> C[Encoded RPC]
```
## API
See `include/rpc.h` for the public C API.
## Examples
### 1) Include header
```c
#include "rpc.h"
```
### 2) Encode message
```text
Use rpc.h APIs to encode requests.
```
### 3) Decode message
```text
Use rpc.h APIs to decode responses.
```
## Best Practices
- Keep message schemas versioned.
## Performance Notes
- Efficient binary encoding.
## Security Considerations
- Validate sizes and bounds when decoding.
## Integration Notes
- Used by bindings and cross-language tools.
## Error Handling
- Check return codes from encode/decode.
## License
Apache-2.0
+67
View File
@@ -0,0 +1,67 @@
# libsingleset
Header-only set implementation for objects in a single set.
## Install
Include the header in your C project.
## Overview
- Fast set operations without allocations.
## Architecture
```mermaid
flowchart LR
A[Node] --> B[libsingleset]
B --> C[Set]
```
## API
See `include/singleset.h` for the public C API.
## Examples
### 1) Include header
```c
#include "singleset.h"
```
### 2) Insert/remove
```text
Use singleset macros to manage membership.
```
### 3) Iterate
```text
Traverse set entries via macros.
```
## Best Practices
- Ensure an object belongs to only one set.
## Performance Notes
- O(1) operations.
## Security Considerations
- Validate pointers and lifetimes.
## Integration Notes
- Useful for schedulers and registries.
## Error Handling
- No dynamic allocation errors.
## License
Apache-2.0
+67
View File
@@ -0,0 +1,67 @@
# libtls
Minimal TLS library for C based on BoringSSL.
## Install
Build as a C library; see repository for build instructions.
## Overview
- Small TLS wrapper for native apps.
## Architecture
```mermaid
flowchart LR
A[Socket] --> B[libtls]
B --> C[BoringSSL]
```
## API
See `include/tls.h` for the public C API.
## Examples
### 1) Include header
```c
#include "tls.h"
```
### 2) Create context
```text
Use tls.h APIs to create configs and sessions.
```
### 3) Handshake
```text
Run TLS handshake and encrypt streams.
```
## Best Practices
- Keep BoringSSL up to date.
## Performance Notes
- TLS adds handshake and encryption overhead.
## Security Considerations
- Validate certificates and configure ciphers.
## Integration Notes
- Useful for native network stacks.
## Error Handling
- Check return values for handshake errors.
## License
Apache-2.0
+67
View File
@@ -0,0 +1,67 @@
# libtt
Virtual console extensions built on libuv.
## Install
Build as a C library; see repository for build instructions.
## Overview
- Console and terminal utilities for native apps.
## Architecture
```mermaid
flowchart LR
A[Console] --> B[libtt]
B --> C[libuv]
```
## API
See `include/tt.h` for the public C API.
## Examples
### 1) Include header
```c
#include "tt.h"
```
### 2) Configure terminal
```text
Use tt.h helpers for terminal settings.
```
### 3) Handle IO
```text
Integrate with libuv event loops.
```
## Best Practices
- Restore terminal settings on exit.
## Performance Notes
- Minimal overhead for terminal operations.
## Security Considerations
- Avoid writing sensitive data to shared terminals.
## Integration Notes
- Useful for CLI tooling.
## Error Handling
- Check return codes for IO errors.
## License
Apache-2.0
+69
View File
@@ -0,0 +1,69 @@
# liburl
WHATWG URL parser in C with efficient views.
## Install
Build as a C library; see repository for build instructions.
## Overview
- Parses URLs into immutable view components.
## Architecture
```mermaid
flowchart LR
A[URL string] --> B[liburl]
B --> C[URL views]
```
## API
See `include/url.h` for the public C API.
## Examples
### 1) Parse URL
```c
url_t url;
url_init(&url);
url_parse(&url, "https://example.com", -1, NULL);
```
### 2) Get href
```c
utf8_string_view_t href = url_get_href(&url);
```
### 3) Cleanup
```c
url_destroy(&url);
```
## Best Practices
- Reuse url_t objects to reduce allocations.
## Performance Notes
- Optimized for low allocations and view access.
## Security Considerations
- Validate host/port if used for networking.
## Integration Notes
- Depends on `libutf` for string views.
## Error Handling
- Check parse results for invalid URLs.
## License
Apache-2.0
+67
View File
@@ -0,0 +1,67 @@
# libutf
Unicode utilities in C without libc++.
## Install
Build as a C library; see repository for build instructions.
## Overview
- UTF encoding/decoding helpers based on simdutf ideas.
## Architecture
```mermaid
flowchart LR
A[UTF data] --> B[libutf]
B --> C[Conversions]
```
## API
See `include/utf.h` for the public C API.
## Examples
### 1) Include header
```c
#include "utf.h"
```
### 2) Convert UTF
```text
Use utf.h helpers to convert between encodings.
```
### 3) Validate
```text
Use utf.h helpers to validate input sequences.
```
## Best Practices
- Validate input before conversion.
## Performance Notes
- Optimized for vectorized implementations when available.
## Security Considerations
- Reject invalid UTF sequences from untrusted sources.
## Integration Notes
- Used by liburl and other string helpers.
## Error Handling
- Check return codes for invalid input.
## License
Apache-2.0
+67
View File
@@ -0,0 +1,67 @@
# libz32
Encoder/decoder for z-base-32 in C.
## Install
Build as a C library; see repository for build instructions.
## Overview
- z-base-32 encoding for human-friendly keys.
## Architecture
```mermaid
flowchart LR
A[Bytes] --> B[libz32]
B --> C[z-base-32]
```
## API
See `include/z32.h` for the public C API.
## Examples
### 1) Include header
```c
#include "z32.h"
```
### 2) Encode
```text
Use z32_encode functions to create z-base-32 strings.
```
### 3) Decode
```text
Use z32_decode functions to recover bytes.
```
## Best Practices
- Use z-base-32 for human-friendly identifiers.
## Performance Notes
- Linear time encoding/decoding.
## Security Considerations
- Encoding is not encryption.
## Integration Notes
- Used by key encoding utilities.
## Error Handling
- Check return codes for invalid input.
## License
Apache-2.0
+71
View File
@@ -0,0 +1,71 @@
# light-bolt11-decoder
Lightweight decoder for Lightning Network BOLT11 payment requests.
## Install
```bash
yarn add light-bolt11-decoder
```
## Overview
- Decodes BOLT11 without signature verification.
- Minimal dependencies for browser use.
## Architecture
```mermaid
flowchart LR
A[BOLT11 string] --> B[light-bolt11-decoder]
B --> C[Decoded sections]
```
## API
#### `decode(request)`
## Examples
### 1) Decode invoice
```js
const { decode } = require('light-bolt11-decoder')
const data = decode('lnbc...')
```
### 2) Inspect tags
```js
console.log(data.sections)
```
### 3) Check expiry
```js
console.log(data.expiry)
```
## Best Practices
- Use full BOLT11 libraries if signature verification is required.
## Performance Notes
- Lightweight and fast for UI decoding.
## Security Considerations
- Do not trust decoded content without signature checks.
## Integration Notes
- Derived from `bolt11` package.
## Error Handling
- Throws on invalid requests.
## License
MIT
+71
View File
@@ -0,0 +1,71 @@
# lightning
Methods for working with the Lightning Network (LND focused).
## Install
```bash
npm install lightning
```
## Overview
- Wraps LND RPC methods and utilities.
- Large API surface; see ln-service docs for specifics.
## Architecture
```mermaid
flowchart LR
A[App] --> B[lightning]
B --> C[LND gRPC]
```
## API
See https://github.com/alexbosworth/ln-service for full method list and usage.
## Examples
### 1) Authenticated LND
```js
const { authenticatedLndGrpc } = require('lightning')
const { lnd } = authenticatedLndGrpc({ cert, macaroon, socket })
```
### 2) Decode invoice
```js
const { decodePaymentRequest } = require('lightning')
```
### 3) Pay invoice
```js
const { pay } = require('lightning')
```
## Best Practices
- Use least-privilege macaroons.
## Performance Notes
- Performance depends on LND node and network latency.
## Security Considerations
- Protect macaroons and TLS certs.
## Integration Notes
- Works with LND and ln-service ecosystem.
## Error Handling
- gRPC errors map to method rejections.
## License
MIT
+71
View File
@@ -0,0 +1,71 @@
# listen-async
Promise-based helper to `listen()` on http/net servers.
## Install
```bash
npm install listen-async
```
## Overview
- Awaits server listen success.
- Allows fallback ports on failure.
## Architecture
```mermaid
flowchart LR
A[Server] --> B[listen-async]
B --> C[Listening]
```
## API
#### `await listen(server, port)`
## Examples
### 1) Basic
```js
const listen = require('listen-async')
await listen(server, 8080)
```
### 2) Fallback port
```js
try { await listen(server, 8080) } catch { await listen(server, 0) }
```
### 3) Use with net server
```js
await listen(netServer, 1234)
```
## Best Practices
- Handle errors and fallback to ephemeral ports.
## Performance Notes
- Minimal overhead.
## Security Considerations
- Validate chosen ports in production.
## Integration Notes
- Works with http, https, net servers.
## Error Handling
- Rejects on listen errors.
## License
Apache-2.0
+73
View File
@@ -0,0 +1,73 @@
# localwatch
Watch a directory and emit diffs of changes.
## Install
```bash
npm install localwatch
```
## Overview
- Stream of batched file changes.
- Configurable filters and path mapping.
## Architecture
```mermaid
flowchart LR
A[Filesystem] --> B[Localwatch]
B --> C[Diff stream]
```
## API
#### `const watch = new Localwatch(dir, options)`
#### `Localwatch.defaultFilter(filename, [stream])`
## Examples
### 1) Watch directory
```js
const watch = new Localwatch('./dir')
for await (const diff of watch) console.log(diff)
```
### 2) Custom filter
```js
const watch = new Localwatch('./dir', { filter: (f) => f.endsWith('.js') })
```
### 3) Relative paths
```js
const watch = new Localwatch('./dir', { relative: true })
```
## Best Practices
- Use `settle` to batch rapid updates.
## Performance Notes
- Batching reduces event spam.
## Security Considerations
- Avoid watching untrusted directories.
## Integration Notes
- Useful for live reloaders.
## Error Handling
- Stream errors propagate via async iteration.
## License
Apache-2.0
+71
View File
@@ -0,0 +1,71 @@
# lunte
Self-contained JavaScript linter with LSP support.
## Install
```bash
npm install --save-dev lunte
```
## Overview
- CLI linter aligned with Standard rules.
- Optional LSP server and VS Code extension.
- Supports TypeScript parsing.
## Architecture
```mermaid
flowchart LR
A[Source] --> B[lunte]
B --> C[Diagnostics]
```
## API
CLI tool: `lunte`, `lunte-lsp`.
## Examples
### 1) Lint project
```bash
lunte src/
```
### 2) Use config
```json
{ "env": ["node"], "rules": { "no-undef": "off" } }
```
### 3) LSP
```bash
lunte-lsp
```
## Best Practices
- Use `.lunteignore` to skip generated files.
## Performance Notes
- No external deps for TypeScript parsing.
## Security Considerations
- LSP runs locally; avoid exposing over network.
## Integration Notes
- Works with VS Code via `vscode-lunte`.
## Error Handling
- CLI exits non-zero on lint errors.
## License
Apache-2.0
+75
View File
@@ -0,0 +1,75 @@
# minicron
Simple cron-like scheduling using setInterval.
## Install
```bash
npm install minicron
```
## Overview
- Schedule callbacks by seconds/minutes/hours/days.
## Architecture
```mermaid
flowchart LR
A[cron.*] --> B[setInterval]
```
## API
#### `cron.seconds(amount, fn, ...args)`
#### `cron.minutes(amount, fn, ...args)`
#### `cron.hours(amount, fn, ...args)`
#### `cron.days(amount, fn, ...args)`
## Examples
### 1) Every 5 seconds
```js
cron.seconds(5, () => console.log('tick'))
```
### 2) Every hour
```js
cron.hours(1, task)
```
### 3) Cancel
```js
const id = cron.minutes(1, task)
clearInterval(id)
```
## Best Practices
- Use id to cancel intervals during shutdown.
## Performance Notes
- Uses setInterval; drift depends on event loop.
## Security Considerations
- Avoid scheduling untrusted callbacks.
## Integration Notes
- Simple alternative to cron schedulers.
## Error Handling
- Exceptions in callbacks should be handled by callers.
## License
Apache-2.0
+80
View File
@@ -0,0 +1,80 @@
# mininet
Control Mininet virtual networks from Node.js.
## Install
```bash
npm install mininet
```
## Overview
- Create switches, hosts, and links.
- Run commands inside virtual hosts.
## Architecture
```mermaid
flowchart LR
A[Mininet JS] --> B[Mininet]
B --> C[Virtual network]
```
## API
#### `const mn = new Mininet(options)`
#### `mn.createSwitch()` / `mn.createHost()`
#### `mn.start()` / `mn.stop()`
#### `host.spawn(cmd)` / `host.exec(cmd)`
## Examples
### 1) Create network
```js
const mn = new Mininet()
const s1 = mn.createSwitch()
const h1 = mn.createHost()
h1.link(s1)
mn.start()
```
### 2) Spawn process
```js
const proc = h1.spawn('node server.js')
```
### 3) Stop
```js
mn.stop()
```
## Best Practices
- Use `clean: true` if Mininet gets stuck.
## Performance Notes
- Virtual networking adds overhead.
## Security Considerations
- Requires sudo for network setup.
## Integration Notes
- Useful for network testing.
## Error Handling
- Check process events for errors.
## License
MIT
+74
View File
@@ -0,0 +1,74 @@
# multi-profile-store
Manage multiple corestores for multi-profile apps.
## Install
```bash
npm install multi-profile-store
```
## Overview
- Simple sync IO for profile storage.
- Create, list, update, and GC profiles.
## Architecture
```mermaid
flowchart LR
A[Profiles] --> B[multi-profile-store]
B --> C[Corestore paths]
```
## API
#### `MultiProfileStore.open(dir)`
#### `MultiProfileStore.migrate(dir)`
#### `store.list()` / `store.active()` / `store.create()` / `store.update()` / `store.remove()` / `store.gc()`
## Examples
### 1) Open store
```js
const p = MultiProfileStore.open('./profiles')
```
### 2) Create profile
```js
const profile = p.create({ name: 'test' })
```
### 3) GC removed profiles
```js
p.gc({ delay: 0 })
```
## Best Practices
- Run GC periodically to reclaim disk.
## Performance Notes
- Sync IO; use in low-contention paths.
## Security Considerations
- Protect profile directories with correct permissions.
## Integration Notes
- Useful for multi-user Pear apps.
## Error Handling
- Errors surface as exceptions.
## License
Apache-2.0
+66
View File
@@ -0,0 +1,66 @@
# musl-toolchains
Prebuilt musl cross-compilation toolchains.
## Install
Download or use via build tooling.
## Overview
- Provides musl-based cross toolchains.
## Architecture
```mermaid
flowchart LR
A[Toolchain] --> B[musl]
```
## API
No JS API; toolchain distribution.
## Examples
### 1) Use in CI
```text
Configure compiler paths to musl toolchain.
```
### 2) Cross-compile
```text
Use toolchain files in CMake.
```
### 3) Verify
```text
Check compiler version outputs.
```
## Best Practices
- Pin toolchain versions for reproducibility.
## Performance Notes
- Toolchain selection affects build time.
## Security Considerations
- Use trusted toolchain sources.
## Integration Notes
- Pairs with `cmake-toolchains`.
## Error Handling
- Build failures surface in compiler output.
## License
Apache-2.0
+72
View File
@@ -0,0 +1,72 @@
# nanodebug
Tiny debugging helper with zero overhead when disabled.
## Install
```bash
npm install nanodebug
```
## Overview
- No-op by default.
- Supports function callbacks and async.
## Architecture
```mermaid
flowchart LR
A[debug()] --> B[nanodebug]
B --> C[log]
```
## API
#### `const debug = require('nanodebug')(opts)`
## Examples
### 1) No-op
```js
const debug = require('nanodebug')()
debug('no output')
```
### 2) Enable
```js
const debug = require('nanodebug')({ enabled: true })
debug('hello')
```
### 3) Custom logger
```js
const debug = require('nanodebug')({ log: console.log })
```
## Best Practices
- Gate verbose logging behind enabled flag.
## Performance Notes
- No overhead when disabled.
## Security Considerations
- Avoid logging secrets.
## Integration Notes
- Useful in low-level modules.
## Error Handling
- Errors in callbacks should be handled by callers.
## License
Apache-2.0
+71
View File
@@ -0,0 +1,71 @@
# native-pipe
Duplex pipes that only depend on N-API.
## Install
```bash
npm install native-pipe
```
## Overview
- Connect to named pipes or file descriptors.
- Streamx-compatible duplex stream.
## Architecture
```mermaid
flowchart LR
A[Pipe name/FD] --> B[NativePipe]
B --> C[Duplex stream]
```
## API
#### `const stream = new NativePipe(pipeNameOrFd)`
## Examples
### 1) Named pipe
```js
const stream = new NativePipe('/tmp/server.sock')
```
### 2) Stdio FD
```js
const stream = new NativePipe(0)
```
### 3) Read/write
```js
stream.write('hello')
stream.on('data', data => console.log(data))
```
## Best Practices
- Handle backpressure with streamx semantics.
## Performance Notes
- Uses native pipes for efficient IPC.
## Security Considerations
- Use secure pipe paths and permissions.
## Integration Notes
- Useful for IPC in Node/Bare.
## Error Handling
- Listen for `error` events on the stream.
## License
Apache-2.0
+70
View File
@@ -0,0 +1,70 @@
# netpaste
Copy and paste over the DHT.
## Install
```bash
npm install -g netpaste
```
## Overview
- CLI for sharing clipboard-like text via DHT.
- Supports profiles and key management.
## Architecture
```mermaid
flowchart LR
A[netpaste] --> B[DHT]
B --> C[Peers]
```
## API
CLI commands: `seed`, `export`, `import`, `copy`, `paste`.
## Examples
### 1) Generate seed
```bash
netpaste seed
```
### 2) Copy text
```bash
netpaste copy "hello"
```
### 3) Paste from profile
```bash
netpaste paste --profile test
```
## Best Practices
- Use profiles to separate contexts.
## Performance Notes
- DHT retrieval depends on connectivity.
## Security Considerations
- Treat data as public unless encrypted.
## Integration Notes
- Keys stored under `~/.netpaste/<profile>`.
## Error Handling
- CLI exits non-zero on network errors.
## License
Apache-2.0
+74
View File
@@ -0,0 +1,74 @@
# network-block-device
NBD server in JS for virtual block devices.
## Install
```bash
npm install -g network-block-device
```
## Overview
- Provides NBD server with read/write callbacks.
- Includes CLI example for Linux nbd client.
## Architecture
```mermaid
flowchart LR
A[NBD client] --> B[NBD server]
B --> C[Block storage]
```
## API
#### `new NBDServer({ blockSize, size, read, write, del })`
#### `server.listen(path)`
## Examples
### 1) Start server
```js
const server = new NBDServer({ blockSize: 1024, size: 16 * 1024 * 1024, read, write, del })
server.listen('/tmp/nbd')
```
### 2) Connect client
```bash
nbdc /tmp/nbd /dev/nbd5
```
### 3) Format and mount
```bash
sudo mkfs.ext4 /dev/nbd5
sudo mount /dev/nbd5 /mnt
```
## Best Practices
- Validate block size and bounds in callbacks.
## Performance Notes
- Performance depends on callback implementation.
## Security Considerations
- Restrict socket path permissions.
## Integration Notes
- Works with Linux nbd tooling.
## Error Handling
- Callback errors should be handled to avoid server crashes.
## License
Apache-2.0
+69
View File
@@ -0,0 +1,69 @@
# ninja-runtime
Prebuilt Ninja binaries for macOS, Linux, and Windows.
## Install
```bash
npm i -g ninja-runtime
```
## Overview
- Provides Ninja binaries via npm.
## Architecture
```mermaid
flowchart LR
A[ninja-runtime] --> B[Ninja binary]
```
## API
CLI tool; use `ninja` after install.
## Examples
### 1) Install and run
```bash
npm i -g ninja-runtime
ninja --version
```
### 2) Use in CI
```text
Pin version via npm to match build requirements.
```
### 3) Build
```bash
ninja -C out
```
## Best Practices
- Pin versions for reproducible builds.
## Performance Notes
- Ninja is optimized for fast incremental builds.
## Security Considerations
- Use trusted package sources.
## Integration Notes
- Often used with cmake-gn and build tooling.
## Error Handling
- Build failures are printed to stderr.
## License
Apache-2.0
+71
View File
@@ -0,0 +1,71 @@
# node-bare-bundle
Run a Bare bundle in a Node.js environment.
## Install
```bash
npm install node-bare-bundle
```
## Overview
- Executes Bare bundles in Node.
- Supports mounting for pre-resolved native modules.
## Architecture
```mermaid
flowchart LR
A[Bundle] --> B[node-bare-bundle]
B --> C[Node runtime]
```
## API
#### `runBundle(buffer, { mount, entrypoint })`
## Examples
### 1) Run bundle
```js
const runBundle = require('node-bare-bundle')
const exports = runBundle(bundleBuffer, { entrypoint: '/index.js' })
```
### 2) With mount
```js
runBundle(bundleBuffer, { mount: './app.bundle', entrypoint: '/main.js' })
```
### 3) Use exports
```js
console.log(exports)
```
## Best Practices
- Ensure bundle entrypoint matches your build output.
## Performance Notes
- Bundle execution cost depends on module graph.
## Security Considerations
- Only run trusted bundles.
## Integration Notes
- Uses bare-bundle and bare-module-resolve.
## Error Handling
- Throws on invalid bundle or entrypoint.
## License
Apache-2.0
+75
View File
@@ -0,0 +1,75 @@
# noise-curve-ed
Ed25519 curve operations for noise-handshake.
## Install
```bash
npm install noise-curve-ed
```
## Overview
- Provides Noise curve module with Ed25519.
## Architecture
```mermaid
flowchart LR
A[noise-handshake] --> B[noise-curve-ed]
B --> C[Ed25519 ops]
```
## API
#### `generateKeyPair([privKey])`
#### `dh(publicKey, { secretKey, scalar })`
#### constants: `DHLEN`, `PKLEN`, `SKLEN`, `SCALARLEN`, `ALG`
## Examples
### 1) Use with noise-handshake
```js
const curve = require('noise-curve-ed')
const Noise = require('noise-handshake')
const handshake = new Noise(pattern, true, staticKeyPair, { curve })
```
### 2) Generate keypair
```js
const { publicKey, secretKey } = curve.generateKeyPair()
```
### 3) DH
```js
const shared = curve.dh(remotePk, { secretKey })
```
## Best Practices
- Keep secret keys in secure memory.
## Performance Notes
- Ed25519 operations are fast for small payloads.
## Security Considerations
- Use constant-time operations and safe key storage.
## Integration Notes
- Plug-in for noise-handshake.
## Error Handling
- Invalid keys may throw or return incorrect results.
## License
Apache-2.0
+84
View File
@@ -0,0 +1,84 @@
# noise-handshake
Noise protocol handshake implementation.
## Install
```bash
npm install noise-handshake
```
## Overview
- Implements Noise patterns and handshake state.
- Produces tx/rx session keys.
## Architecture
```mermaid
sequenceDiagram
participant Initiator
participant Responder
Initiator->>Responder: send()
Responder->>Initiator: recv()
Responder->>Initiator: send()
Initiator->>Responder: recv()
```
## API
#### `new Noise(pattern, initiator, staticKeypair, opts)`
#### `peer.initialise(prologue, remoteStatic)`
#### `peer.send([payload])` / `peer.recv(buf)`
#### `peer.complete` / `peer.tx` / `peer.rx`
## Examples
### 1) Basic handshake
```js
const Noise = require('noise-handshake')
const a = new Noise('IK', true)
const b = new Noise('IK', false)
```
### 2) Exchange
```js
const m1 = a.send(); b.recv(m1)
const m2 = b.send(); a.recv(m2)
```
### 3) Encrypt
```js
const Cipher = require('noise-handshake/cipher')
const send = new Cipher(a.tx)
```
## Best Practices
- Use a secure curve module and PSK where required.
## Performance Notes
- Handshake cost is minimal for session setup.
## Security Considerations
- Validate remote static keys and prologue.
## Integration Notes
- Works with noise-curve-ed and other curve modules.
## Error Handling
- Throws on invalid handshake messages.
## License
Apache-2.0
+74
View File
@@ -0,0 +1,74 @@
# obfuscate-data
Reversibly obfuscate data with a secret key.
## Install
```bash
npm install obfuscate-data
```
## Overview
- Simple reversible obfuscation, not encryption.
## Architecture
```mermaid
flowchart LR
A[Data] --> B[obfuscate]
B --> C[Obfuscated]
```
## API
#### `generateKey()`
#### `obfuscate(data, key)`
#### `deobfuscate(payload, key)`
## Examples
### 1) Obfuscate
```js
const key = obf.generateKey()
const payload = obf.obfuscate(data, key)
```
### 2) Deobfuscate
```js
const data = obf.deobfuscate(payload, key)
```
### 3) Store key
```text
Persist key securely if needed.
```
## Best Practices
- Use real encryption for sensitive data.
## Performance Notes
- Lightweight operations on buffers.
## Security Considerations
- Obfuscation is not cryptographic security.
## Integration Notes
- Useful for simple reversible masking.
## Error Handling
- Throws on invalid input types.
## License
Apache-2.0
+79
View File
@@ -0,0 +1,79 @@
# paparam
Strict and composable CLI parameter parser.
## Install
```bash
npm install paparam
```
## Overview
- Build commands with flags, args, and help output.
- Supports composition and definition objects.
## Architecture
```mermaid
flowchart LR
A[argv] --> B[paparam]
B --> C[Parsed flags/args]
```
## API
#### `command(name, ...mods)`
#### `flag(spec, description)`
#### `arg(spec, description)`
#### `rest(spec, description)`
#### `summary(text)` / `description(text)` / `header(text)` / `footer(text)`
## Examples
### 1) Simple command
```js
const cmd = command('run', flag('--id [id]', 'id'), arg('<link>', 'link'))
cmd.parse()
```
### 2) Subcommands
```js
const root = command('app', run)
```
### 3) Definition object
```js
const cmd = command({ name: 'app', summary: 'summary', 'flag --log': 'log' })
```
## Best Practices
- Use `validate` for cross-flag checks.
## Performance Notes
- Parsing is fast; suitable for CLIs.
## Security Considerations
- Validate file paths and inputs after parsing.
## Integration Notes
- Used in Pear CLI tooling.
## Error Handling
- `parse()` returns null on errors with help output.
## License
Apache-2.0
+79
View File
@@ -0,0 +1,79 @@
# passive-core-watcher
Run conditional logic when hypercores open in a corestore.
## Install
```bash
npm install passive-core-watcher
```
## Overview
- Watches new cores and applies side effects.
- Uses weak sessions that close automatically.
## Architecture
```mermaid
flowchart LR
A[Corestore] --> B[PassiveCoreWatcher]
B --> C[Watched sessions]
```
## API
#### `new PassiveCoreWatcher(corestore, { watch, open })`
#### `watcher.destroy()`
#### `await watcher.ensureTracked(key)`
#### `watcher.on('oncoreopen-error', fn)`
## Examples
### 1) Create watcher
```js
const watcher = new PassiveCoreWatcher(store, {
watch: core => core.name === 'important',
open: session => session.on('close', () => {})
})
```
### 2) Ensure tracked
```js
await watcher.ensureTracked(key)
```
### 3) Destroy
```js
watcher.destroy()
```
## Best Practices
- Keep `watch` fast; avoid heavy IO.
## Performance Notes
- Weak sessions reduce resource usage.
## Security Considerations
- Validate keys before tracking.
## Integration Notes
- Useful for background indexing tasks.
## Error Handling
- Errors are emitted via `oncoreopen-error`.
## License
Apache-2.0
+76
View File
@@ -0,0 +1,76 @@
# pattern-router
Object-pattern-based routing for message streams.
## Install
```bash
npm install pattern-router
```
## Overview
- Matches messages to patterns by structure.
- More specific patterns win; ties by registration order.
## Architecture
```mermaid
flowchart LR
A[Message] --> B[PatternRouter]
B --> C[Handler]
```
## API
#### `new PatternRouter({ multi })`
#### `router.register(pattern, handler)`
#### `router.lookup(message)`
#### `router.write(message)`
## Examples
### 1) Register patterns
```js
router.register({ type: 'ping' }, msg => console.log(msg))
```
### 2) Specific match
```js
router.register({ type: 'ping', extra: { deep: 'x' } }, handler)
```
### 3) Lookup only
```js
const pattern = router.lookup({ type: 'ping' })
```
## Best Practices
- Keep patterns small and specific.
## Performance Notes
- Matching is structural; deep objects cost more.
## Security Considerations
- Validate message payloads in handlers.
## Integration Notes
- Uses `ptnm` for matching.
## Error Handling
- Handler errors bubble as stream errors.
## License
Apache-2.0