npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

larax

v0.3.0

Published

Larax is an NPM package that provides Laravel-inspired helpers written in JavaScript, making it easy to use Laravel-style utilities in your Node.js or frontend projects.

Readme

Larax

Larax Logo

Larax brings Laravel's helper API to JavaScript and TypeScript. If you know Str::slug(), Arr::pluck(), Number::fileSize() or collect()->groupBy(), you already know Larax.

Features

  • 🔥 Laravel-inspired helpersStr, Arr, Obj, Num, Collection and the fluent Stringable
  • 📦 Zero runtime dependencies – ships ESM + CJS builds with full type declarations
  • 🌍 Runs anywhere – Node.js 18+, Deno, Bun and the browser
  • 🧪 Tested – every helper is covered by the test suite

Installation

npm install larax

Usage

import { Str, Arr, Obj, Num, collect, str } from "larax"

Str.slug("Crème Brûlée @ Home")        // "creme-brulee-at-home"
Arr.pluck(users, "profile.name")        // ["Taylor", "Abigail"]
Obj.get(config, "mail.from.address")    // dot notation with a fallback
Num.fileSize(1_048_576)                 // "1 MB"

collect([1, 2, 3, 4])
  .filter((n) => n % 2 === 0)
  .sum()                                // 6

str(" Laravel Framework ").squish().slug().toString() // "laravel-framework"

CommonJS works too:

const { Str } = require("larax")

Str

Static string helpers. Every method takes the subject as its first argument.

Slicingafter · afterLast · before · beforeLast · between · betweenFirst · charAt · chopStart · chopEnd · substr · substrReplace · substrCount · take · length

Searchingcontains · containsAll · doesntContain · startsWith · endsWith · position · is · isMatch · match · matchAll

Casinglower · upper · ucfirst · lcfirst · title · apa · convertCase · camel · studly · snake · kebab · headline · ucsplit

Replacementreplace · replaceArray · replaceFirst · replaceLast · replaceStart · replaceEnd · replaceMatches · remove · swap · mask

Padding & trimmingpadBoth · padLeft · padRight · trim · ltrim · rtrim · squish · deduplicate · start · finish · wrap · unwrap · wordWrap

Truncationlimit · words · wordCount · excerpt

Inflectionplural · singular · pluralStudly · pluralPascal

Transformationascii · transliterate · slug · reverse · repeat · numbers · toBase64 · fromBase64 · explode

ValidationisAscii · isJson · isUrl · isUuid · isUlid

Generationrandom · password · uuid · uuid7 · orderedUuid · ulid

Str.limit("The quick brown fox", 10)              // "The quick..."
Str.mask("[email protected]", "*", 3)            // "tay***************"
Str.plural("child")                               // "children"
Str.headline("EmailNotificationSent")             // "Email Notification Sent"
Str.excerpt("This is my name", "my", { radius: 3 }) // "...is my na..."

Multi-byte and astral characters (emoji, accents) count as single units, so Str.length("a👍b") is 3.

Stringable / str()

str(value) — or Str.of(value) — returns a chainable wrapper exposing the same API, plus append, prepend, basename, dirname, pipe, tap, when, unless, whenEmpty, whenContains, toInteger, toFloat, toBoolean and toDate.

str("tony stark")
  .whenContains("tony", (value) => value.title())
  .append(" — Iron Man")
  .toString() // "Tony Stark — Iron Man"

Chains are immutable, and the wrapper coerces to a string implicitly:

`${str("laravel")}` // "laravel"

Arr

Array and keyed-collection helpers. Methods Laravel defines over associative arrays accept both JS arrays and plain objects.

Readingget · has · hasAny · exists · first · last · sole · random · accessible · isArray · isAssoc · isList

Writingset · add · forget · pull · prepend

Shapeentries · keys · values · divide · wrap · from · collapse · flatten · dot · undot · crossJoin · chunk · split · take · partition

Selectiononly · except · select · pluck · keyBy · prependKeysWith

Filtering & mappingwhere · whereColumn · whereNotNull · reject · filter · string · map · mapWithKeys · mapSpread

Ordering & setssort · sortDesc · sortRecursive · sortRecursiveDesc · shuffle · unique · diff · intersect · contains

Output & aggregationjoin · query · toCssClasses · toCssStyles · sum · avg · min · max · groupBy · countBy · clone

Arr.dot({ products: { desk: { price: 100 } } }) // { "products.desk.price": 100 }
Arr.join(["Tailwind", "Alpine", "Livewire"], ", ", " and ")
// "Tailwind, Alpine and Livewire"
Arr.toCssClasses(["p-4", { "font-bold": true, "text-red": false }])
// "p-4 font-bold"

Note that Arr.sort orders numbers numerically, not lexicographically.

Obj

Laravel's data_* helpers plus general object utilities. Dot paths support * wildcards.

Readingget · has · hasAny · exists Writingset · fill · add · forget · pull Shapeonly / pick · except / omit · keys · values · entries · fromEntries · count · invert · dot · undot Transformationmap / mapValues · mapKeys · mapWithKeys · filter · reject · merge · defaults · clone · freeze Comparisonequals · isEmpty · isNotEmpty · isObject

