utils

Provide JavaScript utilities for precise arithmetic, deep copying, and functional patterns.

1|1|Updated Oct 16, 2017
One-click install
npx skills add https://github.com/yanyue404/fe-attitude --skill utils
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: utils
Source: https://github.com/yanyue404/fe-attitude/tree/main/site/fe
Command: npx skills add https://github.com/yanyue404/fe-attitude --skill utils

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This collection provides reliable JavaScript utilities for common frontend tasks, addressing numeric precision, deep copying, and lightweight functional patterns to reduce boilerplate and avoid floating-point pitfalls.

Core Features & Use Cases

  • Precise arithmetic: add, sub, mul, div with correct decimal behavior to prevent floating-point errors.
  • Deep copy: robust duplication for nested objects and arrays, including special types like Date and RegExp.
  • Object utilities: shallow/loose equality checks, path-based get, object merge and clone helpers.
  • Currying and functional utilities: simple currying for partial application and function composition.
  • Async helpers: lightweight promise wrappers and straightforward async orchestration patterns.
  • Data transformation: small utilities for formatting and lightweight data manipulation.

Quick Start

Use the utils to perform common frontend tasks such as precise addition add('0.1','0.2') to obtain '0.3', or deepCopy(obj) to clone objects.

Frequently Asked Questions about utils

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent floating-point errors in JavaScript arithmetic operations?

To prevent floating-point errors in JavaScript arithmetic, use precise decimal utility functions like add, sub, mul, and div. These ensure correct calculations, so adding 0.1 and 0.2 accurately yields 0.3 without precision loss.

How do I deep copy nested objects and arrays in JavaScript without reference issues?

Deep copy nested objects and arrays in JavaScript without reference issues using a robust deepCopy utility. It safely duplicates structures including special types like Date and RegExp, preventing unintended mutations in frontend state management.

What is currying in JavaScript and how do I apply partial application to functions?

Currying in JavaScript transforms a function with multiple arguments into a sequence of nested functions for partial application. This functional programming utility enables flexible parameter binding and function composition for reusable frontend logic.

Does JavaScript deep copy handle special types like Date and RegExp correctly?

Yes, JavaScript deep copy implementations in this utility handle special types like Date and RegExp correctly. The duplication process robustly clones nested objects and arrays while preserving their specific data types and structural integrity.

How do I safely access nested object properties using a path in JavaScript?

Safely access nested object properties using a path in JavaScript by applying a path-based get utility. This object helper retrieves values from deep structures without throwing errors if intermediate properties are undefined.

Can I use lightweight async helpers for promise orchestration in frontend workflows?

Yes, you can use lightweight async helpers for promise orchestration in frontend workflows. These promise wrappers provide straightforward asynchronous patterns to manage data transformation and UI state tasks efficiently.