We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a96f140 commit ad867deCopy full SHA for ad867de
lib/_count.js
@@ -0,0 +1,13 @@
1
+function count(self, substr) {
2
+ var count = 0
3
+ var pos = self.indexOf(substr)
4
+
5
+ while (pos >= 0) {
6
+ count += 1
7
+ pos = self.indexOf(substr, pos + 1)
8
+ }
9
10
+ return count
11
+}
12
13
+module.exports = count
lib/string.js
@@ -121,15 +121,7 @@ string.js - Copyright (C) 2012-2014, JP Richardson <[email protected]>
121
},
122
123
count: function(ss) {
124
- var count = 0
125
- , pos = this.s.indexOf(ss)
126
-
127
- while (pos >= 0) {
128
- count += 1
129
- pos = this.s.indexOf(ss, pos + 1)
130
- }
131
132
- return count
+ return require('./_count')(this.s, ss)
133
134
135
//#modified from https://github.com/epeli/underscore.string
0 commit comments