Security update to Drupal 8.4.6
[yaffs-website] / node_modules / underscore.string / index.js
1 //  Underscore.string
2 //  (c) 2010 Esa-Matti Suuronen <esa-matti aet suuronen dot org>
3 //  Underscore.string is freely distributable under the terms of the MIT license.
4 //  Documentation: https://github.com/epeli/underscore.string
5 //  Some code is borrowed from MooTools and Alexandru Marasteanu.
6 //  Version '3.2.3'
7
8 'use strict';
9
10 function s(value) {
11   /* jshint validthis: true */
12   if (!(this instanceof s)) return new s(value);
13   this._wrapped = value;
14 }
15
16 s.VERSION = '3.2.3';
17
18 s.isBlank          = require('./isBlank');
19 s.stripTags        = require('./stripTags');
20 s.capitalize       = require('./capitalize');
21 s.decapitalize     = require('./decapitalize');
22 s.chop             = require('./chop');
23 s.trim             = require('./trim');
24 s.clean            = require('./clean');
25 s.cleanDiacritics  = require('./cleanDiacritics');
26 s.count            = require('./count');
27 s.chars            = require('./chars');
28 s.swapCase         = require('./swapCase');
29 s.escapeHTML       = require('./escapeHTML');
30 s.unescapeHTML     = require('./unescapeHTML');
31 s.splice           = require('./splice');
32 s.insert           = require('./insert');
33 s.replaceAll       = require('./replaceAll');
34 s.include          = require('./include');
35 s.join             = require('./join');
36 s.lines            = require('./lines');
37 s.dedent           = require('./dedent');
38 s.reverse          = require('./reverse');
39 s.startsWith       = require('./startsWith');
40 s.endsWith         = require('./endsWith');
41 s.pred             = require('./pred');
42 s.succ             = require('./succ');
43 s.titleize         = require('./titleize');
44 s.camelize         = require('./camelize');
45 s.underscored      = require('./underscored');
46 s.dasherize        = require('./dasherize');
47 s.classify         = require('./classify');
48 s.humanize         = require('./humanize');
49 s.ltrim            = require('./ltrim');
50 s.rtrim            = require('./rtrim');
51 s.truncate         = require('./truncate');
52 s.prune            = require('./prune');
53 s.words            = require('./words');
54 s.pad              = require('./pad');
55 s.lpad             = require('./lpad');
56 s.rpad             = require('./rpad');
57 s.lrpad            = require('./lrpad');
58 s.sprintf          = require('./sprintf');
59 s.vsprintf         = require('./vsprintf');
60 s.toNumber         = require('./toNumber');
61 s.numberFormat     = require('./numberFormat');
62 s.strRight         = require('./strRight');
63 s.strRightBack     = require('./strRightBack');
64 s.strLeft          = require('./strLeft');
65 s.strLeftBack      = require('./strLeftBack');
66 s.toSentence       = require('./toSentence');
67 s.toSentenceSerial = require('./toSentenceSerial');
68 s.slugify          = require('./slugify');
69 s.surround         = require('./surround');
70 s.quote            = require('./quote');
71 s.unquote          = require('./unquote');
72 s.repeat           = require('./repeat');
73 s.naturalCmp       = require('./naturalCmp');
74 s.levenshtein      = require('./levenshtein');
75 s.toBoolean        = require('./toBoolean');
76 s.exports          = require('./exports');
77 s.escapeRegExp     = require('./helper/escapeRegExp');
78 s.wrap             = require('./wrap');
79 s.map              = require('./map');
80
81 // Aliases
82 s.strip     = s.trim;
83 s.lstrip    = s.ltrim;
84 s.rstrip    = s.rtrim;
85 s.center    = s.lrpad;
86 s.rjust     = s.lpad;
87 s.ljust     = s.rpad;
88 s.contains  = s.include;
89 s.q         = s.quote;
90 s.toBool    = s.toBoolean;
91 s.camelcase = s.camelize;
92 s.mapChars  = s.map;
93
94
95 // Implement chaining
96 s.prototype = {
97   value: function value() {
98     return this._wrapped;
99   }
100 };
101
102 function fn2method(key, fn) {
103   if (typeof fn !== "function") return;
104   s.prototype[key] = function() {
105     var args = [this._wrapped].concat(Array.prototype.slice.call(arguments));
106     var res = fn.apply(null, args);
107     // if the result is non-string stop the chain and return the value
108     return typeof res === 'string' ? new s(res) : res;
109   };
110 }
111
112 // Copy functions to instance methods for chaining
113 for (var key in s) fn2method(key, s[key]);
114
115 fn2method("tap", function tap(string, fn) {
116   return fn(string);
117 });
118
119 function prototype2method(methodName) {
120   fn2method(methodName, function(context) {
121     var args = Array.prototype.slice.call(arguments, 1);
122     return String.prototype[methodName].apply(context, args);
123   });
124 }
125
126 var prototypeMethods = [
127     "toUpperCase",
128     "toLowerCase",
129     "split",
130     "replace",
131     "slice",
132     "substring",
133     "substr",
134     "concat"
135 ];
136
137 for (var method in prototypeMethods) prototype2method(prototypeMethods[method]);
138
139
140 module.exports = s;