{"id":15692419,"url":"https://github.com/jonahsnider/util","last_synced_at":"2025-05-05T21:29:19.318Z","repository":{"id":37793611,"uuid":"316761543","full_name":"jonahsnider/util","owner":"jonahsnider","description":"A useful collection of optimized utility functions for JavaScript and TypeScript","archived":false,"fork":false,"pushed_at":"2024-10-29T10:19:28.000Z","size":20702,"stargazers_count":7,"open_issues_count":12,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-29T12:19:03.264Z","etag":null,"topics":["javascript","library","nodejs","typescript","util"],"latest_commit_sha":null,"homepage":"https://util.jonah.pw","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jonahsnider.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2020-11-28T15:18:43.000Z","updated_at":"2024-10-29T10:18:37.000Z","dependencies_parsed_at":"2023-10-03T05:30:20.231Z","dependency_job_id":"83e4ee3a-5821-4750-8679-f2f7a75bf96f","html_url":"https://github.com/jonahsnider/util","commit_stats":{"total_commits":1145,"total_committers":5,"mean_commits":229.0,"dds":0.377292576419214,"last_synced_commit":"38ac78c93ede344f2718ff15b6cbeaeb2d600d5c"},"previous_names":[],"tags_count":84,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonahsnider%2Futil","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonahsnider%2Futil/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonahsnider%2Futil/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonahsnider%2Futil/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonahsnider","download_url":"https://codeload.github.com/jonahsnider/util/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246395594,"owners_count":20770242,"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":["javascript","library","nodejs","typescript","util"],"created_at":"2024-10-03T18:33:01.711Z","updated_at":"2025-03-31T19:31:32.798Z","avatar_url":"https://github.com/jonahsnider.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [@jonahsnider/util](https://util.jonah.pw/)\n\nA collection of simple, optimized utility functions that help you spend more time implementing real features instead of writing the same snippets over and over.\n\nWritten in TypeScript with strong typesafety in mind (more on that below).\n\nWorks in Node.js, mostly works in browsers.\n\n**[View the docs here](https://util.jonah.pw/)**.\n\nIf you're considering using the library I recommend taking a glance at the docs to see if anything seems helpful to you.\n\n[![Build Status](https://github.com/jonahsnider/util/workflows/CI/badge.svg)](https://github.com/jonahsnider/util/actions)\n[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/xojs/xo)\n[![Codecov](https://codecov.io/gh/jonahsnider/util/branch/main/graph/badge.svg)](https://codecov.io/gh/jonahsnider/util)\n\n## Get started\n\n```sh\nyarn add @jonahsnider/util\n# or\nnpm install @jonahsnider/util\n```\n\nthen\n\n```js\nimport {shuffle} from '@jonahsnider/util';\n// or\nimport * as util from '@jonahsnider/util';\n\nconst {shuffle} = require('@jonahsnider/util');\n// or\nconst util = require('@jonahsnider/util');\n```\n\n## Why you should use this library\n\nThere's 3 main benefits this library offers:\n\n1. **Readability**\n\n   Because JavaScript lacks a proper standard library, you will find yourself writing the same snippets again and again.\n   Let's look at sorting an array in ascending order (low to high) as an example:\n\n   ```js\n   // Sort ascending\n   array.sort((a, b) =\u003e a - b);\n   ```\n\n   As an experienced dev you've probably seen this snippet in some form hundreds of times before.\n   If you're a beginner you might not even be able to tell if this is an ascending or descending sort without the comment.\n\n   The alternative:\n\n   ```js\n   import {Sort} from '@jonahsnider/util';\n\n   array.sort(Sort.ascending);\n   ```\n\n   If you were skimming through a file and saw this you can immediately understand what this code does.\n\n   This library works perfectly with existing idiomatic JavaScript and doesn't force you to change the way you write code.\n\n   (also - fun fact: the first snippet doesn't work with `bigint`s, [the second snippet does](https://util.jonah.pw/types/comparable))\n\n2. **Safety**\n\n   Writing your own snippets doesn't just slow you down, it can introduce bugs.\n\n   Every function is tested with 100% coverage, ensuring bug-free code.\n\n3. **Features**\n\n   This library isn't just 1-liners you could copy-paste yourself.\n\n   Want to do a binary search on an array? [We've got you covered](https://util.jonah.pw/functions/binarysearch).\n\n   Combine a bunch of regular expressions into one? [No problem](https://util.jonah.pw/functions/regexpunion).\n\n   Need a deck of cards? [Only one import away](https://util.jonah.pw/functions/newdeck).\n\n### TypeScript\n\nIn addition to all the useful functions this library provides, a major effort has been made to ensure the best possible experience for TypeScript users.\n\n- Functions accept many types of arguments, either as a generic `T` or a union of related types like `number | bigint` (mostly useful in the math functions)\n- `Iterable`s and `ArrayLike`s are used instead of `Array`s whenever possible, broader types ensure compatibility with your projects and let you avoid ugly type assertions\n- When an array is needed, it's always `readonly T[]` unless mutation is required\n\nThere's also a few types exported that can be handy in certain situations (ex. [`NonEmptyArray`](https://util.jonah.pw/types/nonemptyarray) or [`Nullish`](https://util.jonah.pw/types/nullish)).\n\nMy personal favorite is the [`TypedEventEmitter`](https://util.jonah.pw/types/typedeventemitter) which lets you ensure typesafety in event listeners.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonahsnider%2Futil","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonahsnider%2Futil","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonahsnider%2Futil/lists"}