@justeat/f-services

1.18.0 • Public • Published

f-services

Fozzie Bear

npm version CircleCI Coverage Status Known Vulnerabilities

Usage

Installation

Install the module using NPM or Yarn:

yarn add @justeat/f-services
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)

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

Readme

Keywords

Package Sidebar

Install

npm i @justeat/f-services

Weekly Downloads

95

Version

1.18.0

License

Apache-2.0

Unpacked Size

111 kB

Total Files

6

Last publish

Collaborators

  • 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