@trenskow/from 1.1.32 → 1.2.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/.eslintrc.js +2 -1
- package/index.js +4 -7
- package/package.json +3 -2
- package/test/index.js +2 -5
package/.eslintrc.js
CHANGED
package/index.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import keyd from 'keyd';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
keyd = require('keyd');
|
|
3
|
+
export default function from(obj) {
|
|
5
4
|
|
|
6
|
-
module.exports = exports = function from(obj) {
|
|
7
|
-
|
|
8
5
|
if (!(this instanceof from)) return new from(obj);
|
|
9
6
|
|
|
10
7
|
if (typeof(obj) !== 'object') throw TypeError('Input must be object or array.');
|
|
@@ -170,7 +167,7 @@ module.exports = exports = function from(obj) {
|
|
|
170
167
|
}
|
|
171
168
|
|
|
172
169
|
const result = data
|
|
173
|
-
.filter((obj, ...args) => {
|
|
170
|
+
.filter((obj, ...args) => {
|
|
174
171
|
const filter = (this._filter ? this._filter(obj, ...args) : true);
|
|
175
172
|
const conditions = (this._conditions ? this._test(obj, this._conditions) : true);
|
|
176
173
|
return filter && conditions;
|
|
@@ -212,7 +209,7 @@ module.exports = exports = function from(obj) {
|
|
|
212
209
|
keyd(result).set(keyPath, value);
|
|
213
210
|
|
|
214
211
|
});
|
|
215
|
-
|
|
212
|
+
|
|
216
213
|
}
|
|
217
214
|
|
|
218
215
|
if (this._applyTo) {
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trenskow/from",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "A small library for selecting keys from an object.",
|
|
5
5
|
"main": "index.js",
|
|
6
|
+
"type": "module",
|
|
6
7
|
"scripts": {
|
|
7
8
|
"test": "./node_modules/mocha/bin/mocha.js ./test/index.js"
|
|
8
9
|
},
|
|
@@ -20,7 +21,7 @@
|
|
|
20
21
|
"keyd": "^2.0.5"
|
|
21
22
|
},
|
|
22
23
|
"devDependencies": {
|
|
23
|
-
"chai": "^
|
|
24
|
+
"chai": "^5.0.0",
|
|
24
25
|
"mocha": "^10.2.0"
|
|
25
26
|
}
|
|
26
27
|
}
|
package/test/index.js
CHANGED