UNPKG

1.16 kBJavaScriptView Raw
1/**
2 * Extensions to the standard type prototypes.
3 *
4 * Written By:
5 * Matthew Knox
6 *
7 * License:
8 * MIT License. All code unless otherwise specified is
9 * Copyright (c) Matthew Knox and Contributors 2015.
10 */
11'use strict';
12
13var path = require('path');
14require('babel-register')({
15 plugins: [
16 path.join(__dirname, 'require.js')
17 ]
18});
19require('babel-polyfill');
20
21// string.toProperCase
22if (typeof String.prototype.toProperCase !== 'function') {
23 String.prototype.toProperCase = function () {
24 return this.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
25 };
26}
27
28// string.contains
29if (typeof String.prototype.contains !== 'function') {
30 String.prototype.contains = function(str) {
31 return this.indexOf(str) !== -1;
32 };
33}
34
35// string.capitaliseFirst
36if (typeof String.prototype.capitiliseFirst !== 'function') {
37 String.prototype.capitiliseFirst = function () {
38 if (this.length >= 2) {
39 return this[0].toUpperCase() + this.substring(1);
40 }
41 return this;
42 };
43}