🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

@fabryscript/algorithms

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fabryscript/algorithms

![License](https://img.shields.io/badge/license-MIT-blue)

0.0.3
latest
Source
npm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Algorithms

License

A collection of utility functions and algorithms for various programming tasks.

Installation

You can install the @fabryscript/algorithms library using npm or yarn:

npm install @fabryscript/algorithms
# or
yarn add @fabryscript/algorithms

Usage

Import the functions you need from the library and use them in your code.

transformKeys<T>(o: Record<string, T>, transformCallback: (originalKey: string) => string | Promise<string>): Record<string, T> | Promise<Record<string, T>>

Transform an object's keys based on a provided callback function, which can be either synchronous or asynchronous.

Parameters:

  • o (Required): The object to be operated on.
  • transformCallback (Required): The callback function that transforms each key. It must return a string as the keys are expected to be strings. This callback can be either synchronous or asynchronous.

Returns:

  • A new object with transformed keys. If the transformCallback is asynchronous, it returns a promise that resolves to the new object.

Example:

import { transformKeys } from "@fabryscript/algorithms"

const inputObject = { name: 'John', age: 30 };
const asyncTransformCallback = async (key) => key.toUpperCase();
const transformedObject = await transformKeys(inputObject, asyncTransformCallback);
console.log(transformedObject);
// Output: { NAME: 'John', AGE: 30 }

License

This library is open-source and available under the MIT License.

Keywords

utilities

FAQs

Package last updated on 30 Oct 2023

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