@guardian/libs v16.1.3
@guardian/libs
A collection of JavaScript libraries and TypeScript types for Guardian projects
ArticleElementRole
Type that describes the role of an element in an article.
Cookies
API over document.cookies
.
Core Web Vitals
API over Google’s web-vitals
.
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.
isObject
Checks whether a value is a plain object (i.e. {}
-like).
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.
storage
Robust API over localStorage
and sessionStorage
.
timeAgo
Format absolute dates as time-ago strings.
Installation
yarn add @guardian/libs
or
npm install @guardian/libs
then
import { loadScript, storage, ...etc } from '@guardian/libs';
TypeScript
If you are using this library with TypeScript, make sure you are using at least TypeScript v4.2.2.
Bundling
This package uses ES2020
.
If your target environment does not support that, make sure you transpile this package when bundling your application.
Development
Requirements
- Node LTS (latest) (nvm or fnm recommended)
- Yarn
Releasing
Changes are automatically released to NPM.
The main
branch on GitHub is analysed by semantic-release after every push.
If a commit message follows the conventional commit format, semantic-release can determine what Types of changes are included in that commit.
If necessary, it will then automatically release a new, semver-compliant version of the package to NPM.
Pull requests
Try to write PR titles in the conventional commit format, and squash and merge when merging. That way your PR will trigger a release when you merge it (if necessary).
3 days ago
3 days ago
4 days ago
4 days ago
9 days ago
9 days ago
9 days ago
9 days ago
9 days ago
10 days ago
11 days ago
11 days ago
11 days ago
11 days ago
10 days ago
11 days ago
11 days ago
11 days ago
11 days ago
11 days ago
10 days ago
11 days ago
12 days ago
12 days ago
12 days ago
12 days ago
12 days ago
12 days ago
12 days ago
15 days ago
16 days ago
16 days ago
16 days ago
19 days ago
19 days ago
1 month ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
4 months ago
5 months ago
10 months ago
9 months ago
9 months ago
10 months ago
8 months ago
9 months ago
7 months ago
7 months ago
10 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
11 months ago
11 months ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago