JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5313
  • Score
    100M100P100Q127954F
  • License Apache-2.0

Adapter code to run the CometD JavaScript library in a NodeJS environment

Package Exports

  • cometd-nodejs-client

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (cometd-nodejs-client) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

NodeJS CI

The CometD Project

CometD NodeJS Client

This project implements adapter code that allows the CometD JavaScript Client to run in a NodeJS environment.

The adapter code exports an implementation of XMLHttpRequest so that the CometD JavaScript Client works in NodeJS as it does within a browser environment.

WebSocket is supported via the ws package.

NPM Installation

Firstly, you need to install the CometD NodeJS Client:

npm install cometd-nodejs-client

The CometD NodeJS Client does not depend on the CometD JavaScript Client; you need the CometD JavaScript Client to develop your applications.

Therefore, you need to install the CometD JavaScript Client, version 3.1.2 or greater:

npm install cometd

Usage (CommonJS)

// Run the adapter code that implements XMLHttpRequest.
require('cometd-nodejs-client').adapt();

// Your normal CometD client application here.
var lib = require('cometd');
var cometd = new lib.CometD();
...

Usage (ES Modules)

import { CometD } from 'cometd';
import { adapt } from 'cometd-nodejs-client';
// Shim XMLHTTPRequest for Node.js (required by CometD).
adapt();

// Your normal CometD client application here.
const client = new CometD();

See here for an example CometD client application.