Skip to content

Instantly share code, notes, and snippets.

@mtio
Created July 15, 2016 21:39
Show Gist options
  • Select an option

  • Save mtio/4d56aec9872376bc287c73ce93a8b5eb to your computer and use it in GitHub Desktop.

Select an option

Save mtio/4d56aec9872376bc287c73ce93a8b5eb to your computer and use it in GitHub Desktop.
Handy mixins for any Vuejs file
module.exports = {
filters: {
'format_kebab_case' : function(str) {
var x = str.split('_');
x.forEach(function(el, i) {
x[i] = this.replaceAt(el, 0, el.charAt(0).toUpperCase())
}, this);
return x.join(' ');
}
},
methods: {
isObject: function (object) {
return object !== null && typeof object === 'object';
},
objectSize: function (object) {
return Object.keys(object).length;
},
isArray: function (obj) {
return Array.isArray(obj);
},
getKeys: function (obj) {
return Object.keys(obj);
},
replaceAt: function(string, index, character) {
return string.substr(0, index) + character + string.substr(index+character.length);
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment