The Helpers plugin provides helper functions for JavaScript's core objects. Some noteworthy items about this plugin:
MVC.Object.extend(dest, src) -> Object
Copies all properties from the source to the destination object.
MVC.Object.to_query_string(obj) -> String
Turns an object into its URL-encoded query string representation.
MVC.Object.to_query_string({one: 'two', two: 'three', object: {hello: 'world'}});
// 'one=two&two=three&object%5Bhello%5D=world'
String.capitalize() -> String
Capitalizes the first letter of a string and downcases all the others.
String.capitalize('yes');
// 'Yes'
String.include(substring) -> Boolean
Check if the string contains a substring.
String.include('JavaScript','Script');
// true
String.camelize() -> String
Converts a string separated by underscores into a camelCase equivalent.
String.camelize('one_two');
// 'oneTwo'
String.classize() -> String
Checks if the string ends with substring.
String.classize('one_two');
// 'oneTwo'
String.ends_with(substring) -> Boolean
Converts a string separated by underscores into a camelCase equivalent.
String.ends_with('JavaScript','ipt');
// true
String.strip() -> String
Strips all leading and trailing whitespace from a string.
String.camelize(' word ');
// 'word'
Array.from(iterable) -> Array
Clones an existing array or creates a new one from an array-like collection.
Array.from([1,2]);
// [1,2]
Array.include(iterable, checked_item) -> Boolean
Check if the array contains an item.
Array.include([1,2,3], 2);
// true
Function.bind(some_function,thisObj[, arg...]) -> Function
Wraps the function in another, locking its execution scope to an object specified by thisObj. Works the same as the PrototypeJS method, which is described in more detail in their documentation.
function(){
this.assert(true);
}.bind(this);
Function.params(some_function) -> Boolean
Returns the parameter names for the given function in an array.
Function.params(function( one, two ,three){ return 'yes'});
// ['one','two','three']