Skip to content

Commit 1917b28

Browse files
committed
3.3.0
1 parent d61b58f commit 1917b28

File tree

7 files changed

+84
-10
lines changed

7 files changed

+84
-10
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
3.3.0 / 2015-06-15
2+
---------------------
3+
- added `splitRight` and `splitLeft` method [#153](https://github.com/jprichardson/string.js/pull/153)
4+
15
3.2.1 / 2015-06-13
26
---------------------
37
- add missing minified version

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "string",
3-
"version": "3.2.1",
3+
"version": "3.3.0",
44
"description": "string contains methods that aren't included in the vanilla JavaScript string such as escaping HTML, decoding HTML entities, stripping tags, etc.",
55
"keywords": [
66
"string",

component.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "string.js",
3-
"version": "3.2.1",
3+
"version": "3.3.0",
44
"description": "string contains methods that aren't included in the vanilla JavaScript string such as escaping HTML, decoding HTML entities, stripping tags, etc.",
55
"repo": "jprichardson/string.js",
66
"keywords": [

dist/string.js

Lines changed: 75 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,76 @@ function count(self, substr) {
1313

1414
module.exports = count
1515
},{}],2:[function(_dereq_,module,exports){
16+
function splitLeft(self, sep, maxSplit, limit) {
17+
18+
if (typeof maxSplit === 'undefined') {
19+
var maxSplit = -1;
20+
}
21+
22+
var splitResult = self.split(sep);
23+
var splitPart1 = splitResult.slice(0, maxSplit);
24+
var splitPart2 = splitResult.slice(maxSplit);
25+
26+
if (splitPart2.length === 0) {
27+
splitResult = splitPart1;
28+
} else {
29+
splitResult = splitPart1.concat(splitPart2.join(sep));
30+
}
31+
32+
if (typeof limit === 'undefined') {
33+
return splitResult;
34+
} else if (limit < 0) {
35+
return splitResult.slice(limit);
36+
} else {
37+
return splitResult.slice(0, limit);
38+
}
39+
40+
}
41+
42+
module.exports = splitLeft;
43+
44+
},{}],3:[function(_dereq_,module,exports){
45+
function splitRight(self, sep, maxSplit, limit) {
46+
47+
if (typeof maxSplit === 'undefined') {
48+
var maxSplit = -1;
49+
}
50+
if (typeof limit === 'undefined') {
51+
var limit = 0;
52+
}
53+
54+
var splitResult = [self];
55+
56+
for (var i = self.length-1; i >= 0; i--) {
57+
58+
if (
59+
splitResult[0].slice(i).indexOf(sep) === 0 &&
60+
(splitResult.length <= maxSplit || maxSplit === -1)
61+
) {
62+
splitResult.splice(1, 0, splitResult[0].slice(i+sep.length)); // insert
63+
splitResult[0] = splitResult[0].slice(0, i)
64+
}
65+
}
66+
67+
if (limit >= 0) {
68+
return splitResult.slice(-limit);
69+
} else {
70+
return splitResult.slice(0, -limit);
71+
}
72+
73+
}
74+
75+
module.exports = splitRight;
76+
77+
},{}],4:[function(_dereq_,module,exports){
1678
/*
1779
string.js - Copyright (C) 2012-2014, JP Richardson <[email protected]>
1880
*/
1981

2082
!(function() {
2183
"use strict";
2284

23-
var VERSION = '3.2.1';
85+
var VERSION = '3.3.0';
2486

2587
var ENTITIES = {};
2688

@@ -362,6 +424,14 @@ string.js - Copyright (C) 2012-2014, JP Richardson <[email protected]>
362424
return new this.constructor(s);
363425
},
364426

427+
splitLeft: function(sep, maxSplit, limit) {
428+
return _dereq_('./_splitLeft')(this.s, sep, maxSplit, limit)
429+
},
430+
431+
splitRight: function(sep, maxSplit, limit) {
432+
return _dereq_('./_splitRight')(this.s, sep, maxSplit, limit)
433+
},
434+
365435
strip: function() {
366436
var ss = this.s;
367437
for(var i= 0, n=arguments.length; i<n; i++) {
@@ -466,11 +536,11 @@ string.js - Copyright (C) 2012-2014, JP Richardson <[email protected]>
466536
times: function(n) {
467537
return new this.constructor(new Array(n + 1).join(this.s));
468538
},
469-
539+
470540
titleCase: function() {
471541
var s = this.s;
472542
if (s) {
473-
s = s.replace(/(^[a-z]| [a-z]|-[a-z]|_[a-z])/g,
543+
s = s.replace(/(^[a-z]| [a-z]|-[a-z]|_[a-z])/g,
474544
function($1){
475545
return $1.toUpperCase();
476546
}
@@ -1109,6 +1179,6 @@ string.js - Copyright (C) 2012-2014, JP Richardson <[email protected]>
11091179

11101180
}).call(this);
11111181

1112-
},{"./_count":1}]},{},[2])
1113-
(2)
1182+
},{"./_count":1,"./_splitLeft":2,"./_splitRight":3}]},{},[4])
1183+
(4)
11141184
});

dist/string.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/string.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ string.js - Copyright (C) 2012-2014, JP Richardson <[email protected]>
55
!(function() {
66
"use strict";
77

8-
var VERSION = '3.2.1';
8+
var VERSION = '3.3.0';
99

1010
var ENTITIES = {};
1111

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "string",
3-
"version": "3.2.1",
3+
"version": "3.3.0",
44
"description": "string contains methods that aren't included in the vanilla JavaScript string such as escaping html, decoding html entities, stripping tags, etc.",
55
"homepage": "http://stringjs.com",
66
"repository": {

0 commit comments

Comments
 (0)