KRAI Web API
Website
Web API for Angular creates injection tokens for working with native web APIs, simplifying their implementation, testing, and maintenance in Angular applications.
Purpose
- Testability: Injection tokens allow replacing real web APIs with mocks during testing.
- SSR: During server-side rendering (SSR), some web APIs are unavailable. Injection tokens help adapt the code to work on both client and server.
Installation
npm i @krai-tech/web-api
yarn i @krai-tech/web-api
Import
import { Token_Name } from '@krai-tech/web-api/tokens';
Tokens
WINDOW
— provides access to the global window
object
NAVIGATOR
— provides access to the window.navigator
object
USER_AGENT
— provides access to the window.navigator.userAgent
string
ANIMATION_FRAME
— shared Observable
based on window.requestAnimationFrame
CRYPTO
— provides access to the window.crypto
object
LOCATION
— provides access to the window.location
object
LOCAL_STORAGE
— provides access to the window.localStorage
object
SCREEN
— provides access to the window.screen
object
SESSION_STORAGE
— provides access to the window.sessionStorage
object
PAGE_VISIBILITY
— wrapper for the API document.addEventListener('visibilityChange')
HISTORY
— provides access to the window.history
object
Contribution
Yes please! See the
contributing guidelines
for details.
Documentation
Getting Started
License
This project is licensed under the terms of the
MIT license.