Coder Social home page Coder Social logo

shontzu-deriv / deriv-utils Goto Github PK

View Code? Open in Web Editor NEW

This project forked from deriv-com/deriv-utils

0.0 0.0 0.0 699 KB

A utility library for Deriv web apps.

Home Page: https://deriv-utils.pages.dev/

JavaScript 8.85% TypeScript 89.69% CSS 1.46%

deriv-utils's Introduction

Deriv Utility Library (@deriv/utils)

npm Coverage Status

Overview

This utility library provides a comprehensive suite of utilities designed to support the development of web applications for Deriv. It encapsulates common functionalities such as handling constants, formatting, sorting, and more, with a focus on enhancing development efficiency and ensuring type safety.

This library is divided into two main namespaces:

  • Constants
    • AppIDConstants: Holds constants related to application IDs for different domains, facilitating domain-based app ID management.
    • CurrencyConstants: Enumerates all currencies supported by Deriv, simplifying currency-related operations.
    • LocalStorageConstants: An exhaustive list of all local storage keys used across Deriv web apps, ensuring consistency in local storage access.
  • Utils
    • FormatUtils: Contains utility functions for string formatting, including number formatting, currency symbol resolution, and more.
    • LocalStorageUtils: Provides a typesafe wrapper around the browser's localStorage functionality, enhancing reliability and ease of use.
    • ObjectUtils: Offers functions for manipulating objects, such as deep merging, cloning, and property extraction.
    • PromiseUtils: Includes utilities for handling promises, such as timeout wrappers and promise chaining helpers.
    • URLUtils: Contains functions for manipulating URLs, including parameter extraction, URL construction, and query string manipulation.
    • WebSocketUtils: Encapsulates utilities specific to the Deriv WebSocket, addressing environment detection, login ID retrieval, and app ID management.

Getting Started

To get started simply install deriv utils from the @deriv-com/utils package

npm i --save @deriv-com/utils

or

yarn add @deriv-com/utils

Usage Example

Each of the namespaces listed above are exposed directly from the library root. In this example, we are using the FormatUtils.formatMoney() functionality to format different currencies to their correct decimal points or localised formatting.

import { FormatUtils } from "@deriv-com/utils";

const formattedBalance = FormatUtils.formatMoney(1, { currency: "BTC" });
console.log(formattedBalance); // Should output 1.00000000

Documentation

For detailed documentation on each utility and constant, refer to the specific files in the constants and utils directories. Each utility function and constant is documented with JSDoc comments, providing insights into their purpose, parameters, and return values. (A dedicated document page is in the pipeline)

Contributing

We welcome contributions to the @deriv-com/utils library. If you have suggestions for improvements or find a bug, please open an issue or submit a pull request.

Notes

  • @deriv-com/utils outputs both ESM and CJS files but currently, this library only support code running in the browser environment. However, support for Node runtime is planned in the pipeline.

deriv-utils's People

Contributors

niloofar-deriv avatar yashim-deriv avatar adrienne-deriv avatar shontzu-deriv avatar matin-deriv avatar heorhi-deriv avatar jim-deriv avatar ali-hosseini-deriv avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.