19.1.0 • Published 8 months ago

@guardian/libs v19.1.0

Weekly downloads
229
License
-
Repository
-
Last release
8 months ago

@guardian/libs

npm (scoped) ES version npm type definitions

A collection of JavaScript libraries and TypeScript types for Guardian projects

ArticleElementRole

Type that describes the role of an element in an article.

Consent

The Guardian's consent management platform.

Cookies

API over document.cookies.

Countries

Country data and methods to access it.

Format

Codified editorial design and information architecture.

Locale

Get the user’s current location.

Switches

Get the active switches on theguardian.com.

isBoolean

Check whether a value is a boolean.

isNonNullable

Check whether a value is a NonNullable.

isObject

Checks whether a value is a plain object (i.e. {}-like).

isOneOf

Check whether a value is one of a set of literal string or numbers.

isString

Check whether a value is a string.

isUndefined

Check whether a value is undefined.

joinUrl

Combines separate url parts into one valid url string.

loadScript

Inject an external JavaScript file.

log, debug

Selectively log team-specific messages to the console.

Ophan

Types relating to Ophan.

Performance

API over window.performance with hooks into log the data warehouse.

storage

Robust API over localStorage and sessionStorage.

timeAgo

Format absolute dates as time-ago strings.

Installation

Generic badge

yarn add @guardian/libs

or

npm install @guardian/libs

then

import { loadScript, storage, ...etc } from '@guardian/libs';

Bundling

This package uses ES2020.

If your target environment does not support that, make sure you transpile this package when bundling your application.

Local Testing Using Linking

  1. In the command line in your terminal, navigate to the csnx root directory. Run:
make @guardian/libs:build

This build command has to be re-run for changes to be picked up.

  1. Navigate to the repo that will test your code changes. In the appropriate folder of that repo, run
npm/yarn/pnpm link ../csnx/dist/libs/@guardian/libs

where '../csnx' is the path to your local changes in csnx where you cloned the csnx code to.

After re-building the '@guardian/libs' in step 1. this command does not have to be repeated and changes will be automatically picked up.

  1. Once you’ve developed your changes and tested, you can unlink from the repo where you are testing the changes
npm/yarn/pnpm unlink ../csnx/dist/libs/@guardian/libs
19.1.0

9 months ago

19.0.0

9 months ago

18.0.2

10 months ago

18.0.1

10 months ago

18.0.0

12 months ago

16.1.4

1 year ago

17.0.1

12 months ago

17.0.0

1 year ago

16.1.3

1 year ago

16.1.2

1 year ago

16.1.1

1 year ago

16.1.0

1 year ago

16.0.2

1 year ago

16.0.1

1 year ago

16.0.0

2 years ago

15.3.0

2 years ago

15.7.0

2 years ago

15.7.1

2 years ago

15.4.0

2 years ago

15.8.0

2 years ago

15.5.0

2 years ago

15.9.0

2 years ago

15.9.1

2 years ago

15.2.0

2 years ago

15.6.1

2 years ago

15.6.0

2 years ago

15.6.3

2 years ago

15.6.2

2 years ago

15.6.4

2 years ago

15.1.0

2 years ago

14.1.0

2 years ago

15.0.0

2 years ago

13.1.0

2 years ago

12.0.1

2 years ago

14.0.0

2 years ago

13.0.0

2 years ago

10.0.0

3 years ago

12.0.0

2 years ago

11.2.0

2 years ago

11.0.0

3 years ago

10.1.0

3 years ago

10.1.1

3 years ago

11.1.3

2 years ago

11.1.1

3 years ago

11.1.2

2 years ago

11.1.0

3 years ago

9.1.0

3 years ago

9.0.1

3 years ago

9.0.0

3 years ago

8.0.5

3 years ago

8.0.4

3 years ago

7.1.3

3 years ago

7.1.2

3 years ago

7.1.4

3 years ago

8.0.1

3 years ago

8.0.0

3 years ago

8.0.3

3 years ago

8.0.2

3 years ago

6.1.0

3 years ago

7.1.1

3 years ago

7.1.0

3 years ago

5.2.0

3 years ago

6.0.0

3 years ago

6.2.0

3 years ago

7.0.0

3 years ago

5.1.0

3 years ago

4.1.0

3 years ago

4.0.1

3 years ago

4.0.0

3 years ago

5.0.0

3 years ago

3.9.0

3 years ago

3.8.1

3 years ago

3.8.0

3 years ago

3.7.1

3 years ago

3.6.1

3 years ago

3.6.0

4 years ago

3.5.1

4 years ago

3.4.0

4 years ago

3.5.0

4 years ago

3.4.1

4 years ago

3.3.0

4 years ago

3.2.1

4 years ago

3.2.0

4 years ago

3.1.0

4 years ago

2.7.0

4 years ago

2.6.0

4 years ago

2.8.0

4 years ago

3.0.0

4 years ago

2.5.0

4 years ago

2.4.0

4 years ago

2.3.0

4 years ago

2.2.1

4 years ago

2.2.0

4 years ago

2.1.0

4 years ago

1.8.1

4 years ago

1.8.0

4 years ago

2.0.0

4 years ago

1.7.1

4 years ago

1.7.0

4 years ago

1.6.3

4 years ago

1.6.2

5 years ago

1.6.1

5 years ago

1.6.0

5 years ago

1.5.0

5 years ago

1.4.3

5 years ago

1.4.2

5 years ago

1.4.1

5 years ago

1.4.0

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.2.0

5 years ago

1.3.0

5 years ago

1.1.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago