open-index/open-npm huggingface dataset:
npm package: @justeat/js-test-buddy
Description: JS unit test helper functions.
Author: Damian Mullins
Latest version: 0.4.1

# JS Test Buddy :construction_worker:

[![npm version](https://badge.fury.io/js/js-test-buddy.svg)](https://badge.fury.io/js/js-test-buddy)
[![Build Status](https://travis-ci.org/DamianMullins/js-test-buddy.svg)](https://travis-ci.org/DamianMullins/js-test-buddy)
[![Coverage Status](https://coveralls.io/repos/github/DamianMullins/js-test-buddy/badge.svg)](https://coveralls.io/github/DamianMullins/js-test-buddy)
[![Dependency Status](https://gemnasium.com/badges/github.com/DamianMullins/js-test-buddy.svg)](https://gemnasium.com/github.com/DamianMullins/js-test-buddy)

JS unit test helper functions.
npm package: @justeattakeaway/browserslist-config-pie
Description: Shared browserslist config for applications using the PIE Design System
Author: Just Eat Takeaway.com - Design System Team
Latest version: 0.2.1

# browserslist-config-pie
[![npm version](https://badge.fury.io/js/%40justeattakeaway%2Fbrowserslist-config-pie.svg)](https://badge.fury.io/js/%40justeattakeaway%2Fbrowserslist-config-pie)

## Usage

### browserslist-config-pie

The default export contains Just Eat Takeaway's browserslist array.

Full information on browserslist shareable configs can be found in the [browserslist README](https://github.com/browserslist/browserslist#shareable-configs).

To use this config, add the following to your `package.json` once you have installed the `@justeattakeaway/browserslist-config-pie` package.

```json
"browserslist": [
  "extends @justeattakeaway/browserslist-config-pie"
]
```
npm package: @justeattakeaway/cc-stampcards-adapter
Description: The stamp cards adapter
Latest version: 0.7.1

# StampCards Adapter

This package is used to supply the frontend with users stampcards. It connects with the stampcards API and returns the transformed data into cards. The package is built in typescript and is a replacement method for getting users stampcards via braze.

The entry point for the package is `index.ts` with the function `stampCardsAdapter` being the method supplied by the package. The function accepts 3 parameters `token`, `tenant` and `url`. Here the token is the users JWT, the tenant is the users selected tenant and the url is the API URL for the stampcards API.

The `stampCardsAdapter` function returns an object with 3 functions (`initialise`, `handleCardClick`, `handleCardView`) and the source string. It also implements the `Adapter` interface like the braze adapter.

The `initialise` method requires 3 parameters `filters` which is an array of filter functions that take an array of cards and return a modified array of cards. The `callback` which is supplied to the adapter by the consuming application and returns formatted cards. The `errorCallback` which is called upon any errors occurring during the retrieval of users stampcard data.

Inside the `initialise` method we call fetch with the provided `url` and attach the `token` to the authorization header. If successful the fetch returns response.ok true. The `conversationId` is then retrieved from the response headers, and we call the `.json()` method to get the json body response.

Cards are then transformed using the `transformIntoCards` method, taking the response from the api and creating cards from the `inProgress` and `rewards` response attributes and flat mapping them into one array. Filters are then applied to the transformed cards. Cards are then returned via the `callback` function. After this the `createApiSuccessEvent` is fired.

## Installing the Adapter

To install the package run one of the following:

`yarn add @justeattakeaway/cc-stampcards-adapter`

`npm install @justeattakeaway/cc-stampcards-adapter`

## Instantiating the Adapter

To use the adapter you first have to call the function with an Object containing following parameters

```js
{
    token: () => '<THIS WOULD BE THE TOKEN>',
    tenant: '<USERS TENANT>',
    url: '<API_URL>'
}
```

Example adapter call:

```js
import stampcardsAdapter from "@justeattakeaway/cc-stampcards-adapter";

const adapter = stampcardsAdapter({
  token: () => '<THIS WOULD BE THE TOKEN>',
  tenant: '<USERS TENANT>',
  url: '<API_URL>'
});
```

## Using the adapter

### Getting Cards

Once the adapter function has been called you then need to do the following to use the adapter.

```js
adapter.initalise(
  [], // filters
  (cards) => {
  // do somthing with cards
  }, (error) => {
  // do somthing with errors
  }
)
```

### Getting Adapter Source

The adapter source can get obtained by using the source attribute on adapter. This is useful when looping over multiple adapters

```js
adapter.source
```