A production-ready JavaScript utility library and open source resource hub. All utilities are zero-dependency, fully tested with Vitest, and ready to use in any Node.js project.
git clone https://github.com/osr21/open-source-contributions
cd open-source-contributions
npm install
npm test| Utility | File | Description |
|---|---|---|
chunkArray |
utils/chunk-array.js | Split an array into chunks of a given size |
flatten / deepFlatten |
utils/flatten.js | Flatten nested arrays to a given depth |
unique / uniqueBy |
utils/unique.js | Remove duplicate values from an array |
groupBy |
utils/group-by.js | Group an array of objects by a key or function |
countBy |
utils/count-by.js | Count array items by group |
sortBy |
utils/sort-by.js | Sort objects by one or more keys (supports -key for desc) |
intersection |
utils/intersection.js | Set operations: intersection, difference, union |
compact |
utils/compact.js | Remove falsy values from an array |
zip / unzip |
utils/zip.js | Combine or split paired arrays |
range |
utils/range.js | Generate a numeric range array |
sum / average / median |
utils/sum.js | Math aggregates for arrays of numbers |
binarySearch |
utils/binary-search.js | Binary search on a sorted array |
clampArray |
utils/clamp-array.js | Clamp all numeric values in an array to a [min, max] range |
first / last |
utils/first-last.js | Get the first or last N items of an array |
frequency |
utils/frequency.js | Build a frequency map counting occurrences of each item |
swap |
utils/swap.js | Swap two elements by index (returns new array) |
| Utility | File | Description |
|---|---|---|
pick / omit |
utils/pick.js | Select or exclude keys from an object |
pickBy / omitBy |
utils/omit-by.js | Filter object keys by a predicate function |
objectMap / objectMapKeys |
utils/object-map.js | Transform object values or keys |
mergeDeep |
utils/merge-deep.js | Deep merge two objects |
deepEqual |
utils/deep-equal.js | Recursive equality comparison |
deepFreeze |
utils/deep-freeze.js | Recursively freeze an object (immutable) |
deepClone |
utils/deep-clone.js | Deep clone any value |
flattenObject |
utils/flatten-object.js | Flatten nested object to dot-notation keys |
diff |
utils/diff.js | Shallow diff: find added, removed, changed keys |
mapToObject / objectToMap |
utils/map-convert.js | Convert between Map and plain object |
compactObject |
utils/compact.js | Remove falsy-valued keys from an object |
objectSize |
utils/object-size.js | Estimate serialized size of an object in bytes |
invert |
utils/invert.js | Swap keys and values of an object |
getNestedValue |
utils/get-nested.js | Safely read a deeply nested value using a dot-path string |
setNestedValue |
utils/set-nested.js | Immutably set a deeply nested value using a dot-path string |
| Utility | File | Description |
|---|---|---|
slugify |
utils/slugify.js | Convert a string to a URL-friendly slug |
capitalize / titleCase / truncate |
utils/capitalize.js | String formatting helpers |
toCamelCase / toSnakeCase / toKebabCase |
utils/camel-case.js | Convert between naming conventions |
wordCount / charCount / readingTime |
utils/word-count.js | Text analysis utilities |
escapeHtml / unescapeHtml |
utils/escape-html.js | Escape and unescape HTML entities |
interpolate |
utils/interpolate.js | Replace {placeholder} vars in a template string |
pluralize |
utils/pluralize.js | Pluralize English words based on count |
padStart / padEnd / zeroPad |
utils/pad.js | Pad strings to a minimum length |
chunkString / splitLines / wordWrap |
utils/chunk-string.js | Split and wrap string content |
byteSize |
utils/string-bytes.js | Get the UTF-8 byte size of a string |
stripHtml |
utils/strip-html.js | Remove all HTML tags from a string |
stringSimilarity |
utils/string-similarity.js | Dice coefficient similarity score between two strings (0–1) |
levenshtein |
utils/levenshtein.js | Levenshtein edit distance between two strings |
regexEscape |
utils/regex-escape.js | Escape special regex characters so a string can be used in a RegExp |
countOccurrences |
utils/count-occurrences.js | Count how many times a substring appears in a string |
| Utility | File | Description |
|---|---|---|
clamp |
utils/clamp.js | Clamp a number between min and max |
round / floor / ceil |
utils/round.js | Rounding with decimal precision control |
randomInt / randomItem / shuffle |
utils/random.js | Random number, item, and array shuffle |
formatNumber / formatPercent / formatCompact |
utils/format-number.js | Number display formatting |
formatBytes |
utils/format-bytes.js | Human-readable file size (KB, MB, GB…) |
formatCurrency |
utils/currency.js | Format a number as currency |
formatDate / timeAgo |
utils/format-date.js | Date display and relative time |
hash |
utils/hash.js | Fast djb2 non-cryptographic string hash |
factorial |
utils/factorial.js | Compute the factorial of n (iterative, safe for large n) |
fibonacci |
utils/fibonacci.js | Return the nth Fibonacci number (0-indexed, iterative) |
gcd / lcm |
utils/gcd-lcm.js | Greatest common divisor and least common multiple |
isPrime |
utils/is-prime.js | Check whether a number is prime |
lerp |
utils/lerp.js | Linear interpolation and numeric range mapping |
movingAverage |
utils/moving-average.js | Simple moving average over a sliding window |
toRoman / fromRoman |
utils/roman-numerals.js | Convert integers (1–3999) to/from Roman numeral strings |
numberToWords |
utils/number-to-words.js | Convert a non-negative integer to English words |
| Utility | File | Description |
|---|---|---|
debounce |
utils/debounce.js | Delay a function until calls stop |
throttle |
utils/throttle.js | Limit a function to once per interval |
memoize |
utils/memoize.js | Cache function results by arguments |
once |
utils/once.js | Ensure a function is called only once |
retry |
utils/retry.js | Retry an async function with exponential backoff |
sleep |
utils/sleep.js | Pause execution for a given number of ms |
withTimeout |
utils/timeout.js | Race a promise against a timeout |
pipe / compose |
utils/pipe.js | Functional composition helpers |
noop / identity |
utils/noop.js | No-op and identity function utilities |
batch |
utils/batch.js | Process items in parallel batches |
asyncMap / asyncFilter |
utils/async-map.js | Async versions of map and filter |
asyncReduce |
utils/async-reduce.js | Sequential async reduce |
allSettledSplit |
utils/promise-split.js | Split fulfilled vs rejected promises |
composeMiddleware |
utils/middleware.js | Compose a chain of middleware functions (koa/express style) |
| Utility | File | Description |
|---|---|---|
Queue |
utils/queue.js | FIFO queue |
Stack |
utils/stack.js | LIFO stack |
LinkedList |
utils/linked-list.js | Singly linked list |
LRUCache |
utils/lru-cache.js | Least Recently Used cache |
PriorityQueue |
utils/priority-queue.js | Min-heap priority queue with custom comparator |
Trie |
utils/trie.js | Prefix tree for fast string prefix lookup and autocomplete |
TTLCache |
utils/ttl-cache.js | Cache where entries automatically expire after a TTL |
FSM |
utils/fsm.js | Lightweight finite state machine |
EventEmitter |
utils/event-emitter.js | Pub/sub event emitter |
PubSub |
utils/pub-sub.js | Standalone publish-subscribe event bus |
Observable |
utils/observable.js | Reactive observable value |
RateLimiter |
utils/rate-limiter.js | Token bucket rate limiter |
| Utility | File | Description |
|---|---|---|
isValidEmail / isValidUrl |
utils/validate-email.js | Email and URL validation |
isEmpty |
utils/is-empty.js | Check if a value is empty (null, [], {}, '') |
toBoolean |
utils/to-boolean.js | Coerce strings/numbers to boolean |
isBrowser / isNode / prefersDark |
utils/is-browser.js | Runtime environment detection |
safeJsonParse / safeJsonStringify |
utils/safe-json.js | JSON with safe error handling |
| Utility | File | Description |
|---|---|---|
uuid |
utils/uuid.js | Generate a UUID v4 string |
compareSemver / satisfies |
utils/semver.js | Semantic version comparison |
parseCsv / toCsv |
utils/parse-csv.js | Lightweight CSV parser and serializer |
parseUrl / buildUrl / getParam |
utils/parse-url.js | URL parsing and query string building |
parseQueryString / toQueryString |
utils/parse-query-string.js | Query string parse and serialize |
hexToRgb / rgbToHex |
utils/color.js | Color format conversion |
deepFreeze |
utils/deep-freeze.js | Make an object recursively immutable |
encodeBase64 / decodeBase64 |
utils/base64.js | Base64 encode/decode (works in Node.js and browsers) |
formatDuration / parseDuration |
utils/parse-duration.js | Format milliseconds to a human-readable string and parse duration strings |
storage |
utils/storage.js | Safe localStorage wrapper with JSON serialization and fallback |
| Guide | Description |
|---|---|
| Contributing | How to contribute to this project |
| Code of Conduct | Community standards |
| Getting Started | Setup and first steps |
| Style Guide | Coding conventions |
| Git Workflow | Branching and commit standards |
| Open Source Guide | Beginner's guide to contributing to open source |
| API Design | REST API design best practices |
| Security Checklist | Web security checklist |
| Performance Tips | Frontend performance optimization |
| Testing Guide | Unit, integration, and E2E testing |
| Accessibility | Web accessibility (a11y) guide |
| Deployment | Deploying Node.js applications |
| TypeScript Tips | Utility types and patterns |
| React Patterns | Common React patterns |
| Node.js Best Practices | Node.js production tips |
| Docker Basics | Docker quick reference |
| SQL Cheat Sheet | SQL quick reference |
| Regex Guide | Common regex patterns |
| HTTP Status Codes | HTTP status code reference |
| CLI Tools | Useful CLI tools for developers |
| Algorithms | Algorithm complexity cheat sheet |
| Data Structures | Data structures reference |
| Design Patterns | Common software design patterns |
npm install
npm test # run all tests once
npm run test:watch # watch mode
npm run test:coverage # with coverage reportMIT © osr21