@daysnap/utils 0.0.15 → 0.0.17
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/each.d.ts +5 -0
- package/es/each.js +12 -0
- package/lib/each.d.ts +5 -0
- package/lib/each.js +19 -0
- package/package.json +1 -11
package/es/each.d.ts
ADDED
package/es/each.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function each(data, callback) {
|
|
2
|
+
if (Array.isArray(data)) {
|
|
3
|
+
// eslint-disable-next-line no-plusplus
|
|
4
|
+
for (var index = 0, length = data.length; index < length; index++) {
|
|
5
|
+
callback.call(data[index], data[index], index);
|
|
6
|
+
}
|
|
7
|
+
} else {
|
|
8
|
+
Object.keys(data).forEach(function (key) {
|
|
9
|
+
callback.call(data[key], data[key], key);
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
}
|
package/lib/each.d.ts
ADDED
package/lib/each.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.each = each;
|
|
7
|
+
|
|
8
|
+
function each(data, callback) {
|
|
9
|
+
if (Array.isArray(data)) {
|
|
10
|
+
// eslint-disable-next-line no-plusplus
|
|
11
|
+
for (var index = 0, length = data.length; index < length; index++) {
|
|
12
|
+
callback.call(data[index], data[index], index);
|
|
13
|
+
}
|
|
14
|
+
} else {
|
|
15
|
+
Object.keys(data).forEach(function (key) {
|
|
16
|
+
callback.call(data[key], data[key], key);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
}
|
package/package.json
CHANGED
|
@@ -1,20 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@daysnap/utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
4
4
|
"description": "通用的工具库",
|
|
5
|
-
"type": "module",
|
|
6
5
|
"main": "lib/index.js",
|
|
7
6
|
"module": "es/index.js",
|
|
8
7
|
"typings": "lib/index.d.ts",
|
|
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
|
-
},
|
|
18
8
|
"scripts": {
|
|
19
9
|
"ts-node": "npx ts-node --project ./tsconfig.json ./src/filename.ts",
|
|
20
10
|
"gen": "plop --plopfile ./scripts/gen.js --force",
|