Merge pull request #961 from friday/expose-defaults

Enable overriding defaults
This commit is contained in:
Sam Potts 2018-05-14 23:38:25 +10:00 committed by GitHub
commit 4a01027da0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View File

@ -55,6 +55,7 @@ class Plyr {
this.config = utils.extend(
{},
defaults,
Plyr.defaults,
options || {},
(() => {
try {
@ -1269,4 +1270,6 @@ class Plyr {
}
}
Plyr.defaults = utils.cloneDeep(defaults);
export default Plyr;

View File

@ -703,6 +703,11 @@ const utils = {
return array.filter((item, index) => array.indexOf(item) === index);
},
// Clone nested objects
cloneDeep(object) {
return JSON.parse(JSON.stringify(object));
},
// Get the closest value in an array
closest(array, value) {
if (!utils.is.array(array) || !array.length) {