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/576 shipped · 128 next 3%
Locutus tracks 32 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.
In progress
Next
Character classification helpers map cleanly to plain strings and numbers.
isblankiscntrlisgraphisprintispunctisxdigit
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 (27)
-
memccpyC buffer and pointer-oriented string APIs do not generally map cleanly to JS plain values. -
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. -
memcpy_sC 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. -
memmove_sC 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. -
memset_explicitC buffer and pointer-oriented string APIs do not generally map cleanly to JS plain values. -
memset_sC buffer and pointer-oriented string APIs do not generally map cleanly to JS plain values. -
strcat_sC buffer and pointer-oriented string APIs do not generally map cleanly to JS plain values. -
strcollC 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. -
strcpy_sC buffer and pointer-oriented string APIs do not generally map cleanly to JS plain values. -
strdupC buffer and pointer-oriented string APIs do not generally map cleanly to JS plain values. -
strerrorC buffer and pointer-oriented string APIs do not generally map cleanly to JS plain values. -
strerrorlen_sC 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. -
strncat_sC 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. -
strncpy_sC buffer and pointer-oriented string APIs do not generally map cleanly to JS plain values. -
strndupC buffer and pointer-oriented string APIs do not generally map cleanly to JS plain values. -
strnlenC buffer and pointer-oriented string APIs do not generally map cleanly to JS plain values. -
strnlen_sC 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. -
strtok_sC buffer and pointer-oriented string APIs do not generally map cleanly to JS plain values. -
strxfrmC buffer and pointer-oriented string APIs do not generally map cleanly to JS plain values.
stdlib.h
Next
Scalar conversion and numeric helpers are good portability targets.
abortabort_handler_saligned_allocat_quick_exitatexitatolatollbsearchbsearch_scall_oncecallocdefineddivexitfreefree_aligned_sizedfree_sizedgetenv_signore_handler_slabsldivllabslldivmallocmblenmbstowcsmbstowcs_smbtowcmemalignmentqsort_squick_exitrandreallocstrfromdstrfromd128strfromd32strfromd64strfromfstrfromlstrtod128strtod32strtod64strtofstrtoldstrtollstrtoulstrtoullsystemwcstombswcstombs_swctombwctomb_s
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.
Shipped (1)
Next
Scalar math helpers are strong plain-value portability targets.
acosacoshasinasinhatanatan2atanhcbrtceilcopysigncoscosherferfcexpexp2expm1fabsfdimfloorfmafmaxfminfmodfpclassifyhypotilogbisfiniteisgreaterisgreaterequalisinfislessislessequalislessgreaterisnanisnormalisunorderedldexplgammaloglog10log1plog2logbmodfnannearbyintnextafterpowremainderremquorintroundscalbnsignbitsinsinhsqrttantanhtgammatrunc
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 (60)
-
clearerrstdio printing APIs are primarily output sinks rather than plain-value helpers. -
fclosestdio printing APIs are primarily output sinks rather than plain-value helpers. -
feofstdio printing APIs are primarily output sinks rather than plain-value helpers. -
ferrorstdio printing APIs are primarily output sinks rather than plain-value helpers. -
fflushstdio printing APIs are primarily output sinks rather than plain-value helpers. -
fgetcstdio printing APIs are primarily output sinks rather than plain-value helpers. -
fgetposstdio printing APIs are primarily output sinks rather than plain-value helpers. -
fgetsstdio printing APIs are primarily output sinks rather than plain-value helpers. -
fopenstdio printing APIs are primarily output sinks rather than plain-value helpers. -
fopen_sstdio printing APIs are primarily output sinks rather than plain-value helpers. -
fprintfstdio printing APIs are primarily output sinks rather than plain-value helpers. -
fprintf_sstdio printing APIs are primarily output sinks rather than plain-value helpers. -
fputcstdio printing APIs are primarily output sinks rather than plain-value helpers. -
fputsstdio printing APIs are primarily output sinks rather than plain-value helpers. -
freadstdio printing APIs are primarily output sinks rather than plain-value helpers. -
freopenstdio printing APIs are primarily output sinks rather than plain-value helpers. -
freopen_sstdio printing APIs are primarily output sinks rather than plain-value helpers. -
fscanfstdio printing APIs are primarily output sinks rather than plain-value helpers. -
fscanf_sstdio printing APIs are primarily output sinks rather than plain-value helpers. -
fseekstdio printing APIs are primarily output sinks rather than plain-value helpers. -
fsetposstdio printing APIs are primarily output sinks rather than plain-value helpers. -
ftellstdio printing APIs are primarily output sinks rather than plain-value helpers. -
fwritestdio printing APIs are primarily output sinks rather than plain-value helpers. -
getcstdio printing APIs are primarily output sinks rather than plain-value helpers. -
getcharstdio printing APIs are primarily output sinks rather than plain-value helpers. -
gets_sstdio printing APIs are primarily output sinks rather than plain-value helpers. -
perrorstdio printing APIs are primarily output sinks rather than plain-value helpers. -
printfstdio printing APIs are primarily output sinks rather than plain-value helpers. -
printf_sstdio printing APIs are primarily output sinks rather than plain-value helpers. -
putcstdio 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. -
removestdio printing APIs are primarily output sinks rather than plain-value helpers. -
renamestdio printing APIs are primarily output sinks rather than plain-value helpers. -
rewindstdio printing APIs are primarily output sinks rather than plain-value helpers. -
scanfstdio printing APIs are primarily output sinks rather than plain-value helpers. -
scanf_sstdio printing APIs are primarily output sinks rather than plain-value helpers. -
setbufstdio printing APIs are primarily output sinks rather than plain-value helpers. -
setvbufstdio printing APIs are primarily output sinks rather than plain-value helpers. -
snprintf_sstdio printing APIs are primarily output sinks rather than plain-value helpers. -
sprintf_sstdio printing APIs are primarily output sinks rather than plain-value helpers. -
sscanfstdio printing APIs are primarily output sinks rather than plain-value helpers. -
sscanf_sstdio printing APIs are primarily output sinks rather than plain-value helpers. -
tmpfilestdio printing APIs are primarily output sinks rather than plain-value helpers. -
tmpfile_sstdio printing APIs are primarily output sinks rather than plain-value helpers. -
tmpnamstdio printing APIs are primarily output sinks rather than plain-value helpers. -
tmpnam_sstdio printing APIs are primarily output sinks rather than plain-value helpers. -
ungetcstdio printing APIs are primarily output sinks rather than plain-value helpers. -
vfprintfstdio printing APIs are primarily output sinks rather than plain-value helpers. -
vfprintf_sstdio printing APIs are primarily output sinks rather than plain-value helpers. -
vfscanfstdio printing APIs are primarily output sinks rather than plain-value helpers. -
vfscanf_sstdio printing APIs are primarily output sinks rather than plain-value helpers. -
vprintfstdio printing APIs are primarily output sinks rather than plain-value helpers. -
vprintf_sstdio printing APIs are primarily output sinks rather than plain-value helpers. -
vscanfstdio printing APIs are primarily output sinks rather than plain-value helpers. -
vscanf_sstdio printing APIs are primarily output sinks rather than plain-value helpers. -
vsnprintf_sstdio printing APIs are primarily output sinks rather than plain-value helpers. -
vsprintf_sstdio printing APIs are primarily output sinks rather than plain-value helpers. -
vsscanfstdio printing APIs are primarily output sinks rather than plain-value helpers. -
vsscanf_sstdio printing APIs are primarily output sinks rather than plain-value helpers.