Skip to content

Commit efb44a4

Browse files
authored
Merge pull request #34 from hckrnews/feature/esm
ESM only
2 parents 3bcdda9 + 5a18e04 commit efb44a4

29 files changed

+2245
-6960
lines changed

.eslintrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@
3030
"jsdoc": {
3131
"mode": "typescript"
3232
}
33-
},
33+
}
3434
}

.nvmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20.4.0
1+
20.10.0

jsconfig.json

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
{
2-
"compilerOptions": {
3-
"checkJs": true,
4-
"target": "ESNext",
5-
"module": "ESNext",
6-
"moduleResolution": "node",
7-
"rootDirs": [
8-
"src"
9-
],
10-
"resolveJsonModule": true
11-
},
12-
"exclude": [
13-
"node_modules",
14-
"**/node_modules/*"
15-
]
2+
"compilerOptions": {
3+
"checkJs": true,
4+
"target": "ESNext",
5+
"module": "NodeNext",
6+
"moduleResolution": "nodenext",
7+
"rootDirs": [
8+
"src"
9+
],
10+
"resolveJsonModule": true
11+
},
12+
"exclude": [
13+
"node_modules",
14+
"**/node_modules/*"
15+
]
1616
}

package-lock.json

+2,198-6,888
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+5-30
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hckrnews/arrays",
3-
"version": "3.1.8",
3+
"version": "4.0.0",
44
"description": "Usefull array helpers.",
55
"files": [
66
"src/helpers.js",
@@ -19,30 +19,11 @@
1919
"src/modules/summ.js",
2020
"src/modules/toJson.js",
2121
"src/modules/unique.js",
22-
"src/modules/update.js",
23-
"dist/helpers.cjs",
24-
"dist/helpers.cjs.map",
25-
"dist/helpers.js",
26-
"dist/helpers.js.map",
27-
"dist/helpers.module.mjs",
28-
"dist/helpers.module.mjs.map",
29-
"dist/helpers.umd.cjs",
30-
"dist/helpers.umd.cjs.map"
22+
"src/modules/update.js"
3123
],
32-
"main": "dist/helpers.umd.cjs",
24+
"main": "src/helpers.js",
3325
"source": "src/helpers.js",
34-
"module": "dist/helpers.module.mjs",
35-
"unpkg": "dist/helpers.umd.cjs",
36-
"umd:main": "dist/helpers.umd.cjs",
37-
"exports": {
38-
"node": {
39-
"default": "./dist/helpers.umd.cjs",
40-
"module": "./src/helpers.js",
41-
"require": "./dist/helpers.umd.cjs"
42-
},
43-
"require": "./dist/helpers.umd.cjs",
44-
"default": "./dist/helpers.umd.cjs"
45-
},
26+
"module": "src/helpers.js",
4627
"repository": {
4728
"type": "git",
4829
"url": "https://github.com/hckrnews/arrays.git"
@@ -68,8 +49,7 @@
6849
"test": "c8 node --test test/*.js",
6950
"example": "node example/node.js",
7051
"cpd": "node_modules/jscpd/bin/jscpd src",
71-
"vulnerabilities": "npm audit --production",
72-
"build": "microbundle --target node src/helpers.js"
52+
"vulnerabilities": "npm audit --production"
7353
},
7454
"devDependencies": {
7555
"@hckrnews/eslint-config": "^3.0.0",
@@ -82,7 +62,6 @@
8262
"eslint-plugin-jsx-a11y": "^6.4.1",
8363
"eslint-plugin-prettier": "^5.0.0",
8464
"jscpd": "^3.4.5",
85-
"microbundle": "^0.15.1",
8665
"prettier": "^3.0.0"
8766
},
8867
"type": "module",
@@ -95,9 +74,5 @@
9574
},
9675
"overrides": {
9776
"xml2js": "^0.5.0"
98-
},
99-
"funding": {
100-
"type": "github",
101-
"url": "https://github.com/sponsors/w3nl"
10277
}
10378
}

src/helpers.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ class Arr extends Array {
3838
* Filter a multi array.
3939
*
4040
* @param {string} key
41-
* @param {string} find
42-
* @param {boolean=} operator
41+
* @param {any} find
42+
* @param {(boolean|string)=} operator
4343
*
4444
* @return {any[]}
4545
*/
@@ -50,7 +50,7 @@ class Arr extends Array {
5050
/**
5151
* Only get some keys of a multi array.
5252
*
53-
* @param {string} key
53+
* @param {string|string[]} key
5454
*
5555
* @return {any[]}
5656
*/

src/modules/first.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ export default function first(originalArray) {
33
return null;
44
}
55

6-
return originalArray[0];
6+
return originalArray.at(0);
77
}

src/modules/last.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ export default function last(originalArray) {
33
return null;
44
}
55

6-
return originalArray[originalArray.length - 1];
6+
return originalArray.at(-1);
77
}

test/arr.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'node:test';
2-
import assert from 'assert';
2+
import assert from 'node:assert';
33
import { Arr } from '../src/helpers.js';
44

55
const original = new Arr(1, 2, 3);

test/average.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'node:test';
2-
import assert from 'assert';
2+
import assert from 'node:assert';
33
import { Arr } from '../src/helpers.js';
44

55
test('Average', async (t) => {

test/diff-object.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'node:test';
2-
import assert from 'assert';
2+
import assert from 'node:assert';
33
import { Arr } from '../src/helpers.js';
44

55
const a = new Arr([{ name: 'John' }, { name: 'Peter' }, { name: 'Luke' }]);

test/diff.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'node:test';
2-
import assert from 'assert';
2+
import assert from 'node:assert';
33
import { Arr } from '../src/helpers.js';
44

55
const a = new Arr(['John', 'Peter', 'Luke']);

test/first.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'node:test';
2-
import assert from 'assert';
2+
import assert from 'node:assert';
33
import { Arr } from '../src/helpers.js';
44

55
test('First', async (t) => {

test/getByKey.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'node:test';
2-
import assert from 'assert';
2+
import assert from 'node:assert';
33
import { Arr } from '../src/helpers.js';
44

55
const getTestCases = [

test/intersect-object.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'node:test';
2-
import assert from 'assert';
2+
import assert from 'node:assert';
33
import { Arr } from '../src/helpers.js';
44

55
const a = new Arr([{ name: 'John' }, { name: 'Peter' }, { name: 'Luke' }]);

test/intersect.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'node:test';
2-
import assert from 'assert';
2+
import assert from 'node:assert';
33
import { Arr } from '../src/helpers.js';
44

55
const a = new Arr(['John', 'Peter', 'Luke']);

test/last.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'node:test';
2-
import assert from 'assert';
2+
import assert from 'node:assert';
33
import { Arr } from '../src/helpers.js';
44

55
test('Last', async (t) => {

test/max.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'node:test';
2-
import assert from 'assert';
2+
import assert from 'node:assert';
33
import { Arr } from '../src/helpers.js';
44

55
const exampleArray = new Arr([1, 2, 3]);

test/min.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'node:test';
2-
import assert from 'assert';
2+
import assert from 'node:assert';
33
import { Arr } from '../src/helpers.js';
44

55
const exampleArray = new Arr([1, 2, 3]);

test/multifilter.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'node:test';
2-
import assert from 'assert';
2+
import assert from 'node:assert';
33
import { Arr } from '../src/helpers.js';
44

55
const exampleArray = new Arr([

test/multikey.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'node:test';
2-
import assert from 'assert';
2+
import assert from 'node:assert';
33
import { Arr } from '../src/helpers.js';
44

55
const exampleArray = new Arr([

test/multisort.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'node:test';
2-
import assert from 'assert';
2+
import assert from 'node:assert';
33
import { Arr } from '../src/helpers.js';
44

55
const exampleArray = new Arr([

test/pushIfNotExists.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'node:test';
2-
import assert from 'assert';
2+
import assert from 'node:assert';
33
import { Arr } from '../src/helpers.js';
44

55
const a = new Arr();

test/pushMultiple.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'node:test';
2-
import assert from 'assert';
2+
import assert from 'node:assert';
33
import { Arr } from '../src/helpers.js';
44

55
const a = new Arr();

test/pushMultipleIfNotExists.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'node:test';
2-
import assert from 'assert';
2+
import assert from 'node:assert';
33
import { Arr } from '../src/helpers.js';
44

55
const a = new Arr();

test/random.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'node:test';
2-
import assert from 'assert';
2+
import assert from 'node:assert';
33
import { Arr } from '../src/helpers.js';
44

55
const exampleArray = new Arr([1, 2, 3]);

test/summ.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'node:test';
2-
import assert from 'assert';
2+
import assert from 'node:assert';
33
import { Arr } from '../src/helpers.js';
44

55
const exampleArray = new Arr([1, 2, 3]);

test/unique.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'node:test';
2-
import assert from 'assert';
2+
import assert from 'node:assert';
33
import { Arr } from '../src/helpers.js';
44

55
const a = new Arr(['John', 'Peter', 'Luke', 'Peter', 'Luke', 'Paul']);

test/update.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import test from 'node:test';
2-
import assert from 'assert';
2+
import assert from 'node:assert';
33
import { Arr } from '../src/helpers.js';
44

55
const exampleArray = new Arr([

0 commit comments

Comments
 (0)