New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@zcodeapp/utils

Package Overview
Dependencies
Maintainers
0
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zcodeapp/utils

Utils for reuse code

latest
Source
npmnpm
Version
0.3.4
Version published
Maintainers
0
Created
Source

Utils

Utils CI codecov

Overview

The Utils module provides a suite of handy functionalities for string manipulation and object transformation in TypeScript. Designed to be lightweight and efficient, this module is well-suited for common operations in web and Node.js development.

Features

  • String Manipulation: The Strings class within the Utils module offers powerful string manipulation capabilities. For instance, it can generate random strings of a specified length using a mix of alphabetic characters and numbers. This functionality is essential for creating unique identifiers, random tokens, or any scenario where random string generation is required.
  • Object Transformation: The Transform class provides simple yet effective methods for object manipulation. A notable feature is the ability to clone objects, ensuring a deep copy without reference to the original object. This is particularly useful when dealing with complex data structures in TypeScript, where immutability and pure functions are essential.

Installation

Include the Utils class in your TypeScript project:

npm install @zcodeapp/utils

Usage

First, import the Utils class and other necessary interfaces:

import { Utils } from "@zcodeapp/utils";

// generate random string with 100 chars
console.log(Utils.Strings.RandomString(100))

API Reference

Strings Class

Utils.Strings.RandomString(length: number = 10): string Generates a random string of the specified length. The default length is 10 characters.

Transform Class

Utils.Transform.Clone<T, Y = T>(origin: T): Y Creates a deep clone of the provided object. This method is type-safe and can be used to clone complex objects and arrays.

Utils.Transform.md5(key: string): string Returns a md5 of key value.

Example

Here's a basic example of how to use the Utils module:

import { Utils } from "@zcodeapp/utils";

// generate random string wirh 100 chars
console.log(Utils.Strings.RandomString(100))

License

This project is licensed under the MIT License - see the LICENSE file for details.

Keywords

utils

FAQs

Package last updated on 23 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts