forked from vindecodex/counting-str
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
38 lines (38 loc) · 1.14 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"use strict";
exports.__esModule = true;
exports.countCharacters = exports.countSpaces = exports.countWords = exports.countingStr = void 0;
exports.countingStr = {
byWordsLength: 0,
bySpacesLength: 0,
countWords: function (inputString) {
return 0;
},
countSpaces: function (inputString) {
return 0;
}
};
function countWords(inputString) {
if (!inputString)
return 0;
var splitWords = inputString.split(" ");
return splitWords.length;
}
exports.countWords = countWords;
function countSpaces(inputString) {
if (!inputString)
return 0;
var splitWords = inputString.split(" ");
return splitWords.length - 1;
}
exports.countSpaces = countSpaces;
function countCharacters(inputString, options) {
if (!inputString)
return 0;
var inputCharacterSize = inputString.length;
var inputSpaceCharacterSize = inputString.split(" ").length - 1;
var inputCharacterSizeWithoutSpaces = inputCharacterSize - inputSpaceCharacterSize;
if (options.withSpaces)
return inputCharacterSize;
return inputCharacterSizeWithoutSpaces;
}
exports.countCharacters = countCharacters;