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

@karhoo/demand-deeplink

v20.1.2

Published

๐Ÿ”—A library to integrate with a Karhoo web app via a deep link

Downloads

13

Readme

Karhoo Deeplink is a method of passing the userโ€™s required information from the Demand Partnerโ€™s side to a Karhoo web booking application.

This library is intended to be the standard way of working with a deeplink.

Read The Docs

License

Installation

npm i @karhoo/demand-deeplink

Warnings

This library uses URLSearchParams. For old browsers, e.g. IE11 you must bring your own polyfill. You can use either js-core@3 or url-search-params-polyfill(version 8 and above)

This library uses Promise. For old browsers, e.g. IE11 you must bring your own polyfill. You can use js-core@3 to polyfill Promise

Usage

import { parse, validate, generate, Deeplink } from '@karhoo/demand-deeplink'

Parse deeplink:

const deeplinkData = parse(window.location.search)

Validate deeplink:

const { ok, errors } = validate(deeplinkData)

Generate deeplink:

const queryString = generate(deeplinkData)

Resolve deeplink:

To use Deeplink class api parameter (see Api type here) should be passed as a second argument of Deeplink constructor. For this purposes @karhoo/demand-api can be used.

import { getApi } from '@karhoo/demand-api'

const api = getApi()

const subscriber = data => console.log(data)

const deeplink = new Deeplink(window.location.search, api)

deeplink.resolve(subscriber)

Example

A lot of deeplink examples can be find here

Let's imagine, you want to deeplink from a hotel booking website to a Karhoo cab booking website.

Your customer booked a hotel room and reached their booking confirmation page. From here you can offer a complementary service to book a cab to a hotel's location.

At this stage, you know:

  1. Hotel address
  2. Time when a cab required (based on hotel check-in hours)
  3. Number of passengers
  4. Passenger first and last name (if you're willing to pass it)

All these parameters can be embedded to a Deeplink and passed to a Karhoo booking app.

Step 1. Compose deeplink data

const deeplinkData = {
  legs: [
    {
      dropoff: 'Hotel Ermitage, London, UK',
      pickupTime: '2020-03-12T12:00:00+01:00',
    },
  ],
  passengerInfo: {
    passengers: 3,
    firstName: 'Jon',
  },
  bookingType: 'PRE-BOOK',
  meta: {},
}

Step 2. Validate deeplink data

import { validate } from '@karhoo/demand-deeplink'

const { ok, errors } = validate(deeplinkData)

if (!ok) {
  console.log('Deeplink data is invalid', errors)
}

Step 3. Generate a deeplink

import { validate, generate } from '@karhoo/demand-deeplink'

const { ok, errors } = validate(deeplinkData)

if (!ok) {
  console.log('Deeplink data is invalid', errors)
  return
}

const deeplink = generate(deeplinkData)
console.log(deeplink) // ?leg-1-dropoff=Hotel+Ermitage%2C+London%2C+UK&leg-1-pickup-time=2020-03-12T12%3A00%3A00%2B01%3A00&passengers=3&first-name=Jon&booking-type=PRE-BOOK

When you get a deeplink you can navigate your user from your website by adding the link to href attribute.

For example, <a target="_blank" href="https://your-branded-app.kathoo.com/landing/?leg-1-dropoff=Hotel+Ermitage%2C+London%2C+UK&leg-1-pickup-time=2020-03-12T12%3A00%3A00%2B01%3A00&passengers=3&first-name=Jon&booking-type=PRE-BOOK"> Book a cab to a hotel </a>

Issues

Looking to contribute?

๐Ÿ› Bugs

Please file an issue for bugs, missing documentation, or unexpected behavior with a label DEEPLINK

๐Ÿ’ก Feature Requests

Please file an issue to suggest new features with a label DEEPLINK. Vote on feature requests by adding a ๐Ÿ‘. This helps maintainers prioritize what to work on.

โ“ Questions

For questions related to using the library, please re-visit a documentation first. If there are no answer, please create an issue with a label help needed and DEEPLINK.

Contributing

License

BSD-2-Clause