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 CHANGED
@@ -53,3 +53,4 @@ import { API } from 'tools-for-js'
53
53
  | 根据 key 获取对象值 | getValByKey |
54
54
  | 数组随机打乱 | shuffleArray |
55
55
  | 将路径中的反斜杠字符 \ 替换为斜杠 / | replacePath |
56
+ | 切割/获取文件名 | splitToFileName |
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() {
@@ -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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tools-for-js",
3
- "version": "1.2.7",
3
+ "version": "1.2.8",
4
4
  "description": "基于babel构建的javascript工具库",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {