Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions public/data/javascript.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,6 @@
{
"categoryName": "Array Manipulation",
"snippets": [
{
"title": "Slugify String",
"description": "Converts a string into a URL-friendly slug format.",
"code": [
"const slugify = (string, separator = \"-\") => {",
" return string",
" .toString() // Cast to string (optional)",
" .toLowerCase() // Convert the string to lowercase letters",
" .trim() // Remove whitespace from both sides of a string (optional)",
" .replace(/\\s+/g, separator) // Replace spaces with {separator}",
" .replace(/[^\\w\\-]+/g, \"\") // Remove all non-word chars",
" .replace(/\\_/g, separator) // Replace _ with {separator}",
" .replace(/\\-\\-+/g, separator) // Replace multiple - with single {separator}",
" .replace(/\\-$/g, \"\"); // Remove trailing -",
"};",
"",
"// Usage:",
"const title = \"Hello, World! This is a Test.\";",
"console.log(slugify(title)); // Output: 'hello-world-this-is-a-test'",
"console.log(slugify(title, \"_\")); // Output: 'hello_world_this_is_a_test'"
],
"tags": ["javascript", "string", "slug", "utility"],
"author": "technoph1le"
},
{
"title": "Remove Duplicates",
"description": "Removes duplicate values from an array.",
Expand Down Expand Up @@ -57,6 +33,30 @@
{
"categoryName": "String Manipulation",
"snippets": [
{
"title": "Slugify String",
"description": "Converts a string into a URL-friendly slug format.",
"code": [
"const slugify = (string, separator = \"-\") => {",
" return string",
" .toString() // Cast to string (optional)",
" .toLowerCase() // Convert the string to lowercase letters",
" .trim() // Remove whitespace from both sides of a string (optional)",
" .replace(/\\s+/g, separator) // Replace spaces with {separator}",
" .replace(/[^\\w\\-]+/g, \"\") // Remove all non-word chars",
" .replace(/\\_/g, separator) // Replace _ with {separator}",
" .replace(/\\-\\-+/g, separator) // Replace multiple - with single {separator}",
" .replace(/\\-$/g, \"\"); // Remove trailing -",
"};",
"",
"// Usage:",
"const title = \"Hello, World! This is a Test.\";",
"console.log(slugify(title)); // Output: 'hello-world-this-is-a-test'",
"console.log(slugify(title, \"_\")); // Output: 'hello_world_this_is_a_test'"
],
"tags": ["javascript", "string", "slug", "utility"],
"author": "technoph1le"
},
{
"title": "Capitalize String",
"description": "Capitalizes the first letter of a string.",
Expand Down