@daysnap/utils 0.0.26 → 0.0.28
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/es/getDayMillisecond.d.ts +4 -0
- package/es/getDayMillisecond.js +7 -0
- package/es/index.d.ts +4 -1
- package/es/index.js +4 -1
- package/es/parseDate.d.ts +4 -0
- package/es/parseDate.js +11 -0
- package/es/storage/index.d.ts +2 -2
- package/es/storage/index.js +11 -2
- package/lib/getDayMillisecond.d.ts +4 -0
- package/lib/getDayMillisecond.js +13 -0
- package/lib/index.d.ts +4 -1
- package/lib/index.js +37 -1
- package/lib/parseDate.d.ts +4 -0
- package/lib/parseDate.js +17 -0
- package/lib/storage/index.d.ts +2 -2
- package/lib/storage/index.js +14 -5
- package/package.json +2 -2
package/es/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
export declare const version = "0.0.
|
|
1
|
+
export declare const version = "0.0.27";
|
|
2
2
|
export * from './base64ToBlob';
|
|
3
3
|
export * from './blobToBase64';
|
|
4
4
|
export * from './compareVersion';
|
|
5
5
|
export * from './compressImage';
|
|
6
6
|
export * from './createHexColorByHash';
|
|
7
7
|
export * from './downloadFile';
|
|
8
|
+
export * from './each';
|
|
8
9
|
export * from './filterBankCardNo';
|
|
9
10
|
export * from './filterEmoji';
|
|
10
11
|
export * from './filterIdCard';
|
|
@@ -13,6 +14,7 @@ export * from './filterPhone';
|
|
|
13
14
|
export * from './formatAmount';
|
|
14
15
|
export * from './formatDate';
|
|
15
16
|
export * from './getBlobByUrl';
|
|
17
|
+
export * from './getDayMillisecond';
|
|
16
18
|
export * from './getImageInfo';
|
|
17
19
|
export * from './getVideoInfo';
|
|
18
20
|
export * from './isAndroid';
|
|
@@ -30,6 +32,7 @@ export * from './isRegExp';
|
|
|
30
32
|
export * from './isString';
|
|
31
33
|
export * from './isUndefined';
|
|
32
34
|
export * from './omit';
|
|
35
|
+
export * from './parseDate';
|
|
33
36
|
export * from './parseError';
|
|
34
37
|
export * from './parsePath';
|
|
35
38
|
export * from './pick';
|
package/es/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/* 本文件自动生成 './scripts/entry.js' */
|
|
2
|
-
export var version = '0.0.
|
|
2
|
+
export var version = '0.0.27';
|
|
3
3
|
export * from './base64ToBlob';
|
|
4
4
|
export * from './blobToBase64';
|
|
5
5
|
export * from './compareVersion';
|
|
6
6
|
export * from './compressImage';
|
|
7
7
|
export * from './createHexColorByHash';
|
|
8
8
|
export * from './downloadFile';
|
|
9
|
+
export * from './each';
|
|
9
10
|
export * from './filterBankCardNo';
|
|
10
11
|
export * from './filterEmoji';
|
|
11
12
|
export * from './filterIdCard';
|
|
@@ -14,6 +15,7 @@ export * from './filterPhone';
|
|
|
14
15
|
export * from './formatAmount';
|
|
15
16
|
export * from './formatDate';
|
|
16
17
|
export * from './getBlobByUrl';
|
|
18
|
+
export * from './getDayMillisecond';
|
|
17
19
|
export * from './getImageInfo';
|
|
18
20
|
export * from './getVideoInfo';
|
|
19
21
|
export * from './isAndroid';
|
|
@@ -31,6 +33,7 @@ export * from './isRegExp';
|
|
|
31
33
|
export * from './isString';
|
|
32
34
|
export * from './isUndefined';
|
|
33
35
|
export * from './omit';
|
|
36
|
+
export * from './parseDate';
|
|
34
37
|
export * from './parseError';
|
|
35
38
|
export * from './parsePath';
|
|
36
39
|
export * from './pick';
|
package/es/parseDate.js
ADDED
package/es/storage/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const getCache: () => {
|
|
2
2
|
setItem: <T>(key: string, val: T) => T;
|
|
3
3
|
getItem: <T_1>(key: string, defaultVal?: Partial<T_1>) => any;
|
|
4
4
|
removeItem: (key: string) => void;
|
|
@@ -11,7 +11,7 @@ export declare const cache: {
|
|
|
11
11
|
updateItem: (val: Partial<T_3>) => T_3;
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
|
-
export declare const
|
|
14
|
+
export declare const getLocal: () => {
|
|
15
15
|
setItem: <T>(key: string, val: T) => T;
|
|
16
16
|
getItem: <T_1>(key: string, defaultVal?: Partial<T_1>) => any;
|
|
17
17
|
removeItem: (key: string) => void;
|
package/es/storage/index.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
import { factory } from './factory';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
var getStorage = function getStorage(type) {
|
|
3
|
+
var instance = null;
|
|
4
|
+
return function () {
|
|
5
|
+
if (!instance) {
|
|
6
|
+
instance = factory(type);
|
|
7
|
+
}
|
|
8
|
+
return instance;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export var getCache = getStorage('sessionStorage');
|
|
12
|
+
export var getLocal = getStorage('localStorage');
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getDayMillisecond = getDayMillisecond;
|
|
7
|
+
/**
|
|
8
|
+
* 获取多少天的毫秒数 默认获取1天的
|
|
9
|
+
*/
|
|
10
|
+
function getDayMillisecond() {
|
|
11
|
+
var day = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
12
|
+
return day * 24 * 60 * 60 * 1000;
|
|
13
|
+
}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
export declare const version = "0.0.
|
|
1
|
+
export declare const version = "0.0.27";
|
|
2
2
|
export * from './base64ToBlob';
|
|
3
3
|
export * from './blobToBase64';
|
|
4
4
|
export * from './compareVersion';
|
|
5
5
|
export * from './compressImage';
|
|
6
6
|
export * from './createHexColorByHash';
|
|
7
7
|
export * from './downloadFile';
|
|
8
|
+
export * from './each';
|
|
8
9
|
export * from './filterBankCardNo';
|
|
9
10
|
export * from './filterEmoji';
|
|
10
11
|
export * from './filterIdCard';
|
|
@@ -13,6 +14,7 @@ export * from './filterPhone';
|
|
|
13
14
|
export * from './formatAmount';
|
|
14
15
|
export * from './formatDate';
|
|
15
16
|
export * from './getBlobByUrl';
|
|
17
|
+
export * from './getDayMillisecond';
|
|
16
18
|
export * from './getImageInfo';
|
|
17
19
|
export * from './getVideoInfo';
|
|
18
20
|
export * from './isAndroid';
|
|
@@ -30,6 +32,7 @@ export * from './isRegExp';
|
|
|
30
32
|
export * from './isString';
|
|
31
33
|
export * from './isUndefined';
|
|
32
34
|
export * from './omit';
|
|
35
|
+
export * from './parseDate';
|
|
33
36
|
export * from './parseError';
|
|
34
37
|
export * from './parsePath';
|
|
35
38
|
export * from './pick';
|
package/lib/index.js
CHANGED
|
@@ -79,6 +79,18 @@ Object.keys(_downloadFile).forEach(function (key) {
|
|
|
79
79
|
}
|
|
80
80
|
});
|
|
81
81
|
});
|
|
82
|
+
var _each = require("./each");
|
|
83
|
+
Object.keys(_each).forEach(function (key) {
|
|
84
|
+
if (key === "default" || key === "__esModule") return;
|
|
85
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
86
|
+
if (key in exports && exports[key] === _each[key]) return;
|
|
87
|
+
Object.defineProperty(exports, key, {
|
|
88
|
+
enumerable: true,
|
|
89
|
+
get: function get() {
|
|
90
|
+
return _each[key];
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
});
|
|
82
94
|
var _filterBankCardNo = require("./filterBankCardNo");
|
|
83
95
|
Object.keys(_filterBankCardNo).forEach(function (key) {
|
|
84
96
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -175,6 +187,18 @@ Object.keys(_getBlobByUrl).forEach(function (key) {
|
|
|
175
187
|
}
|
|
176
188
|
});
|
|
177
189
|
});
|
|
190
|
+
var _getDayMillisecond = require("./getDayMillisecond");
|
|
191
|
+
Object.keys(_getDayMillisecond).forEach(function (key) {
|
|
192
|
+
if (key === "default" || key === "__esModule") return;
|
|
193
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
194
|
+
if (key in exports && exports[key] === _getDayMillisecond[key]) return;
|
|
195
|
+
Object.defineProperty(exports, key, {
|
|
196
|
+
enumerable: true,
|
|
197
|
+
get: function get() {
|
|
198
|
+
return _getDayMillisecond[key];
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
});
|
|
178
202
|
var _getImageInfo = require("./getImageInfo");
|
|
179
203
|
Object.keys(_getImageInfo).forEach(function (key) {
|
|
180
204
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -379,6 +403,18 @@ Object.keys(_omit).forEach(function (key) {
|
|
|
379
403
|
}
|
|
380
404
|
});
|
|
381
405
|
});
|
|
406
|
+
var _parseDate = require("./parseDate");
|
|
407
|
+
Object.keys(_parseDate).forEach(function (key) {
|
|
408
|
+
if (key === "default" || key === "__esModule") return;
|
|
409
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
410
|
+
if (key in exports && exports[key] === _parseDate[key]) return;
|
|
411
|
+
Object.defineProperty(exports, key, {
|
|
412
|
+
enumerable: true,
|
|
413
|
+
get: function get() {
|
|
414
|
+
return _parseDate[key];
|
|
415
|
+
}
|
|
416
|
+
});
|
|
417
|
+
});
|
|
382
418
|
var _parseError = require("./parseError");
|
|
383
419
|
Object.keys(_parseError).forEach(function (key) {
|
|
384
420
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -452,5 +488,5 @@ Object.keys(_storage).forEach(function (key) {
|
|
|
452
488
|
});
|
|
453
489
|
});
|
|
454
490
|
/* 本文件自动生成 './scripts/entry.js' */
|
|
455
|
-
var version = '0.0.
|
|
491
|
+
var version = '0.0.27';
|
|
456
492
|
exports.version = version;
|
package/lib/parseDate.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.parseDate = parseDate;
|
|
7
|
+
/**
|
|
8
|
+
* 解析成Date
|
|
9
|
+
*/
|
|
10
|
+
function parseDate(v) {
|
|
11
|
+
if (typeof v === 'string') {
|
|
12
|
+
// fix ios 格式日期错误
|
|
13
|
+
// eslint-disable-next-line no-param-reassign
|
|
14
|
+
v = v.replace(/-/g, '/');
|
|
15
|
+
}
|
|
16
|
+
return new Date(v);
|
|
17
|
+
}
|
package/lib/storage/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const getCache: () => {
|
|
2
2
|
setItem: <T>(key: string, val: T) => T;
|
|
3
3
|
getItem: <T_1>(key: string, defaultVal?: Partial<T_1>) => any;
|
|
4
4
|
removeItem: (key: string) => void;
|
|
@@ -11,7 +11,7 @@ export declare const cache: {
|
|
|
11
11
|
updateItem: (val: Partial<T_3>) => T_3;
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
|
-
export declare const
|
|
14
|
+
export declare const getLocal: () => {
|
|
15
15
|
setItem: <T>(key: string, val: T) => T;
|
|
16
16
|
getItem: <T_1>(key: string, defaultVal?: Partial<T_1>) => any;
|
|
17
17
|
removeItem: (key: string) => void;
|
package/lib/storage/index.js
CHANGED
|
@@ -3,9 +3,18 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.getLocal = exports.getCache = void 0;
|
|
7
7
|
var _factory = require("./factory");
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
var getStorage = function getStorage(type) {
|
|
9
|
+
var instance = null;
|
|
10
|
+
return function () {
|
|
11
|
+
if (!instance) {
|
|
12
|
+
instance = (0, _factory.factory)(type);
|
|
13
|
+
}
|
|
14
|
+
return instance;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
var getCache = getStorage('sessionStorage');
|
|
18
|
+
exports.getCache = getCache;
|
|
19
|
+
var getLocal = getStorage('localStorage');
|
|
20
|
+
exports.getLocal = getLocal;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@daysnap/utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.28",
|
|
4
4
|
"description": "通用的工具库",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"build": "dsc build",
|
|
13
13
|
"test": "jest",
|
|
14
14
|
"coverage": "jest --coverage",
|
|
15
|
-
"predeploy": "npm run test",
|
|
15
|
+
"predeploy": "npm run entry && npm run test",
|
|
16
16
|
"deploy": "npm run build && dsc publish",
|
|
17
17
|
"husky": "husky install && echo 'export PATH=\"/usr/local/bin/:$PATH\"' >> ~/.huskyrc",
|
|
18
18
|
"lint": "eslint 'src/**/*.{js,ts}' --fix",
|