@daysnap/utils 0.0.6 → 0.0.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.
Files changed (99) hide show
  1. package/es/base64ToBlob.js +0 -29
  2. package/es/blobToBase64.js +0 -3
  3. package/es/compareVersion.js +0 -1
  4. package/es/createHexColorByHash.js +0 -5
  5. package/es/downloadFile.js +0 -7
  6. package/es/filterBankCardNo.js +0 -5
  7. package/es/filterEmoji.js +0 -6
  8. package/es/filterIdCard.js +0 -2
  9. package/es/filterName.js +0 -3
  10. package/es/filterPhone.js +0 -2
  11. package/es/formatAmount.js +0 -6
  12. package/es/formatDate.js +0 -4
  13. package/es/getBlobByUrl.js +0 -4
  14. package/es/getImageInfo.js +0 -3
  15. package/es/getVideoInfo.js +0 -3
  16. package/es/isAndroid.js +0 -2
  17. package/es/isEmail.js +0 -2
  18. package/es/isIOS.js +0 -2
  19. package/es/isIdCard.js +0 -2
  20. package/es/isMobile.js +0 -2
  21. package/es/isObject.js +0 -2
  22. package/es/isPhone.js +0 -2
  23. package/es/isPromise.js +1 -4
  24. package/es/isRegExp.js +0 -4
  25. package/es/omit.js +0 -2
  26. package/es/parsePath.js +0 -3
  27. package/es/pick.js +0 -3
  28. package/es/replaceCrlf.js +0 -3
  29. package/lib/base64ToBlob.js +2 -60
  30. package/lib/blobToBase64.js +0 -4
  31. package/lib/compareVersion.js +3 -5
  32. package/lib/createHexColorByHash.js +0 -8
  33. package/lib/downloadFile.js +0 -12
  34. package/lib/filterBankCardNo.js +0 -8
  35. package/lib/filterEmoji.js +0 -10
  36. package/lib/filterIdCard.js +0 -2
  37. package/lib/filterName.js +0 -4
  38. package/lib/filterPhone.js +0 -2
  39. package/lib/formatAmount.js +0 -10
  40. package/lib/formatDate.js +0 -8
  41. package/lib/getBlobByUrl.js +0 -6
  42. package/lib/getImageInfo.js +0 -4
  43. package/lib/getVideoInfo.js +0 -4
  44. package/lib/index.js +0 -6
  45. package/lib/isAndroid.js +0 -2
  46. package/lib/isEmail.js +0 -2
  47. package/lib/isIOS.js +0 -2
  48. package/lib/isIdCard.js +0 -2
  49. package/lib/isMobile.js +0 -2
  50. package/lib/isObject.js +0 -2
  51. package/lib/isPhone.js +0 -2
  52. package/lib/isPromise.js +1 -5
  53. package/lib/isRegExp.js +0 -6
  54. package/lib/omit.js +2 -6
  55. package/lib/parsePath.js +0 -4
  56. package/lib/pick.js +0 -4
  57. package/lib/replaceCrlf.js +0 -4
  58. package/lib/storage/factory.js +2 -2
  59. package/package.json +13 -24
  60. package/dist/base64ToBlob.d.ts +0 -4
  61. package/dist/blobToBase64.d.ts +0 -4
  62. package/dist/compareVersion.d.ts +0 -7
  63. package/dist/compressImage.d.ts +0 -4
  64. package/dist/createHexColorByHash.d.ts +0 -4
  65. package/dist/downloadFile.d.ts +0 -6
  66. package/dist/filterBankCardNo.d.ts +0 -4
  67. package/dist/filterEmoji.d.ts +0 -4
  68. package/dist/filterIdCard.d.ts +0 -4
  69. package/dist/filterName.d.ts +0 -4
  70. package/dist/filterPhone.d.ts +0 -6
  71. package/dist/formatAmount.d.ts +0 -4
  72. package/dist/formatDate.d.ts +0 -4
  73. package/dist/getBlobByUrl.d.ts +0 -4
  74. package/dist/getImageInfo.d.ts +0 -4
  75. package/dist/getVideoInfo.d.ts +0 -4
  76. package/dist/index.d.ts +0 -38
  77. package/dist/index.js +0 -604
  78. package/dist/isAndroid.d.ts +0 -4
  79. package/dist/isEmail.d.ts +0 -4
  80. package/dist/isEmpty.d.ts +0 -4
  81. package/dist/isFunction.d.ts +0 -4
  82. package/dist/isIOS.d.ts +0 -4
  83. package/dist/isIdCard.d.ts +0 -4
  84. package/dist/isMobile.d.ts +0 -4
  85. package/dist/isNull.d.ts +0 -4
  86. package/dist/isObject.d.ts +0 -4
  87. package/dist/isPhone.d.ts +0 -4
  88. package/dist/isPromise.d.ts +0 -4
  89. package/dist/isRegExp.d.ts +0 -4
  90. package/dist/isString.d.ts +0 -4
  91. package/dist/isUndefined.d.ts +0 -4
  92. package/dist/omit.d.ts +0 -4
  93. package/dist/parseError.d.ts +0 -4
  94. package/dist/parsePath.d.ts +0 -4
  95. package/dist/pick.d.ts +0 -4
  96. package/dist/replaceCrlf.d.ts +0 -4
  97. package/dist/reserve.d.ts +0 -7
  98. package/dist/storage/factory.d.ts +0 -13
  99. package/dist/storage/index.d.ts +0 -26
