@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 CHANGED
@@ -5,7 +5,8 @@ module.exports = {
5
5
  "mocha": true
6
6
  },
7
7
  "parserOptions": {
8
- "ecmaVersion": 2017
8
+ "ecmaVersion": 2017,
9
+ "sourceType": "module"
9
10
  },
10
11
  "extends": "eslint:recommended",
11
12
  "rules": {
package/index.js CHANGED
@@ -1,10 +1,7 @@
1
- 'use strict';
1
+ import keyd from 'keyd';
2
2
 
3
- const
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.1.32",
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": "^4.4.1",
24
+ "chai": "^5.0.0",
24
25
  "mocha": "^10.2.0"
25
26
  }
26
27
  }
package/test/index.js CHANGED
@@ -1,8 +1,5 @@
1
- 'use strict';
2
-
3
- const
4
- { expect } = require('chai'),
5
- from = require('../');
1
+ import { expect } from 'chai';
2
+ import from from '../index.js';
6
3
 
7
4
  describe('from', () => {
8
5
  it ('should throw an error if input is not an object', () => {