thienatom
v0.1.3
Published
Universal Atomic Utility Registry — language-first, zero dependencies, one task per atom.
Downloads
261
Maintainers
Readme
ThienAtom
Universal Atomic Utility Registry — language-first, zero dependencies, one task per function.
ThienAtom is a modern, lodash-alternative utility library designed with an "atomic" philosophy. It provides a comprehensive collection of helper functions where every function is strictly isolated, ensuring you only ever bundle exactly what you use.
Why ThienAtom?
- Minimum Bundle Size: No barrel exports (
index.js). You import the exact function file, guaranteeing 100% tree-shaking efficiency. - Zero Dependencies: No function imports another function within the registry or relies on third-party packages.
- TypeScript Support: Fully typed out-of-the-box with type guards, assertions, and generic type preservation.
- Mathematical Rigor: Every function is documented with Big O Complexity and mathematical definitions.
Installation
npm install thienatomQuick Start
ThienAtom is a single package that works seamlessly for both JavaScript and TypeScript. You use the exact same import paths for both; TypeScript types are automatically included!
Import only the atom you need using subpath imports:
// JavaScript (ESM) or TypeScript
import isPrime from 'thienatom/math/is-prime';
import chunk from 'thienatom/array/chunk';
// JavaScript (CommonJS)
const isPrime = require('thienatom/math/is-prime');
const chunk = require('thienatom/array/chunk');Note: Always use the default import. Each atom is the default export of its specific subpath.
Available Functions
🧮 Math
thienatom/math/is-prime- Check if a number is primethienatom/math/factorial- Calculate factorial of a numberthienatom/math/gcd- Find the greatest common divisorthienatom/math/clamp- Clamp a number between min and maxthienatom/math/round-decimal- Round a number to a specific decimal placethienatom/math/random-range- Get a random number between min and maxthienatom/math/sum- Calculate the sum of an array of numbersthienatom/math/array-min- Find the minimum value in an arraythienatom/math/array-max- Find the maximum value in an arraythienatom/math/average- Calculate the average of an array of numbersthienatom/math/in-range- Check if a number is within a given rangethienatom/math/is-even- Check if a number is eventhienatom/math/is-odd- Check if a number is odd
🔤 String
thienatom/string/slugify- Convert a string to a URL-friendly slugthienatom/string/capitalize- Capitalize the first letter of a stringthienatom/string/truncate- Truncate a string to a specific lengththienatom/string/trim-whitespace- Remove extra whitespace from a stringthienatom/string/repeat- Repeat a string a specified number of times
📚 Array
thienatom/array/chunk- Split an array into chunks of a specific sizethienatom/array/compact- Remove falsy values from an arraythienatom/array/unique- Get unique elements from an arraythienatom/array/last- Get the last element of an arraythienatom/array/first- Get the first element of an arraythienatom/array/range- Create an array of numbers within a rangethienatom/array/flatten-shallow- Flatten an array one level deepthienatom/array/difference- Find the difference between two arrays
🔍 Type (Guards & Assertions)
thienatom/type/is-nil- Check if a value is null or undefinedthienatom/type/is-defined- Check if a value is defined (not null/undefined)thienatom/type/assert-defined- Assert that a value is defined (TypeScript)thienatom/type/assert-never- Assert exhaustive matching (TypeScript)thienatom/type/is-string- Check if a value is a stringthienatom/type/is-array- Check if a value is an arraythienatom/type/is-plain-object- Check if a value is a plain object
📦 Object
thienatom/object/pick- Create an object with picked propertiesthienatom/object/omit- Create an object omitting specific properties
⚙️ Function
thienatom/function/noop- No-operation functionthienatom/function/identity- Return the first argument passedthienatom/function/debounce- Create a debounced version of a function
⏱️ Async
thienatom/async/sleep- Pause execution for a given number of millisecondsthienatom/async/timeout-wrap- Wrap a promise with a timeout
✅ Validation
thienatom/validation/is-email- Validate an email address formatthienatom/validation/is-url- Validate a URL format
🧩 Misc
thienatom/misc/coalesce- Return the first non-nil value
Contributing
The repository uses a language-first structure (units/[language]/[category]/[atom-name]). Currently, JavaScript (js) and TypeScript (ts) are supported. Check the repository documentation for more details on creating new atoms.
