tools-for-js 1.2.7 → 1.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/lib/index.js +6 -0
- package/lib/utils/string.js +14 -0
- package/package.json +1 -1
package/README.md
CHANGED
package/lib/index.js
CHANGED
|
@@ -177,6 +177,12 @@ Object.defineProperty(exports, "splitString", {
|
|
|
177
177
|
return _string.splitString;
|
|
178
178
|
}
|
|
179
179
|
});
|
|
180
|
+
Object.defineProperty(exports, "splitToFileName", {
|
|
181
|
+
enumerable: true,
|
|
182
|
+
get: function get() {
|
|
183
|
+
return _string.splitToFileName;
|
|
184
|
+
}
|
|
185
|
+
});
|
|
180
186
|
Object.defineProperty(exports, "summation", {
|
|
181
187
|
enumerable: true,
|
|
182
188
|
get: function get() {
|
package/lib/utils/string.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.getStrLength = exports.encode = exports.decode = exports.checkPwdStrength = void 0;
|
|
7
7
|
exports.replacePath = replacePath;
|
|
8
8
|
exports.splitString = splitString;
|
|
9
|
+
exports.splitToFileName = splitToFileName;
|
|
9
10
|
var _utf8_encode = function _utf8_encode(string) {
|
|
10
11
|
string = string.replace(/\r\n/g, '\n');
|
|
11
12
|
var utftext = '';
|
|
@@ -192,4 +193,17 @@ function splitString(str, num) {
|
|
|
192
193
|
*/
|
|
193
194
|
function replacePath(path) {
|
|
194
195
|
return path.replace(/\\/g, '/');
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/*******
|
|
199
|
+
* @description: 切割/获取文件名
|
|
200
|
+
* @author: 琴时
|
|
201
|
+
* @param {*} path
|
|
202
|
+
* @return {*}
|
|
203
|
+
*/
|
|
204
|
+
function splitToFileName(path) {
|
|
205
|
+
path = replacePath(path || '');
|
|
206
|
+
var lastIndex = path.lastIndexOf('/');
|
|
207
|
+
if (lastIndex === -1) return path;
|
|
208
|
+
return path.substring(lastIndex + 1);
|
|
195
209
|
}
|