@jiakun-zhao/utils 0.1.9 → 1.0.0-beta.0

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/dist/index.cjs CHANGED
@@ -1,33 +1,20 @@
1
1
  'use strict';
2
2
 
3
- const utils = require('@antfu/utils');
3
+ const fastGlob = require('fast-glob');
4
+ const ohash = require('ohash');
5
+ const localPkg = require('local-pkg');
4
6
 
5
- function to(value, block) {
6
- return block(value);
7
- }
8
- function use(value, block) {
9
- block(value);
10
- return value;
11
- }
12
- function takeIf(value, predicate) {
13
- return predicate(value) ? value : null;
14
- }
15
- function singleOrNull(arr) {
16
- return arr.length === 1 ? arr[0] : null;
17
- }
18
- function random(max, min = 0) {
19
- return Math.floor(Math.random() * max) + min;
20
- }
21
- function getNpmMirrorFilePath(name, version, ...path) {
22
- return `https://registry.npmmirror.com/${name}/${version}/files/${path.join("/")}`;
23
- }
7
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
24
8
 
25
- exports.getNpmMirrorFilePath = getNpmMirrorFilePath;
26
- exports.random = random;
27
- exports.singleOrNull = singleOrNull;
28
- exports.takeIf = takeIf;
29
- exports.to = to;
30
- exports.use = use;
31
- Object.keys(utils).forEach(function (k) {
32
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = utils[k];
33
- });
9
+ const fastGlob__default = /*#__PURE__*/_interopDefaultCompat(fastGlob);
10
+
11
+
12
+
13
+ exports.glob = fastGlob__default;
14
+ exports.hash = ohash.hash;
15
+ exports.sha256 = ohash.sha256;
16
+ exports.sha256base64 = ohash.sha256base64;
17
+ exports.getPackageInfo = localPkg.getPackageInfo;
18
+ exports.getPackageInfoSync = localPkg.getPackageInfoSync;
19
+ exports.isPackageExists = localPkg.isPackageExists;
20
+ exports.loadPackageJSON = localPkg.loadPackageJSON;
package/dist/index.d.cts CHANGED
@@ -1,10 +1,3 @@
1
- export * from '@antfu/utils';
2
-
3
- declare function to<T, R>(value: T, block: (it: T) => R): R;
4
- declare function use<T>(value: T, block: (it: T) => void): T;
5
- declare function takeIf<T>(value: T, predicate: (it: T) => boolean): T | null;
6
- declare function singleOrNull<T>(arr: T[]): T | null;
7
- declare function random(max: number, min?: number): number;
8
- declare function getNpmMirrorFilePath(name: string, version: string, ...path: string[]): string;
9
-
10
- export { getNpmMirrorFilePath, random, singleOrNull, takeIf, to, use };
1
+ export { default as glob } from 'fast-glob';
2
+ export { hash, sha256, sha256base64 } from 'ohash';
3
+ export { getPackageInfo, getPackageInfoSync, isPackageExists, loadPackageJSON } from 'local-pkg';
package/dist/index.d.mts CHANGED
@@ -1,10 +1,3 @@
1
- export * from '@antfu/utils';
2
-
3
- declare function to<T, R>(value: T, block: (it: T) => R): R;
4
- declare function use<T>(value: T, block: (it: T) => void): T;
5
- declare function takeIf<T>(value: T, predicate: (it: T) => boolean): T | null;
6
- declare function singleOrNull<T>(arr: T[]): T | null;
7
- declare function random(max: number, min?: number): number;
8
- declare function getNpmMirrorFilePath(name: string, version: string, ...path: string[]): string;
9
-
10
- export { getNpmMirrorFilePath, random, singleOrNull, takeIf, to, use };
1
+ export { default as glob } from 'fast-glob';
2
+ export { hash, sha256, sha256base64 } from 'ohash';
3
+ export { getPackageInfo, getPackageInfoSync, isPackageExists, loadPackageJSON } from 'local-pkg';
package/dist/index.d.ts CHANGED
@@ -1,10 +1,3 @@
1
- export * from '@antfu/utils';
2
-
3
- declare function to<T, R>(value: T, block: (it: T) => R): R;
4
- declare function use<T>(value: T, block: (it: T) => void): T;
5
- declare function takeIf<T>(value: T, predicate: (it: T) => boolean): T | null;
6
- declare function singleOrNull<T>(arr: T[]): T | null;
7
- declare function random(max: number, min?: number): number;
8
- declare function getNpmMirrorFilePath(name: string, version: string, ...path: string[]): string;
9
-
10
- export { getNpmMirrorFilePath, random, singleOrNull, takeIf, to, use };
1
+ export { default as glob } from 'fast-glob';
2
+ export { hash, sha256, sha256base64 } from 'ohash';
3
+ export { getPackageInfo, getPackageInfoSync, isPackageExists, loadPackageJSON } from 'local-pkg';
package/dist/index.mjs CHANGED
@@ -1,23 +1,3 @@
1
- export * from '@antfu/utils';
2
-
3
- function to(value, block) {
4
- return block(value);
5
- }
6
- function use(value, block) {
7
- block(value);
8
- return value;
9
- }
10
- function takeIf(value, predicate) {
11
- return predicate(value) ? value : null;
12
- }
13
- function singleOrNull(arr) {
14
- return arr.length === 1 ? arr[0] : null;
15
- }
16
- function random(max, min = 0) {
17
- return Math.floor(Math.random() * max) + min;
18
- }
19
- function getNpmMirrorFilePath(name, version, ...path) {
20
- return `https://registry.npmmirror.com/${name}/${version}/files/${path.join("/")}`;
21
- }
22
-
23
- export { getNpmMirrorFilePath, random, singleOrNull, takeIf, to, use };
1
+ export { default as glob } from 'fast-glob';
2
+ export { hash, sha256, sha256base64 } from 'ohash';
3
+ export { getPackageInfo, getPackageInfoSync, isPackageExists, loadPackageJSON } from 'local-pkg';
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ const utils = require('@antfu/utils');
4
+
5
+ function takeIf(value, predicate) {
6
+ return predicate(value) ? value : null;
7
+ }
8
+ function singleOrNull(arr) {
9
+ return arr.length === 1 ? arr[0] : null;
10
+ }
11
+ function random(max, min = 0) {
12
+ return Math.floor(Math.random() * max) + min;
13
+ }
14
+
15
+ exports.random = random;
16
+ exports.singleOrNull = singleOrNull;
17
+ exports.takeIf = takeIf;
18
+ Object.keys(utils).forEach(function (k) {
19
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = utils[k];
20
+ });
@@ -0,0 +1,10 @@
1
+ export * from '@antfu/utils';
2
+
3
+ declare function takeIf<T>(value: T, predicate: (it: T) => boolean): T | null;
4
+ declare function singleOrNull<T>(arr: T[]): T | null;
5
+ /**
6
+ * min <= result < max
7
+ */
8
+ declare function random(max: number, min?: number): number;
9
+
10
+ export { random, singleOrNull, takeIf };
@@ -0,0 +1,10 @@
1
+ export * from '@antfu/utils';
2
+
3
+ declare function takeIf<T>(value: T, predicate: (it: T) => boolean): T | null;
4
+ declare function singleOrNull<T>(arr: T[]): T | null;
5
+ /**
6
+ * min <= result < max
7
+ */
8
+ declare function random(max: number, min?: number): number;
9
+
10
+ export { random, singleOrNull, takeIf };
@@ -0,0 +1,10 @@
1
+ export * from '@antfu/utils';
2
+
3
+ declare function takeIf<T>(value: T, predicate: (it: T) => boolean): T | null;
4
+ declare function singleOrNull<T>(arr: T[]): T | null;
5
+ /**
6
+ * min <= result < max
7
+ */
8
+ declare function random(max: number, min?: number): number;
9
+
10
+ export { random, singleOrNull, takeIf };
@@ -0,0 +1,13 @@
1
+ export * from '@antfu/utils';
2
+
3
+ function takeIf(value, predicate) {
4
+ return predicate(value) ? value : null;
5
+ }
6
+ function singleOrNull(arr) {
7
+ return arr.length === 1 ? arr[0] : null;
8
+ }
9
+ function random(max, min = 0) {
10
+ return Math.floor(Math.random() * max) + min;
11
+ }
12
+
13
+ export { random, singleOrNull, takeIf };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jiakun-zhao/utils",
3
3
  "type": "module",
4
- "version": "0.1.9",
4
+ "version": "1.0.0-beta.0",
5
5
  "description": "Utils.",
6
6
  "author": "Jiakun Zhao <jiakun.zhao@outlook.com>",
7
7
  "license": "MIT",
@@ -16,8 +16,13 @@
16
16
  "exports": {
17
17
  ".": {
18
18
  "types": "./dist/index.d.ts",
19
- "require": "./dist/index.cjs",
20
- "import": "./dist/index.mjs"
19
+ "import": "./dist/index.mjs",
20
+ "require": "./dist/index.cjs"
21
+ },
22
+ "./shared": {
23
+ "types": "./dist/shared.d.ts",
24
+ "import": "./dist/shared.mjs",
25
+ "require": "./dist/shared.cjs"
21
26
  }
22
27
  },
23
28
  "main": "./dist/index.cjs",
@@ -27,15 +32,18 @@
27
32
  "dist"
28
33
  ],
29
34
  "dependencies": {
30
- "@antfu/utils": "^0.7.6"
35
+ "@antfu/utils": "^0.7.6",
36
+ "fast-glob": "^3.3.2",
37
+ "local-pkg": "^0.5.0",
38
+ "ohash": "^1.1.3"
31
39
  },
32
40
  "devDependencies": {
33
41
  "@jiakun-zhao/eslint-config": "^1.3.1",
34
- "@types/node": "^20.9.0",
42
+ "@types/node": "^20.9.2",
35
43
  "bumpp": "^9.2.0",
36
- "eslint": "^8.53.0",
44
+ "eslint": "^8.54.0",
37
45
  "esno": "^4.0.0",
38
- "typescript": "^5.2.2",
46
+ "typescript": "^5.3.2",
39
47
  "unbuild": "^2.0.0"
40
48
  },
41
49
  "eslintConfig": {