Angular comes with jqLite, a tiny, API-compatible subset of jQuery. However, its
functionality is very limited and MacGyver extends jqLite to make sure MacGyver
components work properly.
Real jQuery will continue to take precedence over jqLite and all functions MacGyver extends.
MacGyver adds the following methods:
MacGyver comes with character code enum for easy reference and increase readability. With dependency injection, just inject "keys" to gain access.
util.pluralize("apple", 5) => "apples" util.pluralize("apple", 10, true) => "10 apples"
Converts first leter of the string to uppercase (Underscore string proxy)
util.capitalize("lowercase") => "Lowercase"
util.uncapitalize("UPPERCASE") => "uPPERCASE"
util.toCamelCase("a-string-with-dashes") => "aStringWithDashes"
util.toSnakeCase("just another string") => "just_another_string"
Convert all the keys in an object to camel case
util.toSnakeCase({'hello-world': 'test'}) => {'helloWorld': 'test'}
Convert all the keys in an object to snake case
util.toSnakeCase({'helloWorld': 'test'}) => {'hello_world': 'test'}
util.pyth(3, 4) => 5
util.degrees(Math.PI) => 180
util.radian(180) => Math.PI
Convert HEX color into RGB values
util.hex2rgb("#5331DE") => {r: 83, g: 49, b: 222}
Parse url and break it into different components
util.validateUrl("http://www.example.com/macgyver/episodes") => {domain: "com" name: "example" path: "/macgyver/episodes" port: undefined protocol: "http://" subdomain: "www" url: "http://www.example.com/macgyver/episodes"}
util.validateEmail("user@example.com") => true
util.getQueryString("http://www.example.com/macgyver?season=1&episode=3&time=12:23", "episode") => 3
util.parseUrlPath("http://www.example.com/macgyver?season=1&episode=3&time=12:23") => {fullPath: "http://www.example.com/macgyver?season=1&episode=3&time=12:23", path: "http://www.example.com", pathComponents: [ "http:", "", "www.example.com", "macgyver" ], verb: "macgyver", queries: { season: "1", episode: "3", time: "12:23" } }