@vope/utils 1.4.7 → 1.4.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/cjs/index.js CHANGED
@@ -42,6 +42,7 @@ __export(src_exports, {
42
42
  inputRegex: () => inputRegex,
43
43
  isClass: () => isClass,
44
44
  isEmpty: () => isEmpty,
45
+ isKey: () => isKey,
45
46
  isNull: () => isNull,
46
47
  joinPaths: () => joinPaths,
47
48
  loadImage: () => loadImage,
@@ -288,6 +289,9 @@ var isNull = (value) => value === void 0 || value === null;
288
289
  // src/is/empty.ts
289
290
  var isEmpty = (value) => isNull(value) || value === "";
290
291
 
292
+ // src/is/key.ts
293
+ var isKey = (key, data) => key in data;
294
+
291
295
  // src/load/image.ts
292
296
  var loadImage = (src) => {
293
297
  return new Promise((resolve) => {
@@ -393,9 +397,9 @@ var MemoryBasic = class {
393
397
  return this;
394
398
  for (const [type, target] of memorys) {
395
399
  const memory = this.#reflex(target);
396
- memory.forEach((value, index2) => {
397
- if (value >= index2) {
398
- memory[index2] = value - 1;
400
+ memory.forEach((value, i) => {
401
+ if (value >= index) {
402
+ memory[i] = value - 1;
399
403
  }
400
404
  });
401
405
  if (memory !== target) {
package/lib/index.js CHANGED
@@ -10,6 +10,7 @@ import { getEncoding } from "./encoding";
10
10
  import { inputRegex } from "./input-regex";
11
11
  import { isClass } from "./is/class";
12
12
  import { isEmpty } from "./is/empty";
13
+ import { isKey } from "./is/key";
13
14
  import { isNull } from "./is/null";
14
15
  import { loadImage } from "./load/image";
15
16
  import { MemoryBasic } from "./memory/basic";
@@ -48,6 +49,7 @@ export {
48
49
  inputRegex,
49
50
  isClass,
50
51
  isEmpty,
52
+ isKey,
51
53
  isNull,
52
54
  joinPaths,
53
55
  loadImage,
package/lib/is/key.js ADDED
@@ -0,0 +1,4 @@
1
+ const isKey = (key, data) => key in data;
2
+ export {
3
+ isKey
4
+ };
@@ -93,9 +93,9 @@ class MemoryBasic {
93
93
  return this;
94
94
  for (const [type, target] of memorys) {
95
95
  const memory = this.#reflex(target);
96
- memory.forEach((value, index2) => {
97
- if (value >= index2) {
98
- memory[index2] = value - 1;
96
+ memory.forEach((value, i) => {
97
+ if (value >= index) {
98
+ memory[i] = value - 1;
99
99
  }
100
100
  });
101
101
  if (memory !== target) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vope/utils",
3
- "version": "1.4.7",
3
+ "version": "1.4.9",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {
package/types/index.d.ts CHANGED
@@ -10,6 +10,7 @@ export { getEncoding } from './encoding';
10
10
  export { inputRegex } from './input-regex';
11
11
  export { isClass } from './is/class';
12
12
  export { isEmpty } from './is/empty';
13
+ export { isKey } from './is/key';
13
14
  export { isNull } from './is/null';
14
15
  export { loadImage } from './load/image';
15
16
  export { MemoryBasic } from './memory/basic';
@@ -0,0 +1,4 @@
1
+ /**
2
+ * 检测key是否为对象的属性
3
+ */
4
+ export declare const isKey: <T extends object>(key: string, data: T) => key is Extract<keyof T, string>;