"Laravel Helper Methods In Javascript"
- data_get, data_set, and data_fill for dot notation -- wildcards ("*") available -- deep object access = @See Laravel data_set, data_get, & data_fill docs (Powerful functions we've got in js now)
- @See Laravel Helper Functions
- @See Collect.js Collections (Utilized for our "collect" function)
npm install --save-dev laravel-js-helpers
yarn add laravel-js-helpers --save
<script src='https://unpkg.com/laravel-js-helpers@latest/build/index.min.js'></script>
Curious, but not 100% on whether this is what you're looking for?
Data Get
Data Get Simple
data_get(family, 'family.members.brother.name');
Data Get Output
"drew"
Data Get Wildcard("*")
data_get(family, 'family.members.*.age');
Data Get Wildcard Output
[17, 25, 'thats not polite', 50];
Data Set
Data Set Simple
data_set(family, 'members.brother.age', 21);
data_set(family, 'members.brother.name', 'Everett');
Data Set Wildcard("*")
data_set(family, 'members.*.last_name', 'Smith');
Data Set Output
{
members: {
brother: {
age: 21,
name: 'Everett',
last_name: 'Smith',
hobbies: ['football', '"chillin"', 'video games']
},
sister: {
age: 25,
name: 'ash',
last_name: 'Smith',
hobbies: ['mothering babies', 'fitness', 'nutrition', '']
},
mother: {
name: 'amy',
last_name: 'Smith',
age: 'thats not polite',
hobbies: ['cleaning', 'nursing', 'hiking']
},
father: {
age: 50,
name: 'jon',
last_name: 'Smith',
hobbies: ['reading', 'sports', 'talking for seemingly ever', 'providing useful insights']
},
}
}
Data Fill
Data Fill Simple
data_fill(family, 'members.brother.age', 23); // wont do anything
data_fill(family, 'members.brother.name', 'Zak'); // wont do anything
data_fill(family, 'members.brother.birthday', 'April 22'); // will do something
Data Fill Wildcard("*")
data_fill(family, 'members.*.last_name', 'Horton'); // wont do anything
data_fill(family, 'members.*.nickname', 'Hortonion'); // will do something
Data Fill Output
{
members: {
brother: {
age: 21,
name: 'Everett',
last_name: 'Smith',
birthday: 'April 22',
nickname: 'Hortonion',
hobbies: ['football', '"chillin"', 'video games']
},
sister: {
age: 25,
name: 'ash',
last_name: 'Smith',
nickname: 'Hortonion',
hobbies: ['mothering babies', 'fitness', 'nutrition', '']
},
mother: {
name: 'amy',
last_name: 'Smith',
nickname: 'Hortonion',
age: 'thats not polite',
hobbies: ['cleaning', 'nursing', 'hiking']
},
father: {
age: 50,
name: 'jon',
last_name: 'Smith',
nickname: 'Hortonion',
hobbies: ['reading', 'sports', 'talking for seemingly ever', 'providing useful insights']
},
}
}
PRs are welcomed to this project. If you want to improve the laravel-js-helpers library, add functionality or improve the docs please feel free to submit a PR.
If you discover a security vulnerability within Clean Code Studio Packages Or Specifically within laravel-js-helpers, please send an e-mail to Zachary Horton via zak@cleancode.studio. All security vulnerabilities will be promptly addressed.
- CDN
- Tests
- Change Log
- Documentation
- Travis Continuous Build Integration
- data_get
- data_set
- data_fill
- transform
- value
- blank
- filled
- collect
- Initial Simple Documentation Setup
- Initial Setup
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 |