laravel-js-helpers
v1.0.3
Published
Laravel helpers within javascript (data_get, data_set, data_fill, collect)
Downloads
46
Maintainers
Readme
Laravel JS Helpers
"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)
Installation
NPM
npm install --save-dev laravel-js-helpers
Yarn
yarn add laravel-js-helpers --save
CDN
<script src='https://unpkg.com/laravel-js-helpers@latest/build/index.min.js'></script>
Playground Examples
Curious, but not 100% on whether this is what you're looking for?
Utilization
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']
},
}
}
Contribute
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.
Security Vulnerabilities
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 [email protected]. All security vulnerabilities will be promptly addressed.
Change Log
Release 1.0.3
CDN
Tests
Change Log
Documentation
Travis Continuous Build Integration
Release 1.0.2
- data_get
- data_set
- data_fill
- transform
- value
- blank
- filled
- collect
Release 1.0.1
- Initial Simple Documentation Setup
Release 1.0.0
- Initial Setup
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|