@krai-tech/web-api
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

KRAI WEB API Logo

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
# or
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.

Dependencies (1)

Dev Dependencies (0)

    Package Sidebar

    Install

    npm i @krai-tech/web-api

    Weekly Downloads

    9

    Version

    1.0.0

    License

    Apache-2.0

    Unpacked Size

    107 kB

    Total Files

    60

    Last publish

    Collaborators

    • krai-tech