
Product
Announcing Precomputed Reachability Analysis in Socket
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
my-utils-kit
Advanced tools
A lightweight and type-safe utility library for working with strings, objects, array Performance methods in TypeScript. Includes helpful methods for deep cloning, object transformations, safe access, query string handling, and more — designed for modern J
A lightweight utility toolkit built with TypeScript, offering a collection of Performance, ViewPort, string, object, and array helper methods for everyday JavaScript/TypeScript development.
npm install my-utils-kit
# or
yarn add my-utils-kit
import { camelCase, deepCloneObj, groupBy } from 'my-utils-kit';
console.log(deepCloneObj({ a: 1 })); // ➜ { a: 1 }
console.log(groupBy([{ type: 'fruit', name: 'apple' }], 'type'));
import { debounce, throttle, OperationBatcher, memoize } from 'my-utils-kit';
// ---------- 1. DEBOUNCE ----------
function handleInput(event: Event) {
const input = (event.target as HTMLInputElement).value;
console.log('Debounced Input:', input);
}
const debouncedInput = debounce(handleInput, 300);
document
.getElementById('searchInput')
?.addEventListener('input', debouncedInput);
// ---------- 2. THROTTLE ----------
function onScroll() {
console.log('Throttled scroll triggered');
}
const throttledScroll = throttle(onScroll, 200);
window.addEventListener('scroll', throttledScroll);
// ---------- 3. BATCH ----------
// Create an instance of the batcher
const batcher = new OperationBatcher(200); // 200ms delay between flushes
// Enqueue async or sync operations
batcher.enqueueOperation(() => apiCall1());
batcher.enqueueOperation(() => apiCall2());
// Example function definitions (for demonstration)
function apiCall1() {
console.log('API Call 1 triggered');
}
function apiCall2() {
console.log('API Call 2 triggered');
}
// ---------- 4. MEMOIZE ----------
function expensiveCalc(n: number): number {
console.log('Computing...');
return n * n;
}
const memoizedCalc = memoize(expensiveCalc);
console.log(memoizedCalc(5)); // Computes
console.log(memoizedCalc(5)); // Cached
// ----------5. loadScriptOnUserEvent -------
loadScriptOnUserEvent('https://example.com/analytics.js', {
events: ['click', 'keydown'],
timeout: 8000,
});
// ----------6. runCallbackOnUserEvent -------
runCallbackOnUserEvent(() => {
callback()
}, {
events: ['click', 'keydown'],
timeout: 7000,
});
// ----------7. observeElementOnIntersect -------
observeElementOnIntersect('.track-on-view', { threshold: 0.4 }, (entry) => {
entry.target.classList.add('visible');
console.log('Intersected:', entry.target);
});
// ----------8. Current Screen Size -------
import { getScreenSize } from 'my-utils-kit';
const size = getScreenSize();
console.log(size); // e.g., "md"
debounce(fn,delay,immediate=false)
throttle(fn,delay,immediate=false)
memoize(expensiveCalc)
new OperationBatcher()
loadScriptOnUserEvent(src,options)
runCallbackOnUserEvent(callback,options)
observeElementOnIntersect(el,options, callback)
getScreenSize(breakpoints?)
Returns the current screen size label based on breakpoints.
If no custom breakpoints are provided, the following default breakpoints are used:
Label | Min Width | Max Width |
---|---|---|
xs | 0px | 480px |
sm | 481px | 640px |
md | 641px | 768px |
lg | 769px | 1024px |
xl | 1025px | 1280px |
2xl | 1281px | 1536px |
3xl | 1537px | ∞ (Infinity) |
watchScreenSize(callback, breakpoints?)
camelCase(str)
kebabCase(str)
snakeCase(str)
capitalize(str)
truncate(str, length)
reverseString(str)
capitalize(str)
uncapitalize(str)
padStart(str, length, char)
padEnd(str, length, char)
repeatString(str, times)
isPalindrome(str)
countOccurrences(str, char)
removeSpaces(str)
removeSpecialChars(str)
escapeHTML(str)
unescapeHTML(str)
slugify(str)
maskString(str, visibleChars, maskChar='*')
stripTags(htmlStr)
toAscii(str)
toHex(str)
toBase64(str)
fromBase64(str)
toBinary(str)
fromBinary(str)
randomString(length, chars?)
swapCase(str)
countWords(str)
removeDuplicates(str)
toTitleCase(str)
isAnagram(str1, str2)
findLongestWord(str)
deepCloneObj(obj)
deepMerge(obj1, obj2)
flattenObject(obj)
unflattenObject(flatObj)
getNestedValue(obj, path)
setNestedValue(obj, path, value)
omit(obj, keys)
pick(obj, keys)
invertObj(obj)
isEmpty(obj)
hasKey(obj, key)
hasDeepKey(obj, path)
isPlainObject(val)
getObjectSize(obj)
freeze(obj)
seal(obj)
isFrozen(obj)
isSealed(obj)
objectIntersection(obj1, obj2)
objectDifference(obj1, obj2)
transformObjectKeys(obj, fn)
transformObjectValues(obj, fn)
queryStringToObject(str)
objectToQueryString(obj)
isSubset(obj1, obj2)
deleteKey(obj, key)
getTypeOfValue(val)
unique(arr)
flatten(arr, depth=1)
chunk(arr, size)
shuffle(arr)
randomElement(arr)
difference(arr1, arr2)
intersection(arr1, arr2)
union(arr1, arr2)
zip(arr1, arr2)
unzip(arr)
partition(arr, fn)
sortBy(arr, key, order='asc')
moveElement(arr, fromIndex, toIndex)
reverseArray(arr))
rotateArray(arr, positions)
deepFlatten(arr)
first(arr, n=1)
last(arr, n=1)
compact(arr)
sortNumbers(arr, order='asc')
arrayToObject(arr, key)
objectToArray(obj)
range(start, end, step=1)
sum(arr)
average(arr)
median(arr)
mode(arr)
isSorted(arr)
everyNth(arr, n)
findDuplicates(arr)
uniqueObjects(arr, key)
my-utils-kit/
├── src/
│ ├── arrayUtils.ts
│ ├── objectUtils.ts
│ └── stringUtils.ts
│ └── functionUtils.ts
├── dist/
│ └── compiled JS files
├── index.ts
└── package.json
npm run build
Uses TypeScript to compile code to the dist/
directory.
To test your package before publishing:
# From your package folder
npm link
# From your test project
npm link my-utils-kit
Then use it like a normal module:
import { camelCase } from 'my-utils-kit';
MIT – feel free to use and contribute.
Made with ❤️ by Vinoth Madhavan
FAQs
A lightweight and type-safe utility library for working with strings, objects, array Performance methods in TypeScript. Includes helpful methods for deep cloning, object transformations, safe access, query string handling, and more — designed for modern J
The npm package my-utils-kit receives a total of 242 weekly downloads. As such, my-utils-kit popularity was classified as not popular.
We found that my-utils-kit demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Socket’s precomputed reachability slashes false positives by flagging up to 80% of vulnerabilities as irrelevant, with no setup and instant results.
Product
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.
Product
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.