package/lib/isPromise.js CHANGED
@@ -5,13 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.isPromise = isPromise;
7
7
 
8
- require("core-js/modules/es.object.to-string.js");
9
-
10
- require("core-js/modules/es.promise.js");
11
-
12
8
  /**
13
9
  * 校验是否是 promise
14
10
  */
15
11
  function isPromise(val) {
16
- return val instanceof Promise || !!val.then || !!val.catch;
12
+ return val instanceof Promise || !!val.then || !!val["catch"];
17
13
  }
package/lib/isRegExp.js CHANGED
@@ -5,12 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.isRegExp = isRegExp;
7
7
 
8
- require("core-js/modules/es.regexp.constructor.js");
9
-
10
- require("core-js/modules/es.regexp.exec.js");
11
-
12
- require("core-js/modules/es.regexp.to-string.js");
13
-
14
8
  /**
15
9
  * 校验是否是正则表达式
16
10
  */
package/lib/omit.js CHANGED
@@ -1,16 +1,12 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.omit = omit;
9
9
 
10
- require("core-js/modules/es.object.to-string.js");
11
-
12
- require("core-js/modules/web.dom-collections.for-each.js");
13
-
14
10
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
15
11
 
16
12
  /**
@@ -18,7 +14,7 @@ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/obje
18
14
  */
19
15
  function omit(obj) {
20
16
  var fields = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
21
- var clone = (0, _objectSpread2.default)({}, obj);
17
+ var clone = (0, _objectSpread2["default"])({}, obj);
22
18
  fields.forEach(function (key) {
23
19
  delete clone[key];
24
20
  });
package/lib/parsePath.js CHANGED
@@ -5,10 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.parsePath = parsePath;
7
7
 
8
- require("core-js/modules/es.object.to-string.js");
9
-
10
- require("core-js/modules/web.dom-collections.for-each.js");
11
-
12
8
  /**
13
9
  * 根据路径解析值
14
10
  */
package/lib/pick.js CHANGED
@@ -5,10 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.pick = pick;
7
7
 
8
- require("core-js/modules/es.object.to-string.js");
9
-
10
- require("core-js/modules/web.dom-collections.for-each.js");
11
-
12
8
  /**
13
9
  * 挑选对象里的某些属性,新对象返回
14
10
  */
@@ -5,10 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.replaceCrlf = replaceCrlf;
7
7
 
8
- require("core-js/modules/es.regexp.exec.js");
9
-
10
- require("core-js/modules/es.string.replace.js");
11
-
12
8
  /**
13
9
  * 替换字符串里面的回车换行
14
10
  */
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
4
4
 
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
@@ -38,7 +38,7 @@ function factory(type) {
38
38
  var _updateItem = function updateItem(key, val) {
39
39
  var prev = _getItem(key);
40
40
 
41
- return _setItem(key, (0, _objectSpread2.default)((0, _objectSpread2.default)({}, prev), val));
41
+ return _setItem(key, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, prev), val));
42
42
  }; // 清除
