Curated JavaScript utilities — without the lodash bloat
A practical, opinionated toolbox of helpers we actually reach for in production — Python's itertools, functools, and collections ported to JS: 19 lazy generators, memoize and partial, Counter and DefaultDict. Every area is its own package subpath, so you can require lang/checks on its own and leave the rest behind. Zero runtime dependencies, working across Node, the browser, and edge runtimes.
npm install @wizhut_tech/wizjs Helpers live under namespaces — lang, io, math — so the right tool is wherever your fingers expect it. Each area is also a package subpath, so the import path and the docs page are the same address.
The root import still hands back the whole nested object — handy at the REPL, or in scripts where one require is simpler.
const wizjs = require('@wizhut_tech/wizjs') wizjs.lang.checks.isNil(undefined) // → true wizjs.lang.checks.isObject({ a: 1 }) // → true wizjs.math.numbers.clamp(42, 0, 10) // → 10
Every namespace area answers to its own subpath, so nothing else is loaded. Needs Node 14.13 or newer.
const { isNil, isEmpty } = require('@wizhut_tech/wizjs/lang/checks') const { clamp } = require('@wizhut_tech/wizjs/math/numbers') // …/<namespace>/<area> — nothing else is loaded if (isNil(value) || isEmpty(value)) { return defaultValue } clamp(value, 0, 10)
itertools mirrors the Python primitives we all miss — 19 lazy generators.
const itertools = require('@wizhut_tech/wizjs/lang/itertools') const pairs = [...itertools.zip(['a', 'b', 'c'], [1, 2, 3])] // → [['a', 1], ['b', 2], ['c', 3]] const batches = [...itertools.batched([1, 2, 3, 4, 5], 2)] // → [[1, 2], [3, 4], [5]]
functools for compose, partial, once, memoize.
const { compose } = require('@wizhut_tech/wizjs/lang/functools') // composes right to left, like Python const slugify = compose( s => s.replace(/\s+/g, '-'), s => s.trim(), s => s.toLowerCase() ) slugify(' Hello World ') // → 'hello-world'
Counter and DefaultDict straight from Python, joined by pick, omit, and get.
const { Counter } = require('@wizhut_tech/wizjs/lang/collections') const objects = require('@wizhut_tech/wizjs/lang/objects') const tally = new Counter(['js', 'py', 'js', 'go', 'js']) tally.mostCommon(2) // → [['js', 3], ['py', 1]] tally.get('rb') // → 0 — unseen simply counts as zero objects.pick({ id: 7, name: 'Ada', password: '…' }, ['id', 'name']) // → { id: 7, name: 'Ada' }
Ten focused namespaces
Practical helpers, drawn from real production codebases — and only the ones that actually carry their weight.
Small file helpers — loadFully reads a whole file in one call, no fs boilerplate.
Practical array operations beyond the standard prototype — chunk, unique, flatten, compact, and accumulate for folding with named operators.
Type-safe predicates: isNil, isEmpty, isString, isObject, isInteger and friends. Drop-in replacements for the lodash predicates you actually use.
Control-flow helpers — if_exception runs a function and hands back your fallback when it throws.
The singleton pattern done right — register an instance once, getInstance anywhere.
Python's functools in JS — partial, compose, once, memoize (with a cache alias), and reduce.
Python's itertools as 19 lazy generators — chain, zip, range, enumerate, islice, groupby, product, batched, pairwise, and more. Works on any iterable.
pick, omit, and path-safe get — the three object helpers every codebase ends up writing.
The Python collections JS is missing — Counter with mostCommon and elements, and DefaultDict with a filling factory.
Numeric utilities — clamp, true modulo, and the safe coercions toInteger and toNumber.
Open source
Free, open source, and zero runtime dependencies — built to span Node, browsers, and edge runtimes. No magic, no surprises.