YAPF/bindings/js
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Nexoniarz d7f494a0c9 Language bindings, KDE thumbnails, yapf compare, in-memory encoding
- yapf_encode() / yapf_free_buffer(): encode to memory; yapf_save uses it
- yapf.c also compiles as C++
- `yapf compare`: size and decode speed of the original format vs YAPF,
  with a lossless check
- bindings with tested examples: C++ (header-only), C# (P/Invoke),
  Rust (crate, builds the C code), Go (cgo), Java (FFM API, Java 22+),
  Zig (@cImport), LuaJIT (FFI), TypeScript types for the JS port;
  Python now encodes in memory
- docs/LANGUAGES.md and examples/ with measured results
- KDE Dolphin thumbnail plugin (KF6, CMake)
- README: honest status for Photoshop / VS Code / Figma (not run in the
  apps yet) and macOS (cross-compiled only), platform table

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 14:39:56 +02:00
..
example.mjs Language bindings, KDE thumbnails, yapf compare, in-memory encoding 2026-10-03 14:39:56 +02:00
package.json Language bindings, KDE thumbnails, yapf compare, in-memory encoding 2026-10-03 14:39:56 +02:00
README.md Language bindings, KDE thumbnails, yapf compare, in-memory encoding 2026-10-03 14:39:56 +02:00
test.js YAPF v1: fast byte-aligned format, SIMD, tools and plugins 2026-10-03 14:17:59 +02:00
yapf.d.ts Language bindings, KDE thumbnails, yapf compare, in-memory encoding 2026-10-03 14:39:56 +02:00
yapf.js YAPF v1: fast byte-aligned format, SIMD, tools and plugins 2026-10-03 14:17:59 +02:00

yapf.js — YAPF in JavaScript

Encoder and decoder for YAPF v1 in one dependency-free file. Works in browsers, Node.js, web workers, Figma plugins and VS Code webviews, and produces exactly the same bytes as the C library.

const YAPF = require('./yapf.js');            // or <script src="yapf.js"> → window.YAPF

const img = YAPF.decode(bytes);               // Uint8Array → image
// img = { width, height, channels, pixels, gpuFormat, flags, mipLevels, mips }

const file = YAPF.encode({ width, height, channels: 4, pixels });   // → Uint8Array

// draw on a canvas
ctx.putImageData(new ImageData(YAPF.toRGBA(img), img.width, img.height), 0, 0);

decode throws an Error for corrupt or unsupported data. Speed: a 4K image decodes in about 150 ms in Node / Chrome (the C library: 6 ms).

TypeScript types are in yapf.d.ts.

Example: node example.mjs ../../other/YAPF.YAPF · tests: node test.js.