@jiakun-zhao/utils 0.1.8 → 0.1.9

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
@@ -12,32 +12,17 @@ function use(value, block) {
12
12
  function takeIf(value, predicate) {
13
13
  return predicate(value) ? value : null;
14
14
  }
15
- function isNotEmpty(o) {
16
- if (typeof o !== "object")
17
- return Boolean(o);
18
- return Array.isArray(o) ? !!o.length : !!Object.keys(o).length;
19
- }
20
15
  function singleOrNull(arr) {
21
16
  return arr.length === 1 ? arr[0] : null;
22
17
  }
23
- function createArray(length, fn) {
24
- const block = fn ? (_, idx) => fn(idx) : (_, idx) => idx;
25
- return Array.from({ length }, block);
26
- }
27
18
  function random(max, min = 0) {
28
19
  return Math.floor(Math.random() * max) + min;
29
20
  }
30
- function hScreen() {
31
- document.body.style.setProperty("--h-screen", `${window.innerHeight}px`);
32
- }
33
- function fixHeightScreen() {
34
- hScreen();
35
- window.addEventListener("resize", hScreen);
21
+ function getNpmMirrorFilePath(name, version, ...path) {
22
+ return `https://registry.npmmirror.com/${name}/${version}/files/${path.join("/")}`;
36
23
  }
37
24
 
38
- exports.createArray = createArray;
39
- exports.fixHeightScreen = fixHeightScreen;
40
- exports.isNotEmpty = isNotEmpty;
25
+ exports.getNpmMirrorFilePath = getNpmMirrorFilePath;
41
26
  exports.random = random;
42
27
  exports.singleOrNull = singleOrNull;
43
28
  exports.takeIf = takeIf;
package/dist/index.d.cts CHANGED
@@ -3,11 +3,8 @@ export * from '@antfu/utils';
3
3
  declare function to<T, R>(value: T, block: (it: T) => R): R;
4
4
  declare function use<T>(value: T, block: (it: T) => void): T;
5
5
  declare function takeIf<T>(value: T, predicate: (it: T) => boolean): T | null;
6
- declare function isNotEmpty(o: any): boolean;
7
6
  declare function singleOrNull<T>(arr: T[]): T | null;
8
- declare function createArray(length: number): number[];
9
- declare function createArray<R>(length: number, fn: (index: number) => R): R[];
10
7
  declare function random(max: number, min?: number): number;
11
- declare function fixHeightScreen(): void;
8
+ declare function getNpmMirrorFilePath(name: string, version: string, ...path: string[]): string;
12
9
 
13
- export { createArray, fixHeightScreen, isNotEmpty, random, singleOrNull, takeIf, to, use };
10
+ export { getNpmMirrorFilePath, random, singleOrNull, takeIf, to, use };
package/dist/index.d.mts CHANGED
@@ -3,11 +3,8 @@ export * from '@antfu/utils';
3
3
  declare function to<T, R>(value: T, block: (it: T) => R): R;
4
4
  declare function use<T>(value: T, block: (it: T) => void): T;
5
5
  declare function takeIf<T>(value: T, predicate: (it: T) => boolean): T | null;
6
- declare function isNotEmpty(o: any): boolean;
7
6
  declare function singleOrNull<T>(arr: T[]): T | null;
8
- declare function createArray(length: number): number[];
9
- declare function createArray<R>(length: number, fn: (index: number) => R): R[];
10
7
  declare function random(max: number, min?: number): number;
11
- declare function fixHeightScreen(): void;
8
+ declare function getNpmMirrorFilePath(name: string, version: string, ...path: string[]): string;
12
9
 
13
- export { createArray, fixHeightScreen, isNotEmpty, random, singleOrNull, takeIf, to, use };
10
+ export { getNpmMirrorFilePath, random, singleOrNull, takeIf, to, use };
package/dist/index.d.ts CHANGED
@@ -3,11 +3,8 @@ export * from '@antfu/utils';
3
3
  declare function to<T, R>(value: T, block: (it: T) => R): R;
4
4
  declare function use<T>(value: T, block: (it: T) => void): T;
5
5
  declare function takeIf<T>(value: T, predicate: (it: T) => boolean): T | null;
6
- declare function isNotEmpty(o: any): boolean;
7
6
  declare function singleOrNull<T>(arr: T[]): T | null;
8
- declare function createArray(length: number): number[];
9
- declare function createArray<R>(length: number, fn: (index: number) => R): R[];
10
7
  declare function random(max: number, min?: number): number;
11
- declare function fixHeightScreen(): void;
8
+ declare function getNpmMirrorFilePath(name: string, version: string, ...path: string[]): string;
12
9
 
13
- export { createArray, fixHeightScreen, isNotEmpty, random, singleOrNull, takeIf, to, use };
10
+ export { getNpmMirrorFilePath, random, singleOrNull, takeIf, to, use };
package/dist/index.mjs CHANGED
@@ -10,27 +10,14 @@ function use(value, block) {
10
10
  function takeIf(value, predicate) {
11
11
  return predicate(value) ? value : null;
12
12
  }
13
- function isNotEmpty(o) {
14
- if (typeof o !== "object")
15
- return Boolean(o);
16
- return Array.isArray(o) ? !!o.length : !!Object.keys(o).length;
17
- }
18
13
  function singleOrNull(arr) {
19
14
  return arr.length === 1 ? arr[0] : null;
20
15
  }
21
- function createArray(length, fn) {
22
- const block = fn ? (_, idx) => fn(idx) : (_, idx) => idx;
23
- return Array.from({ length }, block);
24
- }
25
16
  function random(max, min = 0) {
26
17
  return Math.floor(Math.random() * max) + min;
27
18
  }
28
- function hScreen() {
29
- document.body.style.setProperty("--h-screen", `${window.innerHeight}px`);
30
- }
31
- function fixHeightScreen() {
32
- hScreen();
33
- window.addEventListener("resize", hScreen);
19
+ function getNpmMirrorFilePath(name, version, ...path) {
20
+ return `https://registry.npmmirror.com/${name}/${version}/files/${path.join("/")}`;
34
21
  }
35
22
 
36
- export { createArray, fixHeightScreen, isNotEmpty, random, singleOrNull, takeIf, to, use };
23
+ export { getNpmMirrorFilePath, random, singleOrNull, takeIf, to, use };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jiakun-zhao/utils",
3
3
  "type": "module",
4
- "version": "0.1.8",
4
+ "version": "0.1.9",
5
5
  "description": "Utils.",
6
6
  "author": "Jiakun Zhao <jiakun.zhao@outlook.com>",
7
7
  "license": "MIT",
@@ -31,10 +31,10 @@
31
31
  },
32
32
  "devDependencies": {
33
33
  "@jiakun-zhao/eslint-config": "^1.3.1",
34
- "@types/node": "^20.8.10",
34
+ "@types/node": "^20.9.0",
35
35
  "bumpp": "^9.2.0",
36
36
  "eslint": "^8.53.0",
37
- "esno": "^0.17.0",
37
+ "esno": "^4.0.0",
38
38
  "typescript": "^5.2.2",
39
39
  "unbuild": "^2.0.0"
40
40
  },