npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

xo-lib

v0.11.1

Published

Library to connect to XO-Server

Downloads

1,175

Readme

xo-lib

Package Version License PackagePhobia Node compatibility

Library to connect to XO-Server

Install

Installation of the npm package:

> npm install --save xo-lib

Usage

If the URL is not provided and the current environment is a web browser, the location of the current page will be used.

import Xo from 'xo-lib'

// Connect to XO.
const xo = new Xo({ url: 'https://xo.company.tld' })

// Let's start by opening the connection.
await xo.open()

// Must sign in before being able to call any methods (all calls will
// be buffered until signed in).
await xo.signIn({
  email: '[email protected]',
  password: 'admin',
})

console('signed as', xo.user)

The credentials can also be passed directly to the constructor:

const xo = Xo({
  url: 'https://xo.company.tld',
  credentials: {
    email: '[email protected]',
    password: 'admin',
  },
})

xo.open()

xo.on('authenticated', () => {
  console.log(xo.user)
})

If the URL is not provided and the current environment is a web browser, the location of the current page will be used.

Connection

await xo.open()

console.log('connected')

Disconnection

xo.close()

console.log('disconnected')

Method call

const token = await xo.call('token.create')

console.log('Token created', token)

Status

The connection status is available through the status property which is open, connecting or closed.

console.log('%s to xo-server', xo.status)

Current user

Information about the user account used to sign in is available through the user property.

console.log('Current user is', xo.user)

This property is null when the status is not connected.

Events

xo.on('open', () => {
  console.log('connected')
})
xo.on('closed', () => {
  console.log('disconnected')
})
xo.on('notification', function (notif) {
  console.log('notification:', notif.method, notif.params)
})
xo.on('authenticated', () => {
  console.log('authenticated as', xo.user)
})

xo.on('authenticationFailure', () => {
  console.log('failed to authenticate')
})

Contributions

Contributions are very welcomed, either on the documentation or on the code.

You may:

  • report any issue you've encountered;
  • fork and create a pull request.

License

AGPL-3.0-or-later © Vates SAS