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 🙏

© 2026 – Pkg Stats / Ryan Hefner

hunit-js

v2.0.1

Published

Communication library for HUnit Channel Manager

Downloads

26

Readme

Content

  1. Installation

  2. Usage

Installation

npm install hunit-js --save

Usage

import { HUnitClient } from 'hunit-js';

// Defines authentication credentials. Hotel id, user and password.
const credentials = {
  hotelId: '20',
  userName: 'hotel.user',
  password: 'hotel.password'
};

// Instantiate the client
const hunit = new HUnitClient(credentials);

// Do request
hunit.portalRead()
  .then(console.log)
  .catch(console.error);

Example list

The examples below show the most diverse communications being made to a single hotel in a simple way.

import { HUnitClient } from 'hunit-js';

const hunit = new HUnitClient({ hotelId: '20', userName: 'hotel.user', password: 'hotel.password' });

// Get OTAs list
hunit.portalRead()
  .then(portalList => console.log({ portalList }))
  .catch(console.error);

// Get new, changed or canceled reservations
hunit.bookingRead()
  .then(reservationList => console.log({ reservationList }))
  .catch(console.error);

// Get specific reservation by HUnit ID
hunit.bookingByIdRead({ locatorId: '21565' })
  .then(reservation => console.log({ reservation }))
  .catch(console.error);

// Get specific reservation by Portal ID
hunit.bookingByIdRead({ portalId: '1', channelReservationId: '155511' })
  .then(reservation => console.log({ reservation }))
  .catch(console.error);

// Confirm receipt of reservation
const confirmationList = [
  { reservationId: '12', pmsReservationIdentifier: 'my_id_1' },
  { reservationId: '52', pmsReservationIdentifier: 'my_id_2' },
  { reservationId: '589', pmsReservationIdentifier: 'my_id_5' }
];
hunit.confirmePost(confirmationList)
  .then(confirmeResult => console.log({ confirmeResult }))
  .catch(console.error);

// Update inventory
const updates = [
  // Remove availability from apartment 12, from December 25 to December 31
  // if you do not enter the day of the week in the "dateRange" tag, all days will be considered
  {
    roomTypeId: '12',
    availability: 0,
    dateRange: { from: new Date('2021-12-25'), to: new Date('2021-12-31') }
  },
  // Remove availability from apartment 12, during the weekends of January
  {
    roomTypeId: '12',
    availability: 0,
    dateRange: { from: new Date('2021-01-01'), to: new Date('2021-01-31'), fri: true, sat: true }
  },
  // Close availability from apartment 222 sending a sell stop
  {
    roomTypeId: '222',
    dateRange: { from: new Date('2021-12-25'), to: new Date('2021-12-31') },
    stopSell: true
  },
  // Open availability from apartment 15 canceling a sell stop
  {
    roomTypeId: '15',
    dateRange: { from: new Date('2021-12-25'), to: new Date('2021-12-31') },
    stopSell: false
  }
];
hunit.availabilityUpdate(updates)
  .then(availabilityUpdateResult => console.log({ availabilityUpdateResult }))
  .catch(console.error);

// Get packages list
hunit.packageRead()
  .then(packageList => console.log({ packageList }))
  .catch(console.error);

// Get room rate list
hunit.roomRateRead()
  .then(roomRateList => console.log({ roomRateList }))
  .catch(console.error);

// Update occupancy rate
const occupancyRateList = [
  { date: new Date('2020-01-01'), occupancy: 15 },
  { date: new Date('2020-01-02'), occupancy: 21 },
  { date: new Date('2020-01-03'), occupancy: 13 }
];
hunit.occupancyRateUpdate(occupancyRateList)
  .then(rateUpdateResult => console.log({ rateUpdateResult }))
  .catch(console.error);

The requests below are made to get reservations and confirm the receipt of several hotels at the same time in a single request.

import { HUnitClient } from 'hunit-js';

const hunit = new HUnitClient({ userName: 'hotel.user', password: 'hotel.password' });

// Get new, changed or canceled reservations for all hotels
hunit.bookingReadOneCall()
  .then(reservationList => console.log({ reservationList }))
  .catch(console.error);

// Confirm receipt of reservation for all hotels
const confirmationListOneCall = [
  { hotelId: '65', reservationId: '12', pmsReservationIdentifier: 'my_id_1' },
  { hotelId: '65', reservationId: '52', pmsReservationIdentifier: 'my_id_2' },
  { hotelId: '77', reservationId: '98', pmsReservationIdentifier: 'my_id_78' }
];
hunit.bookingConfirmationOneCall(confirmationListOneCall)
  .then(confirmeResult => console.log({ confirmeResult }))
  .catch(console.error);