System programming library; libjs — libc in JavaScript.
npm install libjs libsysThis library uses libsys to execute system calls from JavaScript.
It expects your environment has libsys global object, in Node.js you can shim libsys as follows:
require('libsys/shim');- Synchronous system calls
- Files — Standard file operations, which operate on most of the Linux/Unix file descriptors.
read— read from a file descriptor.write— write to a file descriptor.open— open a file.close— close a file descriptor.access— check user can access a file.chmod— change file attributes.fchmod— change file attributes.chown— change file owner.fchown— change file owner.lchown— change file owner.truncate— erase file contents.ftruncate— erase file contents.lseek— change cursor position.rename— rename a file.fsync— flush file to disk.fdatasync— flush file to disk.
- Stats — Fetches and returns statistics about a file.
- Directories
mkdir— creat a directory.mkdirat— create a directory relative to another directory.rmdir— remove a directory.getcwd— fetch current working directory.getdents64— scan through directory entries.readdir— fetch all folder entries.readdirList— fetch all folder entries.
- Links
- Time
- Networking
socket— create a socket file descriptor.connect— initiate a connection on a socket.bind— assign an address to a socket.listen— listen for new connections on a socket.accept— accept a connection on a socket.accept4— accept a connection on a socket.shutdown— shut down all or part of a full-duplex connection.send— write data to a socket file descriptor.sendto— write data to a socket file descriptor.recv— read data from socket file descriptor.recvfrom— read data from socket file descriptor.setsockopt— get and set options on a socket.
- Process
- Events
fcntl— manipulate file descriptor.epoll_create— create an epoll file descriptor.epoll_create1— create an epoll file descriptor.epoll_wait— fetch epoll events.epoll_ctl— control interface for an epoll file descriptor.inotify_initinotify_init1inotify_add_watchinotify_rm_watchkqueuekeventEV_SET
- Memory
- Files — Standard file operations, which operate on most of the Linux/Unix file descriptors.
- Asynchronous system calls
- Files:
readAsync,writeAsync,openAsync,closeAsync,accessAsync,chmodAsync,fchmodAsync,chownAsync,fchownAsync,lchownAsync,truncateAsync,ftruncateAsync,lseekAsync,renameAsync,fsyncAsync,fdatasyncAsync - Stats:
statAsync,lstatAsync, andfstatAsync - Directories:
mkdirAsync,mkdiratAsync,rmdirAsync,getcwdAsync,getdents64Async, andreaddirListAsync - Links:
symlinkAsync,unlinkAsync,readlinkAsync, andlinkAsync - Time:
utimeAsyncandutimesAsync - Networking:
socketAsync,connectAsync,bindAsync,listenAsync,acceptAsync,accept4Async,shutdownAsync,sendAsyncandsendtoAsync, - Process:
getpidAsync,getppidAsync,getuidAsync,geteuidAsync,getgidAsync, andgetegidAsync,
- Files:
- Structs
epoll_eventandIepoll_eventin_addrandIin_addrinotify_eventandIinotify_eventipc_permandIipc_permipv4andIipv4linux_dirent64andIlinux_dirent64shmid_dsandIshmid_dssigactionandIsigactionsockaddrandIsockaddrsockaddr_inandIsockaddr_instatStructandIstatStructtimespecandItimespectimevalandItimevaltimevalarrandItimevalarrutimbufandIutimbufkeventStructandIkeventStructkevent64_sStructandIkevent64_sStruct
- Sockets
flip,htons32,hton16,htons,Ip,Ipv4, andIpv6,
- Constants
Unlicense — public domain.