43
43
 
44
44
 
package/package.json CHANGED
@@ -1,14 +1,21 @@
1
1
  {
2
2
  "name": "@daysnap/utils",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "description": "通用的工具库",
5
+ "type": "module",
5
6
  "main": "lib/index.js",
6
7
  "module": "es/index.js",
7
8
  "typings": "lib/index.d.ts",
8
- "browser": "dist/index.js",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./lib/index.d.ts",
12
+ "require": "./lib/index.js",
13
+ "import": "./es/index.js",
14
+ "default": "./lib/index.js"
15
+ },
16
+ "./package.json": "./package.json"
17
+ },
9
18
  "scripts": {
10
- "docs": "typedoc --tsconfig ./tsconfig.json",
11
- "rollup": "rollup -c",
12
19
  "ts-node": "npx ts-node --project ./tsconfig.json ./src/filename.ts",
13
20
  "gen": "plop --plopfile ./scripts/gen.js --force",
14
21
  "del": "plop --plopfile ./scripts/del.js --force",
@@ -31,7 +38,6 @@
31
38
  "tool"
32
39
  ],
33
40
  "files": [
34
- "dist",
35
41
  "lib",
36
42
  "es"
37
43
  ],
@@ -42,16 +48,8 @@
42
48
  },
43
49
  "homepage": "https://github.com/daysnap/utils#readme",
44
50
  "devDependencies": {
45
- "@babel/core": "^7.19.3",
46
- "@babel/plugin-transform-runtime": "^7.19.1",
47
- "@babel/preset-env": "^7.19.4",
48
- "@babel/preset-typescript": "^7.18.6",
49
51
  "@commitlint/cli": "^16.2.1",
50
52
  "@commitlint/config-conventional": "^16.2.1",
51
- "@rollup/plugin-babel": "^6.0.0",
52
- "@rollup/plugin-commonjs": "^23.0.0",
53
- "@rollup/plugin-node-resolve": "^15.0.0",
54
- "@rollup/plugin-typescript": "^9.0.1",
55
53
  "@typescript-eslint/eslint-plugin": "^5.40.0",
56
54
  "@typescript-eslint/parser": "^5.40.0",
57
55
  "commitizen": "^4.2.4",
@@ -66,11 +64,7 @@
66
64
  "plop": "^3.1.1",
67
65
  "prettier": "^2.7.1",
68
66
  "rimraf": "^3.0.2",
69
- "rollup": "^2.67.0",
70
- "rollup-plugin-babel": "^4.4.0",
71
- "rollup-plugin-terser": "^7.0.2",
72
67
  "ts-node": "^10.9.1",
73
- "typedoc": "^0.23.17",
74
68
  "typescript": "^4.8.4"
75
69
  },
76
70
  "publishConfig": {
@@ -84,11 +78,6 @@
84
78
  "*.{js,ts}": "eslint --fix"
85
79
  },
86
80
  "dependencies": {
87
- "@babel/runtime": "^7.19.4",
88
- "core-js": "^3.25.5"
89
- },
90
- "browserslist": [
91
- "> 1%",
92
- "last 2 versions"
93
- ]
81
+ "@babel/runtime": "^7.19.4"
82
+ }
94
83
  }
