A collection of lightweight, high-performance TypeScript utility functions designed to bridge the gap between common Python idioms and JavaScript runtime environments. This library streamlines data manipulation and object handling by providing robust, type-safe alternatives to standard Pythonic patterns.
- Dict-like Object Iterators: Implements
items(),keys(), andvalues()helpers that mirror Python dictionary behavior for seamless object traversal. - Safe Range Generator: Provides a flexible
range(start, stop, step)function that yields numbers just like its Python counterpart, perfect forfor-ofloops. - Type-Strict Filtering: Includes highly optimized array utilities like
compact()andgroupBy()with full TypeScript generics support. - Zero-Dependency Core: Built from the ground up with no external dependencies, ensuring a minimal bundle size for production environments.
Install the package via npm:
npm install python-utils-85Or using yarn:
yarn add python-utils-85Import the utilities directly into your project to start writing more readable, Python-inspired TypeScript code.
import { range, items } from 'python-utils-85';
// Using range() for iteration
for (const i of range(0, 10, 2)) {
console.log(i); // Outputs: 0, 2, 4, 6, 8
}
// Accessing object properties like a dictionary
const user = { name: 'Alice', age: 30 };
for (const [key, value] of items(user)) {
console.log(`${key}: ${value}`);
}Distributed under the MIT License. See LICENSE for more information.