1.8.15 • Published 6 months ago

conversikit v1.8.15

Weekly downloads
-
License
ISC
Repository
github
Last release
6 months ago

CONVERSIKIT is a versatile JavaScript library that provides a wide range of functions for converting and transforming text and data. Whether you need to change letter casing, convert between different data formats, apply camel case formatting, or handle CSV and TSV data, CONVERSIKIT has you covered.

Overview

CONVERSIKIT is designed to simplify data processing and text manipulation tasks in your JavaScript projects. It offers a set of easy-to-use functions, each tailored for specific data transformation needs.

Features

  • Case Conversion: Easily convert text to uppercase, lowercase, or capitalize case to meet your formatting requirements.

  • JSON and Array Conversion: Seamlessly switch between JSON and array data structures, making data interchange more convenient.

  • Camel Case Formatting: Convert strings to camel case, a common practice in JavaScript coding.

  • CSV and TSV Handling: Efficiently work with CSV (Comma-Separated Values) and TSV (Tab-Separated Values) data, both for reading and writing.

Functions

toConvertUpperCase(string)

  • Converts all letters in the input string to uppercase.

toConvertLowerCase(string)

  • Converts all letters in the input string to lowercase.

toConvertCapitalizeCase(string)

  • Converts the input string into capitalize case.

toConvertArrayJson(array)

  • Converts an array to JSON format.

toConvertJsonArray(array)

  • Converts JSON data to an array format.

toConvertCamelCase(string)

  • Converts a string into camel case.

toConvertCSVFile(data, fileName)

  • Converts an array of JSON data into a CSV file.

toConvertCSVToJson(path)

  • Converts a CSV file into JSON format.

toConvertTSVToJson(path)

  • Converts a TSV (Tab-Separated Values) file into JSON format. This function is designed to take a path to a TSV file as its parameter and convert the content of the TSV file into a JSON format. It reads the TSV file, parses its contents, and returns the data as an array of JSON objects.

Examples

const conversikit = require("conversikit");

async function example() {
  const data = await conversikit.toConvertUpperCase("thank you my man"); // "THANK YOU MY MAN"
  const data1 = await conversikit.toConvertLowerCase("thank you my Man"); // "thank you my man"
  const data2 = await conversikit.toConvertCapitalizeCase("thank you my Man"); // "Thank You My Man"

  console.log(data);
  console.log(data1);
  console.log(data2);
}

example();

Convert Array to JSON

const conversikit = require("conversikit");

const data = [
  "name",
  "Ankit",
  "roll",
  "10",
  // ... (other key-value pairs)
];

const jsonData = await conversikit.toConvertArrayJson(data);
console.log("Result =", jsonData);

Output:

Result = {
  name: "Ankit",
  roll: "10",
  // ... (other key-value pairs)
};

Note: If duplicate keys are present in the array, they will be handled gracefully.

Convert String into Camel Case

const conversikit = require("conversikit");

const data = "thank you";
const data1 = "";
const data2 = "thank";
const data3 = "we are programmer";

const result = await conversikit.toConvertCamelCase(data); // "thankYou"
const result1 = await conversikit.toConvertCamelCase(data1); // ""
const result2 = await conversikit.toConvertCamelCase(data2); // "thank"
const result3 = await conversikit.toConvertCamelCase(data3); // "weAreProgrammer"

Convert Array JSON Data to CSV File

const conversikit = require("conversikit");

const data = [
  { name: "test1", age: 10 },
  { name: "test2", age: 30 },
  // ... (other objects)
];

const filename = "example.csv";
await conversikit.toConvertCSVFile(data, filename);

Convert CSV to JSON

const conversikit = require("conversikit");
const data = await conversikit.toConvertCSVToJson("give your file path name"); // e.g., "data.csv"

Output:

Result = [
  { name: 1, age: 10, dob: "12-08-1997" },
  { name: "thank", age: 90, dob: "12-09-1995" },
];

Convert TSV to JSON

const conversikit = require("conversikit");
const data = await conversikit.toConvertTSVToJson("give your file path name"); // e.g., "data.csv"

Name    Age   City
John    30    New York
Alice   25    Los Angeles
Bob     35    Chicago

Output:

Result = [
  {
    "Name": "John",
    "Age": "30",
    "City": "New York"
  },
  {
    "Name": "Alice",
    "Age": "25",
    "City": "Los Angeles"
  },
  {
    "Name": "Bob",
    "Age": "35",
    "City": "Chicago"
  }
];

Author

Arun Pradhan.

Other

Feel free to reach out for questions, feedback, or contributions.