Project Goals
- Fluent
- Stringable
- Simplified
Tinkerable Demo
Laravel JS Str
"Laravel's Illuminate\Str & Illuminate\Stringify Including Str.of() In Javascript"
Installation
NPM
npm install --save-dev laravel-js-str
Yarn
yarn add laravel-js-str --save
CDN
Str
Documentation For Each String Method Points To Laravel. Javascript examples are below, Laravel docs will specify what each method specifically does. Replace Str::method() with Str.() when using this package
- Str.after
- Str.afterLast
- Str.ascii
- Str.before
- Str.beforeLast
- Str.between
- Str.contains
- Str.containsAll
- Str.finish
- Str.is
- Str.isAscii
- Str.isUuid
- Str.length
- Str.limit
- Str.lower
- Str.orderedUuid
- Str.plural
- Str.random
- Str.replaceArray
- Str.replaceFirst
- Str.replaceLast
- Str.singular
- Str.slug
- Str.start
- Str.substr
- Str.ucfirst
- Str.upper
- Str.uuid
- Str.words
const Str = ; let slice = Str;// ' my name'
const Str = ; let slice = Str;// 'Controller'
const Str = ; let slice = Str;// 'u'
const Str = ; let slice = Str;// 'This is '
const Str = ; let slice = Str;// 'This '
const Str = ; let slice = Str;// ' is my '
const Str = ; let converted = Str;// fooBar
const Str = ; let contains = Str;// true
const Str = ; let contains = Str;// true
const Str = ; let containsAll = Str;// true
const Str = ; let result = Str;// true
const Str = ; let result = Str;// true result = Str;// false
const Str = ; let adjusted = Str;// this/string/ adjusted = Str;// this/string/
const Str = ; let matches = Str;// true matches = Str; // false
isAscii is experimental, not confident it works in all scenarios
const Str = ; let isAscii = Str;// true isAscii = Str; // false
const Str = ; let isUuid = Str;// true isUuid = Str; // false
const Str = ; let converted = Str;// foo-bar
const Str = ; let length = Strlength'Laravel';// 7
const Str = ; let truncated = Str;// The quick brown fox...
const Str = ; let truncated = Str;// The quick brown fox (...)
const Str = ; let converted = Str;// laravel
const Str = ; let plural = Str;// cars plural = Str;// children
const Str = ; let plural = Str;// children plural = Str;// child
const Str = ; let random = Str;
const Str = ; let string = 'The event will take place between ? and ?';let replaced = Str;// The event will take place between 8:30 and 9:00
const Str = ; let replaced = Str;// a quick brown fox jumps over the lazy dog
const Str = ; let replaced = Str;// the quick brown fox jumps over a lazy dog
const Str = ; let singular = Str;// car singular = Str;// child
const Str = ; let slug = Str;// laravel-5-framework
const Str = ; let converted = Str;// foo_bar
const Str = ; let adjusted = Strstart'this/string' '/';// /this/string adjusted = Strstart'/this/string' '/';// /this/string
const Str = ; let result = Str
const Str = ; let converted = Str;// FooBar
const Str = ; let converted = Str;// Laravel
const Str = ; let converted = Strtitle'a nice title uses the correct case';// A Nice Title Uses The Correct Case
const Str = ; let string = Str;// Foo bar
const Str = ; let string = Str;// LARAVEL
const Str = ; return Str;
const Str = ; Str; // Perfectly balanced, as >>>
const Str = ; let slice = Str;// ' my name'
const Str = ; let slice = Str;// 'Controller'
const Str = ; let string = Str;// 'Taylor Otwell'
Experimental Method, not sure this works in all cases
const Str = ; let string = Str;// 'u'
const Str = ; let string = Str;// 'baz'
const Str = ; let string = Str;// 'baz'
const Str = ; let slice = Str;// 'This is '
const Str = ; let slice = Str;// 'This '
const Str = ; let converted = Str;// fooBar
const Str = ; let contains = Str;// true
const Str = ; let contains = Str
const Str = ; let containsAll = Str;// true
const Str = ; let string = Str;// '/foo/bar'
const Str = ; let string = Str;// '/foo'
const Str = ; let result = Str;// true
const Str = ; let result = Str;// true result = Str;// false
const Str = ; let result = Str;// true
const Str = ; let collection = Str;// collect(['foo', 'bar', 'baz'])
const Str = ; let adjusted = Str;// this/string/ adjusted = Str; // this/string/
const Str = ; let matches = Str;// true matches = Str; // false
isAscii is Experimental, not positive its correct in all cases
const Str = ; let result = Str;// true result = Str; // false
const Str = ; let result = Str;// true result = Str; // false
const Str = ; let result = Str;// false result = Str; // true
const Str = ; let converted = Str;// foo-bar
const Str = ; let length = Strlength;// 7
const Str = ; let truncated = Str;// The quick brown fox...
const Str = ; let truncated = Str;// The quick brown fox (...)
const Str = ; let result = Str;// 'laravel'
const Str = ; let string = Str;// 'Laravel ' string = Str; // 'Laravel/'
const Str = ; let result = Str;// 'bar' result = Str; // 'bar'
Match All Coming Soon
const { Str } = require('laravel-js-str');
let result = Str.of('bar foo bar').matchAll('/bar/');
// collect(['bar', 'bar'])
const { Str } = require('laravel-js-str');
let result = Str.of('bar fun bar fly').matchAll('/f(\w*)/');
// collect(['un', 'ly']);
const Str = ; let plural = Str;// cars plural = Str; // children
const Str = ; let plural = Str;// children plural = Str; // child
const Str = ; let string = Str;// Laravel Framework
const Str = ; let replaced = Str;// Laravel 7.x
const Str = ; let string = 'The event will take place between ? and ?';let replaced = Str;// The event will take place between 8:30 and 9:00
const Str = ; let replaced = Str;// a quick brown fox jumps over the lazy dog
const Str = ; let replaced = Str;// the quick brown fox jumps over a lazy dog
const Str = ; let replaced = Str; //'15015551000'
const Str = ; let string = Str;// ' Laravel' string = Str; // '/Laravel'
const Str = ; let singular = Str;// car singular = Str; // child
const Str = ; let slug = Str;// laravel-framework
const Str = ; let converted = Str;// foo_bar
const Str = ; let segments = Str;// collect(["one", "two", "three"])
const Str = ; let adjusted = Strstart'/';// /this/string adjusted = Strstart'/'; // /this/string
const Str = ; let result = Str;// true
const Str = ; let converted = Str;// FooBar
const Str = ; let string = Str;// Framework string = Str; // Frame
const Str = ; let converted = Strtitle;// A Nice Title Uses The Correct Case
const Str = ; let string = Str;// 'Laravel' string = Str; // 'Laravel'
const Str = ; let string = Str;// Foo bar
const Str = ; let adjusted = Str;// LARAVEL
const Str = ; let string = Str; // 'Laravel'
const Str = ; let string = Str;// Perfectly balanced, as >>>
Playground Examples
Curious, but not 100% on whether this is what you're looking for?
The most powerful method is Str.of('example'), allowing us to fluently chain Str methods together
Example
let Str = ; let home = 'https://planets.com';let title = 'hello mars, a cool world for you to visit, maybe?'; let article = Str start'/' ; let resource = home + article // resource value: // 'https://planets.com/mars-a-cool-world/'//// article value:// Stringable: { value: 'https://planets.com/mars-a-cool-world-to-visit', replace, before, after, etc... }//
Utilization
The most powerful method is Str.of('example'), allowing us to fluently chain Str methods together
Example
let Str = ; let home = 'https://planets.com';let title = 'hello mars, a cool world for you to visit, maybe?'; let article = Str start'/' ; let resource = home + article // resource value: // 'https://planets.com/mars-a-cool-world/'//// article value:// Stringable: { value: 'https://planets.com/mars-a-cool-world-to-visit', replace, before, after, etc... }//
Contribute
PRs are welcomed to this project. If you want to improve this package, add functionality or improve the docs please feel free to submit a PR.
Security Vulnerabilities
If you discover a security vulnerability within Clean Code Studio Packages Or Specifically within laravel-js-str, please send an e-mail to Zachary Horton via zak@cleancode.studio. All security vulnerabilities will be promptly addressed.
Change Log
Release 1.0.0
- Initial Release
Versioning
Semantic Versioning
Code Status | Stage | Rule | Example Version |
---|---|---|---|
First release | New Product | Start with 1.0.0 | 1.0.0 |
Backward compatible bug fixes | Patch Release | Increment the third digit | 1.0.1 |
Backward compatible new features | Minor Release | Increment the middle digit and reset last digit to zero | 1.1.0 |
Changes that break backward compatibility | Major Release | Increment the first digit and reset middle and last digits to zero | 2.0.0 |