C header files in TypeScript
TypeScript implementations of 20 C standard library functions across 5 modules. Each function is individually importable and tree-shakeable.
ctype math stdio stdlib stringWe have 20 C functions so far - help us add more
Got a rainy Sunday afternoon and a taste for a porting puzzle?
- Get inspiration from the C math.h documentation, the C math.h source.
- Click "New file" in the appropriate folder on GitHub. This will fork the project to your account, directly add the file to it, and send a Pull Request to us.
We will then review it. If it's useful to the project and in line with our contributing guidelines your work will become part of Locutus and you'll be automatically credited in the authors section accordingly.
Upstream Surface Inventory 20/83 shipped · 44 next 24%
Locutus tracks 5 upstream namespaces for C and sorts them into what is already shipped, what we still want, what we intentionally keep, and what still needs a decision.
Next
Character classification helpers map cleanly to plain strings and numbers.
isblankiscntrlisgraphisprintispunctisxdigit
stdlib.h
Next
Scalar conversion and numeric helpers are good portability targets.
atolatollbsearchlabsllabsrandstrtofstrtollstrtoulstrtoull
Explicit non-goals (3)
-
getenvProcess environment lookup depends on host state outside Locutus' model. -
qsortIn-place comparator-driven sorting does not map cleanly to plain JS values. -
srandGlobal RNG seeding mutates ambient runtime state.
Next
Character-class span helpers are useful for string scanning.
strcspnstrspn
Prefix-bounded string comparison still has a clean plain-value contract.
strncmp
Character-class search maps naturally to string scanning.
strpbrk
Last-occurrence search maps naturally to string lookup.
strrchr
Explicit non-goals (9)
-
memchrC buffer and pointer-oriented string APIs do not generally map cleanly to JS plain values. -
memcmpC buffer and pointer-oriented string APIs do not generally map cleanly to JS plain values. -
memcpyC buffer and pointer-oriented string APIs do not generally map cleanly to JS plain values. -
memmoveC buffer and pointer-oriented string APIs do not generally map cleanly to JS plain values. -
memsetC buffer and pointer-oriented string APIs do not generally map cleanly to JS plain values. -
strcpyC buffer and pointer-oriented string APIs do not generally map cleanly to JS plain values. -
strncatC buffer and pointer-oriented string APIs do not generally map cleanly to JS plain values. -
strncpyC buffer and pointer-oriented string APIs do not generally map cleanly to JS plain values. -
strtokStateful tokenizer semantics do not fit Locutus' plain-value model.
Shipped (1)
Next
Sized string formatting still produces a plain string result.
snprintf
Variadic string formatting still yields a plain string result.
vsnprintfvsprintf
Explicit non-goals (7)
-
fprintfstdio printing APIs are primarily output sinks rather than plain-value helpers. -
fputsstdio printing APIs are primarily output sinks rather than plain-value helpers. -
printfstdio printing APIs are primarily output sinks rather than plain-value helpers. -
putcharstdio printing APIs are primarily output sinks rather than plain-value helpers. -
putsstdio printing APIs are primarily output sinks rather than plain-value helpers. -
vfprintfstdio printing APIs are primarily output sinks rather than plain-value helpers. -
vprintfstdio printing APIs are primarily output sinks rather than plain-value helpers.
Shipped (1)
Next
Scalar math helpers are strong plain-value portability targets.
acosasinatanatan2ceilcopysigncosexpfabsfloorfmodhypotloglog10modfpowsinsqrttantrunc