Obj.get({ users: [{ name: "Taylor" }] }, "users.*.name") // ["Taylor"]
Obj.set({}, "products.desk.price", 100) // { products: { desk: { price: 100 } } }
Obj.merge({ a: { x: 1 } }, { a: { y: 2 } }) // { a: { x: 1, y: 2 } }

Num

Locale-aware number formatting built on Intl.

Formattingformat · currency · percentage · fileSize · abbreviate · forHumans Wordsspell · spellOrdinal · ordinal Mathsclamp · pairs · trim · parseInt · parseFloat · isNumeric · round · random · sum · average · lerp · percentOf ConfigurationuseLocale · useCurrency · withLocale · withCurrency · defaultLocale · defaultCurrency

Num.currency(1000)                          // "$1,000.00"
Num.abbreviate(489_939)                     // "490K"
Num.forHumans(1_230_000, { precision: 2 })  // "1.23 million"
Num.spell(1234)                             // "one thousand two hundred thirty-four"
Num.ordinal(21)                             // "21st"

Num.withLocale("de-DE", () => Num.format(100000)) // "100.000"

Collection / collect()

A chainable collection over a JavaScript array. Transforming methods return a new collection; the methods Laravel mutates in place (push, pop, shift, put, pull, forget, splice, transform) mutate here too.

Accessall · toArray · toJson · count · get · has · first · last · firstWhere · sole · random · search

PredicatesisEmpty · isNotEmpty · contains · doesntContain · every · some

Transformationmap · flatMap · mapSpread · mapWithKeys · mapToGroups · transform · filter · reject · where · whereIn · whereNotIn · whereBetween · whereNotBetween · whereNull · whereNotNull

Shapecollapse · flatten · chunk · chunkWhile · sliding · split · splitIn · partition · pad

Ordering & slicingsort · sortDesc · sortBy · sortByDesc · reverse · shuffle · slice · take · takeWhile · takeUntil · skip · skipWhile · skipUntil · nth · forPage

Setsunique · duplicates · diff · intersect · merge · concat · zip · combine · crossJoin

Keyspluck · keyBy · groupBy · countBy · only · except · keys · values · flip

Aggregationsum · avg / average · min · max · median · mode · reduce · implode · join

Control floweach · eachSpread · tap · pipe · when · unless · whenEmpty · whenNotEmpty · dump · clone

Collections are iterable, so for...of and spreading work as expected.

collect(products)
  .where("price", ">", 100)
  .sortByDesc("price")
  .take(3)
  .pluck("name")

Collection.times(3, (i) => i * 2).all() // [2, 4, 6]
Collection.range(1, 5).sum()            // 15

Global helpers

import {
  blank, filled, value, dataGet, dataSet, dataFill, dataForget,
  head, last, tap, transform, withValue, throwIf, throwUnless,
  retry, once, optional, sleep, classBasename, collect, str,
} from "larax"
blank("   ")                              // true — but blank(0) is false
value(() => 42)                           // 42
dataGet(data, "products.*.name")          // wildcard reads
tap(user, (u) => console.log(u.id))       // returns user
throwUnless(user.isAdmin, "Forbidden")
await retry(3, fetchThing, 250)           // 3 attempts, 250ms apart
optional(maybeNull).name                  // undefined, never a TypeError

Migrating from 0.2.x

Two helpers gained Laravel's positional signatures. The old object-argument form still works, so existing code keeps running:

Num.clamp({ num: 5, min: 1, max: 3 }) // still supported
Num.clamp(5, 1, 3)                    // preferred

Obj.get({ obj: data, path: "a.b", daf: "x" }) // still supported
Obj.get(data, "a.b", "x")                     // preferred

Two behaviour changes are worth knowing about:

  • Str.contains now matches substrings, as Laravel does. It previously split the subject on spaces and compared whole words, so Str.contains("This is my name", "nam") returned false; it now returns true.
  • Obj.get no longer returns the fallback for falsy stored values. Obj.get({ count: 0 }, "count", 99) previously returned 99 and now correctly returns 0.

Configuration

Larax needs no configuration. Import the helpers you need and go — the build is side-effect free, so bundlers tree-shake anything you don't use.

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository.
  2. Create a new branch (feature/my-feature).
  3. Run the checks: pnpm typecheck && pnpm test && pnpm build.
  4. Add a changeset describing your change: pnpm changeset.
  5. Commit your changes (git commit -m 'Add some feature').
  6. Push to the branch (git push origin feature/my-feature).
  7. Create a Pull Request.

CI runs the same three checks on Node 22 and 24. Releases are automated: merging a changeset to master opens a "Version Packages" PR, and merging that PR publishes to npm.

Development requires Node 22.11+ (a floor set by @changesets/cli 3) and pnpm 11, which is pinned via packageManager.

License

This project is licensed under the MIT License.

Author

Developed by Abbas Roholamin.


Star the repository if you find it useful!