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

@balboacodes/laravel-helpers

v0.13.0

Published

A TypeScript port of Laravel's helpers

Readme

Laravel Helpers

publish

About

This package is a TypeScript port of many Laravel helpers. It aims to remain as faithful as possible to the originals.

Installation

npm i @balboacodes/laravel-helpers

Usage

Because there are so many helpers, the usage for all of them cannot be shown here. To see if the function you need is available, you can do a search of the provided type definition file or the source here on GitHub. Here's a sampling of some of the functionality provided:

Arrays and Objects

import { Arr } from '@balboacodes/laravel-helpers';

const array = Arr.collapse([
    [1, 2, 3],
    [4, 5, 6],
    [7, 8, 9],
]);

// [1, 2, 3, 4, 5, 6, 7, 8, 9]

const object = {'products': {'desk': {'price': 100}}};

const flattened = Arr.dot(object);

// {'products.desk.price': 100}

Collections

The Collection class provides a fluent, convenient wrapper for working with arrays or objects of data.

import { collect } from '@balboacodes/laravel-helpers';

const collection = collect([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);

const chunks = collection.chunk(4).all();

// [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10]]

Numbers

import { NumberFormatter } from '@balboacodes/laravel-helpers';

const number = NumberFormatter.abbreviate(1000);

// 1K

Strings

import { Str, str } from '@balboacodes/laravel-helpers';

const slice = Str.after('This is my name', 'This is ');

// 'my name'

const slice = Str.of('This is my name').after('This is ').title();

// 'My Name'

const slice = str('This is my name').after('This is ').title();

// 'My Name'

Miscellaneous

import { blank, throw_if } from '@balboacodes/laravel-helpers';

blank('');
blank('   ');
blank(null);
blank(collect());

// true

blank(0);
blank(true);
blank(false);

// false

throw_if(true, () => new Error('test');

// throws

throw_if(false, new Error());

// doesn't throw

Other Utilities

Benchmarking

Utilize the Benchmark class to measure the number of milliseconds it takes for the given functions to complete.

import { Benchmark } from '@balboacodes/laravel-helpers';

const benchmark = Benchmark.measure(() => /* some operation */, 10);

// 0.5 ms

const benchmarks = Benchmark.measure({
    'Scenario 1': () => /* some operation */,
    'Scenario 2': () => /* some operation */,
});

// { 'Scenario 1': 0.5 ms, 'Scenario 2': 20.0 ms }

Lottery

The Lottery class may be used to execute callbacks based on a set of given odds.

import { Lottery } from '@balboacodes/laravel-helpers';

Lottery.odds(1, 20)
    .winner(() => user.won())
    .loser(() => user.lost())
    .choose();

Pipeline

The Pipeline class provides a convenient way to "pipe" a given input through a series of object instances or functions, giving each the opportunity to inspect or modify the input and invoke the next callable in the pipeline.

import { Pipeline } from '@balboacodes/laravel-helpers';

const result = new Pipeline()
    .send(user)
    .through([
        (user: User, next: Closure) => {
            // ...

            return next(user);
        },
        (user: User, next: Closure) => {
            // ...

            return next(user);
        },
    ])
    .then((user: User) => user);

Timebox

The Timebox class ensures that the given callback always takes a fixed amount of time to execute, even if its actual execution completes sooner.

import { Timebox } from '@balboacodes/laravel-helpers';

(new Timebox).call((timebox) => {
    // ...
}, 10);

Documentation

The documentaion for all of the helpers can be found on Laravel's documentation pages. All you have to do is convert the syntax to JS. Here are the relevant pages to look at:

Related

If you like this package, be sure to check out our other packages.