# @justeat/f-services

> Fozzie Services - Shared Services for Components and projects

Latest version **1.18.1** (published 2024-04-29) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @justeat/f-services
pnpm add @justeat/f-services
yarn add @justeat/f-services
bun add @justeat/f-services
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.18.1 |
| Published | 2024-04-29 |
| First published | 2019-09-24 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=14 |
| Dependencies | 2 |
| Unpacked size | 127.5 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 14 |
| Maintainers | ilia.chikmarev, fidel.montesino, anastasiia.horban, raouf.sawehli, mmakwe-onyeka, gregory.palaci, arielfdr, dawidchar, roberto.santana, lizzie.turney, davidpn.11, dandel10n, mwh1989, kevinrodrigues, fozzie-bot, ashleynolan, simonsje, xander-marjoram, sergii.semenkiv, thomaswilliammcclean, benrwhite, robertellison, zlatin.ivanov, joshuang2332, oliversweb, andymayje, jamieomaguire, adammorr, lsphillips |
| Keywords | fozzie |

## Links

- npm: https://www.npmjs.com/package/@justeat/f-services
- Repository: https://github.com/justeat/fozzie-components
- Homepage: https://github.com/justeat/fozzie-components/tree/master/packages/services/f-services
- Issues: https://github.com/justeat/fozzie-components/issues
- npm.io page: https://npm.io/package/@justeat/f-services

## Dependencies (2)

- [lodash-es](https://npm.io/package/lodash-es.md) 4.17.21
- [window-or-global](https://npm.io/package/window-or-global.md) 1.0.1

## Recent versions

- 1.18.1 (latest) — 2024-04-29
- 0.4.0 (beta) — 2019-09-25
- 1.18.0 — 2024-03-14
- 1.17.0 — 2022-07-26
- 1.16.1 — 2022-06-16
- 1.16.0 — 2022-05-16
- 1.15.0 — 2022-05-12
- 1.14.0 — 2022-02-22
- 1.13.0 — 2021-08-26
- 1.11.0 — 2021-05-06
- 1.10.0 — 2021-04-28
- 1.9.0 — 2021-03-24
- 1.8.0 — 2021-03-23
- 1.7.0 — 2020-12-08
- 1.6.0 — 2020-12-01
- … 21 more at https://npm.io/package/@justeat/f-services/versions

## README

<!--suppress SpellCheckingInspection -->
<div align="center">

# f-services

<img width="125" alt="Fozzie Bear" src="../../../bear.png" />

</div>

---

[![npm version](https://badge.fury.io/js/%40justeat%2Ff-services.svg)](https://badge.fury.io/js/%40justeat%2Ff-services)
[![CircleCI](https://circleci.com/gh/justeat/fozzie-components.svg?style=svg)](https://circleci.com/gh/justeat/workflows/fozzie-components)
[![Coverage Status](https://coveralls.io/repos/github/justeat/f-services/badge.svg)](https://coveralls.io/github/justeat/f-services)
[![Known Vulnerabilities](https://snyk.io/test/github/justeat/f-services/badge.svg?targetFile=package.json)](https://snyk.io/test/github/justeat/f-services?targetFile=package.json)

## Usage

### Installation

Install the module using NPM or Yarn:

```sh
yarn add @justeat/f-services
```

```sh
npm install @justeat/f-services
```

### Import the package

You can import it in your component/application like this (please note that styles have to be imported separately)

```js
import { windowServices } from '@justeat/f-services';

// You can then (optionally) destructure
const { addEvent, getWindowWidth, removeEvent } = windowServices;

```

If you are using Webpack, you can import the component dynamically to separate the services bundle from the main `bundle.client.js`:

### Services in the bundle:

----

#### Axios

##### `createClient`

Create an axios client.
##### `createCamelCaseClient`

Create an axios client with all response JSON transformed to camelCase.

##### `getNetworkDetails`

Uses the navigator API (falling back to moz/webkit) to return network information.

##### `objectToCamelCase`

Recursively converts object's property names to camelCase.

----

#### Globalisation

##### `getLocale`

Returns the locale for the current tenant, if the configuration for that locale is present, otherwise returns the default locale.

##### `getTheme`

Returns the theme based on the user's locale. Either `ml` for Menulog or `je` for Just Eat.

----

#### Window

Uses the `window-or-global` module for SSR compatibility.

##### `addEvent`

Add an event listener with a callback function. Optional throttling. Returns the function that will be called by the listener.

##### `getWindowHeight`

Returns the current innerHeight.

##### `getWindowWidth`

Returns the current innerWidth.

##### `removeEvent`

Remove an event listener. To remove a throttled event, pass in the value returned by `addEvent` when the listener was added.

----

#### Utilities

##### default export

Returns a deep object by traversing following the provided path.

----

#### Validations

##### `getFormValidationState`

Returns an object containing arrays of the names of valid and invalid validation rules.

##### `isValidPostcode`

Returns a boolean indicating whether the provided postcode is valid in the provided locale.

##### `isValidPhoneNumber`

Returns a boolean indicating whether the provided phone number is valid in the provided locale.x

---
_Source: https://npm.io/package/@justeat/f-services · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