@@ -1,4 +0,0 @@
1
- /**
2
- * base64 转 blob
3
- */
4
- export declare function base64ToBlob(base64: string, contentType?: string): Blob;
@@ -1,4 +0,0 @@
1
- /**
2
- * blob 转 base64
3
- */
4
- export declare function blobToBase64(blob: Blob): Promise<string | ArrayBuffer>;
@@ -1,7 +0,0 @@
1
- /**
2
- * 比对版本
3
- * -1 => V < v
4
- * 0 => V === v
5
- * 1 => V > v
6
- */
7
- export declare function compareVersion(V: string, v: string): number;
@@ -1,4 +0,0 @@
1
- /**
2
- * 压缩图片
3
- */
4
- export declare function compressImage(image: CanvasImageSource): HTMLCanvasElement;
@@ -1,4 +0,0 @@
1
- /**
2
- * 根据字符串hash值生成颜色值
3
- */
4
- export declare const colorGenByHash: (str: string) => string;
@@ -1,6 +0,0 @@
1
- /**
2
- * 通过 a 标签下载文件
3
- */
4
- export declare function downloadFile(data: string | Blob | MediaSource, options?: {
5
- fileName?: string;
6
- }): void;
@@ -1,4 +0,0 @@
1
- /**
2
- * 过滤银行卡号
3
- */
4
- export declare function filterBankCardNo(val: string): string;
@@ -1,4 +0,0 @@
1
- /**
2
- * 过滤emoji
3
- */
4
- export declare function filterEmoji(val: string): string;
@@ -1,4 +0,0 @@
1
- /**
2
- * 身份证号码加 *
3
- */
4
- export declare function filterIdCard(val: string): string;
@@ -1,4 +0,0 @@
1
- /**
2
- * 过滤姓名
3
- */
4
- export declare function filterName(val: string): string;
@@ -1,6 +0,0 @@
1
- /**
2
- * 手机号加 *
3
- * filterPhone('13177778888') => 131****8888
4
- * filterPhone('13177778888', ' ') => 131 **** 8888
5
- */
6
- export declare function filterPhone(val: string, sep?: string): string;
@@ -1,4 +0,0 @@
1
- /**
2
- * 格式化金额,默认元
3
- */
4
- export declare function formatAmount(s: string, radix?: number): string;
@@ -1,4 +0,0 @@
1
- /**
2
- * 格式化日期
3
- */
4
- export declare function formatDate(val: string | Date | number, fmt?: string): string;
@@ -1,4 +0,0 @@
1
- /**
2
- * 根据在线 url 返回 blob
3
- */
4
- export declare function getBlobByUrl(url: string): Promise<Blob>;
@@ -1,4 +0,0 @@
1
- /**
2
- * 获取图片信息
3
- */
4
- export declare function getImageInfo(src: string): Promise<HTMLImageElement>;
@@ -1,4 +0,0 @@
1
- /**
2
- * 获取 video 信息
3
- */
4
- export declare function getVideoInfo(src: string): Promise<HTMLVideoElement>;
package/dist/index.d.ts DELETED
@@ -1,38 +0,0 @@
1
- export declare const version = "0.0.3";
2
- export * from './base64ToBlob';
3
- export * from './blobToBase64';
4
- export * from './compareVersion';
5
- export * from './compressImage';
6
- export * from './createHexColorByHash';
7
- export * from './downloadFile';
8
- export * from './filterBankCardNo';
9
- export * from './filterEmoji';
10
- export * from './filterIdCard';
11
- export * from './filterName';
12
- export * from './filterPhone';
13
- export * from './formatAmount';
14
- export * from './formatDate';
15
- export * from './getBlobByUrl';
16
- export * from './getImageInfo';
17
- export * from './getVideoInfo';
18
- export * from './isAndroid';
19
- export * from './isEmail';
20
- export * from './isEmpty';
21
- export * from './isFunction';
22
- export * from './isIOS';
23
- export * from './isIdCard';
24
- export * from './isMobile';
25
- export * from './isNull';
26
- export * from './isObject';
27
- export * from './isPhone';
28
- export * from './isPromise';
29
- export * from './isRegExp';
30
- export * from './isString';
31
- export * from './isUndefined';
32
- export * from './omit';
33
- export * from './parseError';
34
- export * from './parsePath';
35
- export * from './pick';
36
- export * from './replaceCrlf';
37
- export * from './reserve';
38
- export * from './storage';