0.8.4 • Published 2 months ago

@sinclair/carbon v0.8.4

Weekly downloads
-
License
MIT
Repository
-
Last release
2 months ago

Test npm version License

Install

$ npm install @sinclair/carbon

Overview

Carbon is an experimental cross platform compatibility layer for Node, Deno and Bun.

License MIT

Http Server

The following starts an Http listener

import { Http } from '@sinclair/carbon'

const listener = await Http.listen({ port: 5000 }, request => {

  return new Response('hello world')
})

WebSocket Server

The following upgrades an Http request into a WebSocket

import { Http } from '@sinclair/carbon'

const listener = await Http.listen({ port: 5000 }, request => {

  return Http.upgrade(request, socket => {

    socket.send('hello world')
  })
})

Features

Carbon implements several API abstractions that provide a uniform way to interact with core functionality provided by each runtime. It is built exclusively for ESM and dynamic platform detection + dynamic ESM imports to load implementations for each runtime.

The following API's are implemented

FeatureInfoNodeDenoBunBrowser
AnsiAnsi Terminal CodesYesYesYesYes
AssertValue AssertionsYesYesYesYes
AsyncAsync UtilsYesYesYesYes
BenchmarkPerformance MeasurementsYesYesYesYes
BufferOperations on Uint8Array BuffersYesYesYesYes
ChannelMulti Sender Single Receiver ChannelsYesYesYesYes
CryptoWeb Crypto APIYesYesYesYes
EncodingJson and Binary Buffer EncodingYesYesYesYes
EventsEvent EmittersYesYesYesYes
FsIsolated File SystemYesYesYesYes
HttpHttp and WebSocketsYesYesYesPartial
NetTcp Listeners and SocketsYesYesYesNo
OsOperating System ResolverYesYesYesYes
PathPathing Utils (Windows and Posix)YesYesYesYes
PerformanceWeb Performance APIYesYesYesYes
ProcessStandard IO and TTYYesYesYesPartial
QsQuery String ParsingYesYesYesYes
RuntimeJavaScript Runtime ResolverYesYesYesYes
StreamStream InterfacesYesYesYesYes
TestUnit TestingYesYesYesYes
TypeType System (TypeBox)YesYesYesYes
UrlUrl ParsingYesYesYesYes
ValueValue Operations (TypeBox)YesYesYesYes
0.8.4

2 months ago

0.8.3

3 months ago

0.8.2

3 months ago

0.8.1

3 months ago

0.8.0

3 months ago