r/javascript • • 13h ago

LazyPromise: an async primitive that has familiar semantics of a native promise, but supports auto-propagating cancellation, type-safe errors, and dependency injection

Thumbnail lazypromise.com
0 Upvotes

r/javascript • • 22h ago

KernelPlay JS v0.6.0 Released — Modular Architecture, Universal Renderer Cores & Decoupled Physics!

Thumbnail github.com
2 Upvotes

I'm excited to announce that KernelPlay JS v0.6.0 is officially released!

This update introduces an important architectural shift toward a more modular engine, focusing on decoupling the Renderer and Physics systems.

Here's what's new:

1. Universal Renderer Architecture

Previously, switching rendering pipelines could require developers to replace generic components such as `BoxRenderer` with pipeline-specific components like `PixiBoxRenderer`.

With the new architecture, universal components can work across all supported rendering pipelines without requiring developers to manually switch rendering components.

This makes changing renderers much easier and keeps game logic independent of the rendering pipeline.

2. Decoupled Physics Engine Core

Physics logic has now been moved into a separate Physics Engine Core.

The default physics engine remains integrated and ready to use, but the new structure makes it possible to plug in custom physics engines.

This gives developers more flexibility over how physics is handled in their projects.

3. Future Physics Plugins

We're also planning to expand the plugin ecosystem.

High-end physics engines such as Matter.js will be available as separate plugins in the future. They won't be bundled into the core engine, helping keep KernelPlay JS lightweight.

4. Official TypeScript Support

This release also introduces official TypeScript support through `.d.ts` declaration files.

Developers can now benefit from type information, better editor support, and autocomplete when working with KernelPlay JS in TypeScript projects.

---

This architectural change is a major step toward making KernelPlay JS more flexible, modular, and lightweight.

There's still a lot planned for the project, and I'd love to hear your thoughts.

What do you think about this new modular architecture? Would you be interested in building custom renderer or physics cores?

Thank you to everyone following and supporting KernelPlay JS!


r/javascript • • 16h ago

AskJS [AskJS] Utility functions named like verbs are the worst API design in JS libraries

0 Upvotes

I keep running into the same API design pattern in JS and TS libraries, and it quietly causes production bugs:

import { format, parse, validate } from 'some-lib'

format(date)      // "2026-11-27" or "11/27/2026" depending on locale?
parse(input)      // throws? returns null? returns the input unchanged?
validate(email)   // true/false? or throws a ValidationError?

The function names are verbs. They sound obvious. But the contract is anything but obvious.

format might respect the system locale, or it might not. It might throw on invalid input, or return null, or return the input unchanged. parse might be strict, lenient, or silently coerce. validate might return a boolean or throw.

The problem isn't any single library. It's that the ecosystem has converged on verb-named utilities without a shared contract. So every time I switch libraries, I re-learn whether parse throws on garbage input or swallows it.

Compare that to something like Date.prototype.toISOString(). The name is boring, but the behavior is exact. No locale surprises, no silent coercion, no guessing.

I'm starting to think libraries should name these functions after what they actually do, not after the general idea:

formatDateToISO(date)      // exact contract
parseEmailStrict(input)    // throws on invalid
isValidEmail(email)        // boolean, never throws

More verbose, yes. But you can read the call site and know what happens without checking docs.

What's your take? Do you prefer short verb names with documented behavior, or longer names that encode the contract? And have you ever been burned by a parse or validate that behaved differently than you expected?


r/javascript • • 3h ago

AskJS [AskJS] Good resources for using JS/TS for simple real-time multiplayer games/interfaces, web-based?

3 Upvotes

I have designed a game in real life and thought of creating a very simple online version of it so I can play it with more people at any time. I don't have much experience with JS, just basic webpage functionality, though I have a lot of experience with programming in general.

The game is not very complicated in terms of mechanics, just turn-based in a real-time updating board and I'd probably be looking to something similar to what chess websites implement, if not an identical implementation. I'd just like resources related to designs I could get "inspiration" from and how the web clients would communicate with the server. I do not want to use automated assistance.