String and Array Helpers for JavaScript

String and Array Helpers for JavaScript

Grafite Helpers is a collection of JavaScript string and array helpers for Laravel developers by Matt Lantz. These helpers are similar to the PHP helpers Laravel provides; however if you’re primarily a frontend developer, I still think you’ll appreciate them.

Here’s a few examples of the string helpers in action:

"This is my name".explode()
// ["This", "is", "my", "name"]

"This is my name".after("This is")
// ' my name'

"This is my name".beforeLast("my name");
// 'This is '

"I love watching movies".slug();
// "i-love-watching-movies"

And here’s a few array helper examples:

["Nissan", "BMW", "Ferrari"].implode();
// "Nissan BMW Ferrari"

["Nissan", "BMW", "Ferrari"].first();
// "Nissan"

["Nissan", "BMW", "Ferrari"].last();
// "Ferrari"

["Nissan", "BMW", "Ferrari"].remove("BMW");
// ["Nissan", "Ferrari"]

This package is available as @grafite/helpers in the NPM registry, and you can install it in your project with the following:

npm install @grafite/helpers

You can then import it in your project:

import '@grafite/helpers'

Check out the Helpers documentation for details of all the supported helpers. You can view the source code on GitHub at GrafiteInc/Helpers.


Filed in: News


Newsletter

Join the weekly newsletter and never miss out on new tips, tutorials, and more.

Laravel News Partners

Laravel Jobs

Laravel Developer
San Jose, CA - Must Be Local
X3 Builders
Experienced PHP Developer
Wilmington, NC
Queensboro Shirt Company
Senior Laravel developer
Netherlands, Rotterdam
Pionect
Senior Laravel Engineer
Remote okay (must already live in USA)
Hawthorne Effect
Senior Software Engineer (Remote - Contract)
Remote
Koodi Systems
PHP Developer
Pittsburgh / Remote
Sequoia Waste Solutions
Software Developer
Eindhoven
Simac IDS