@toolsntuts/utils
v0.1.5
Published
Generic functions for basic tasks
Downloads
870
Readme
Svelte Util Functions
It makes use of the following technologies
Installation
npm i @toolsntuts/utils
Configuration
Update your vite.config.ts file in your sveltekit application with the following
import { defineConfig } from 'vitest/config';
import { sveltekit } from '@sveltejs/kit/vite';
export default defineConfig({
plugins: [sveltekit()],
server: {
fs: {
allow: [
'dist', // Allow access to the dist folder
'.', // Allow access to the project root
'src' // Allow access to src if needed
]
}
}
});
timeAgo()
Accepts number input and returns string output
const date = +new Date("November 2, 2024")
const time = timeAgo(date) // returns 1 day ago
slugify()
Accepts string input and returns string output
const email = "[email protected]"
const slugified = slugify(email) // returns exampletestcom
getFolderName()
Wrapper for slugify
emailToTag()
Accepts email string returns a tag string
const email = "[email protected]"
const slugified = emailToTag(email) // returns @example
mediaUrlFormat()
Accepts email string returns a tag string
const media = "<MEDIA_FILE_NAME>.jpg"
const urlFormat = mediaUrlFormat(media) // returns .jpg