{"id":22323004,"url":"https://github.com/frontendfixer/-helper","last_synced_at":"2026-02-23T23:35:45.406Z","repository":{"id":261934584,"uuid":"885759659","full_name":"frontendfixer/-helper","owner":"frontendfixer","description":"A collection of simple helper functions for javascript and typescript","archived":false,"fork":false,"pushed_at":"2024-11-09T10:56:47.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-04T03:37:12.648Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/frontendfixer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-09T10:21:32.000Z","updated_at":"2024-11-09T10:56:50.000Z","dependencies_parsed_at":"2024-11-09T11:28:47.789Z","dependency_job_id":"7fd50c1f-34ef-48b1-b199-638e46a3b3aa","html_url":"https://github.com/frontendfixer/-helper","commit_stats":null,"previous_names":["frontendfixer/-helper"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frontendfixer%2F-helper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frontendfixer%2F-helper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frontendfixer%2F-helper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/frontendfixer%2F-helper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/frontendfixer","download_url":"https://codeload.github.com/frontendfixer/-helper/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":236476440,"owners_count":19154817,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-04T01:09:02.454Z","updated_at":"2026-02-23T23:35:45.373Z","avatar_url":"https://github.com/frontendfixer.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TypeScript Helper Functions\n\nA collection of utility functions for common operations in TypeScript/JavaScript applications. These functions provide easy-to-use solutions for string manipulation, encryption, date formatting, and currency formatting.\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Functions Overview](#functions-overview)\n- [Usage Examples](#usage-examples)\n- [API Reference](#api-reference)\n- [Dependencies](#dependencies)\n- [Error Handling](#error-handling)\n- [License](#license)\n\n## Installation\n\n1. Install the required dependencies:\n\n```bash\nnpm install date-fns\n# or\npnpm add date-fns\n # or\ndeno install npm:date-fns\n```\n\n2. Copy the helper functions file into your project:\n\n```bash\nutils/helpers.ts\n```\n\n3. Import the functions you need:\n\n```typescript\nimport { createSlug, formatPrice, formattedDate } from \"./utils/helpers\";\n```\n\n## Functions Overview\n\n| Function          | Description                            | Usage                        |\n| ----------------- | -------------------------------------- | ---------------------------- |\n| `createSlug`      | Converts strings to URL-friendly slugs | String manipulation for URLs |\n| `toTitleCase`     | Converts strings to Title Case         | Text formatting              |\n| `slugToTitleCase` | Converts URL slugs to Title Case       | Text formatting              |\n| `generateKey`     | Generates encryption keys              | Cryptography                 |\n| `encryptText`     | Encrypts text data                     | Data security                |\n| `decryptText`     | Decrypts encrypted data                | Data security                |\n| `sleep`           | Creates time delays                    | Async operations             |\n| `formattedDate`   | Formats dates                          | Date handling                |\n| `formatPrice`     | Formats currency values                | Currency display             |\n\n## Usage Examples\n\n### String Manipulation\n\n```typescript\n// Create URL-friendly slugs\nconst slug = createSlug(\"Hello World!\"); // Output: \"hello-world\"\nconst customSlug = createSlug(\"This Is A Test\", \"_\"); // Output: \"this_is_a_test\"\n\n// Convert to Title Case\nconst title = toTitleCase(\"hello world\"); // Output: \"Hello World\"\nconst slugTitle = slugToTitleCase(\"hello-world\"); // Output: \"Hello World\"\n```\n\n### Encryption\n\n```typescript\n// Basic encryption workflow\nasync function secureData() {\n  try {\n    // Generate a new encryption key\n    const key = await generateKey();\n\n    // Encrypt some data\n    const encrypted = await encryptText(\"Secret message\", key);\n\n    // Decrypt the data\n    const decrypted = await decryptText(encrypted, key);\n    console.log(decrypted); // Output: \"Secret message\"\n  } catch (error) {\n    console.error(\"Encryption error:\", error);\n  }\n}\n```\n\n### Date Formatting\n\n```typescript\n// Format dates\nconst today = formattedDate(new Date()); // Output: \"09/11/2024\"\nconst custom = formattedDate(new Date(), \"MM/dd/yyyy\"); // Output: \"11/09/2024\"\n```\n\n### Currency Formatting\n\n```typescript\n// Format prices\nconst price1 = formatPrice(1000); // Output: \"₹1K\"\nconst price2 = formatPrice(1500.5, {\n  currency: \"USD\",\n  notation: \"standard\",\n}); // Output: \"$1,500.50\"\n```\n\n### Async Delays\n\n```typescript\n// Create delays in async functions\nasync function delayExample() {\n  console.log(\"Start\");\n  await sleep(2000); // Wait for 2 seconds\n  console.log(\"End\");\n\n  // With callback\n  await sleep(1000, () =\u003e {\n    console.log(\"Callback executed\");\n  });\n}\n```\n\n## API Reference\n\n### String Functions\n\n#### `createSlug(title: string, replace?: string): string`\n\nCreates a URL-friendly slug from a string.\n\n- `title`: The string to convert\n- `replace` (optional): Character to use for replacing spaces (default: \"-\")\n- Throws error if title is empty or invalid\n\n#### `toTitleCase(str: string): string`\n\nConverts a string to Title Case.\n\n- `str`: The input string\n- Throws error if input is empty or invalid\n\n[Additional function documentation...]\n\n## Dependencies\n\n- `date-fns`: ^2.x.x - For date formatting operations\n- Modern browser with Web Crypto API support for encryption functions\n\n## Error Handling\n\nAll functions include comprehensive error handling and input validation. Common errors:\n\n```typescript\ntry {\n  const slug = createSlug(\"\"); // Throws: \"Title must be a non-empty string\"\n  const price = formatPrice(-100); // Throws: \"Price cannot be negative\"\n  const date = formattedDate(\"invalid-date\"); // Throws: \"Invalid date provided\"\n} catch (error) {\n  console.error(error);\n}\n```\n\n## License\n\nThis project is licensed under the MIT License - see the LICENSE file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrontendfixer%2F-helper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrontendfixer%2F-helper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrontendfixer%2F-helper/lists"}