Skip to content

Commit

Permalink
Merge pull request #34 from hckrnews/feature/esm
Browse files Browse the repository at this point in the history
ESM only
  • Loading branch information
w3nl authored Dec 18, 2023
2 parents 3bcdda9 + 5a18e04 commit efb44a4
Show file tree
Hide file tree
Showing 29 changed files with 2,245 additions and 6,960 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@
"jsdoc": {
"mode": "typescript"
}
},
}
}
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.4.0
20.10.0
28 changes: 14 additions & 14 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"compilerOptions": {
"checkJs": true,
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "node",
"rootDirs": [
"src"
],
"resolveJsonModule": true
},
"exclude": [
"node_modules",
"**/node_modules/*"
]
"compilerOptions": {
"checkJs": true,
"target": "ESNext",
"module": "NodeNext",
"moduleResolution": "nodenext",
"rootDirs": [
"src"
],
"resolveJsonModule": true
},
"exclude": [
"node_modules",
"**/node_modules/*"
]
}
9,086 changes: 2,198 additions & 6,888 deletions package-lock.json

Large diffs are not rendered by default.

35 changes: 5 additions & 30 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hckrnews/arrays",
"version": "3.1.8",
"version": "4.0.0",
"description": "Usefull array helpers.",
"files": [
"src/helpers.js",
Expand All @@ -19,30 +19,11 @@
"src/modules/summ.js",
"src/modules/toJson.js",
"src/modules/unique.js",
"src/modules/update.js",
"dist/helpers.cjs",
"dist/helpers.cjs.map",
"dist/helpers.js",
"dist/helpers.js.map",
"dist/helpers.module.mjs",
"dist/helpers.module.mjs.map",
"dist/helpers.umd.cjs",
"dist/helpers.umd.cjs.map"
"src/modules/update.js"
],
"main": "dist/helpers.umd.cjs",
"main": "src/helpers.js",
"source": "src/helpers.js",
"module": "dist/helpers.module.mjs",
"unpkg": "dist/helpers.umd.cjs",
"umd:main": "dist/helpers.umd.cjs",
"exports": {
"node": {
"default": "./dist/helpers.umd.cjs",
"module": "./src/helpers.js",
"require": "./dist/helpers.umd.cjs"
},
"require": "./dist/helpers.umd.cjs",
"default": "./dist/helpers.umd.cjs"
},
"module": "src/helpers.js",
"repository": {
"type": "git",
"url": "https://github.com/hckrnews/arrays.git"
Expand All @@ -68,8 +49,7 @@
"test": "c8 node --test test/*.js",
"example": "node example/node.js",
"cpd": "node_modules/jscpd/bin/jscpd src",
"vulnerabilities": "npm audit --production",
"build": "microbundle --target node src/helpers.js"
"vulnerabilities": "npm audit --production"
},
"devDependencies": {
"@hckrnews/eslint-config": "^3.0.0",
Expand All @@ -82,7 +62,6 @@
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prettier": "^5.0.0",
"jscpd": "^3.4.5",
"microbundle": "^0.15.1",
"prettier": "^3.0.0"
},
"type": "module",
Expand All @@ -95,9 +74,5 @@
},
"overrides": {
"xml2js": "^0.5.0"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/w3nl"
}
}
6 changes: 3 additions & 3 deletions src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class Arr extends Array {
* Filter a multi array.
*
* @param {string} key
* @param {string} find
* @param {boolean=} operator
* @param {any} find
* @param {(boolean|string)=} operator
*
* @return {any[]}
*/
Expand All @@ -50,7 +50,7 @@ class Arr extends Array {
/**
* Only get some keys of a multi array.
*
* @param {string} key
* @param {string|string[]} key
*
* @return {any[]}
*/
Expand Down
2 changes: 1 addition & 1 deletion src/modules/first.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ export default function first(originalArray) {
return null;
}

return originalArray[0];
return originalArray.at(0);
}
2 changes: 1 addition & 1 deletion src/modules/last.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ export default function last(originalArray) {
return null;
}

return originalArray[originalArray.length - 1];
return originalArray.at(-1);
}
2 changes: 1 addition & 1 deletion test/arr.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from 'node:test';
import assert from 'assert';
import assert from 'node:assert';
import { Arr } from '../src/helpers.js';

const original = new Arr(1, 2, 3);
Expand Down
2 changes: 1 addition & 1 deletion test/average.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from 'node:test';
import assert from 'assert';
import assert from 'node:assert';
import { Arr } from '../src/helpers.js';

test('Average', async (t) => {
Expand Down
2 changes: 1 addition & 1 deletion test/diff-object.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from 'node:test';
import assert from 'assert';
import assert from 'node:assert';
import { Arr } from '../src/helpers.js';

const a = new Arr([{ name: 'John' }, { name: 'Peter' }, { name: 'Luke' }]);
Expand Down
2 changes: 1 addition & 1 deletion test/diff.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from 'node:test';
import assert from 'assert';
import assert from 'node:assert';
import { Arr } from '../src/helpers.js';

const a = new Arr(['John', 'Peter', 'Luke']);
Expand Down
2 changes: 1 addition & 1 deletion test/first.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from 'node:test';
import assert from 'assert';
import assert from 'node:assert';
import { Arr } from '../src/helpers.js';

test('First', async (t) => {
Expand Down
2 changes: 1 addition & 1 deletion test/getByKey.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from 'node:test';
import assert from 'assert';
import assert from 'node:assert';
import { Arr } from '../src/helpers.js';

const getTestCases = [
Expand Down
2 changes: 1 addition & 1 deletion test/intersect-object.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from 'node:test';
import assert from 'assert';
import assert from 'node:assert';
import { Arr } from '../src/helpers.js';

const a = new Arr([{ name: 'John' }, { name: 'Peter' }, { name: 'Luke' }]);
Expand Down
2 changes: 1 addition & 1 deletion test/intersect.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from 'node:test';
import assert from 'assert';
import assert from 'node:assert';
import { Arr } from '../src/helpers.js';

const a = new Arr(['John', 'Peter', 'Luke']);
Expand Down
2 changes: 1 addition & 1 deletion test/last.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from 'node:test';
import assert from 'assert';
import assert from 'node:assert';
import { Arr } from '../src/helpers.js';

test('Last', async (t) => {
Expand Down
2 changes: 1 addition & 1 deletion test/max.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from 'node:test';
import assert from 'assert';
import assert from 'node:assert';
import { Arr } from '../src/helpers.js';

const exampleArray = new Arr([1, 2, 3]);
Expand Down
2 changes: 1 addition & 1 deletion test/min.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from 'node:test';
import assert from 'assert';
import assert from 'node:assert';
import { Arr } from '../src/helpers.js';

const exampleArray = new Arr([1, 2, 3]);
Expand Down
2 changes: 1 addition & 1 deletion test/multifilter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from 'node:test';
import assert from 'assert';
import assert from 'node:assert';
import { Arr } from '../src/helpers.js';

const exampleArray = new Arr([
Expand Down
2 changes: 1 addition & 1 deletion test/multikey.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from 'node:test';
import assert from 'assert';
import assert from 'node:assert';
import { Arr } from '../src/helpers.js';

const exampleArray = new Arr([
Expand Down
2 changes: 1 addition & 1 deletion test/multisort.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from 'node:test';
import assert from 'assert';
import assert from 'node:assert';
import { Arr } from '../src/helpers.js';

const exampleArray = new Arr([
Expand Down
2 changes: 1 addition & 1 deletion test/pushIfNotExists.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from 'node:test';
import assert from 'assert';
import assert from 'node:assert';
import { Arr } from '../src/helpers.js';

const a = new Arr();
Expand Down
2 changes: 1 addition & 1 deletion test/pushMultiple.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from 'node:test';
import assert from 'assert';
import assert from 'node:assert';
import { Arr } from '../src/helpers.js';

const a = new Arr();
Expand Down
2 changes: 1 addition & 1 deletion test/pushMultipleIfNotExists.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from 'node:test';
import assert from 'assert';
import assert from 'node:assert';
import { Arr } from '../src/helpers.js';

const a = new Arr();
Expand Down
2 changes: 1 addition & 1 deletion test/random.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from 'node:test';
import assert from 'assert';
import assert from 'node:assert';
import { Arr } from '../src/helpers.js';

const exampleArray = new Arr([1, 2, 3]);
Expand Down
2 changes: 1 addition & 1 deletion test/summ.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from 'node:test';
import assert from 'assert';
import assert from 'node:assert';
import { Arr } from '../src/helpers.js';

const exampleArray = new Arr([1, 2, 3]);
Expand Down
2 changes: 1 addition & 1 deletion test/unique.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from 'node:test';
import assert from 'assert';
import assert from 'node:assert';
import { Arr } from '../src/helpers.js';

const a = new Arr(['John', 'Peter', 'Luke', 'Peter', 'Luke', 'Paul']);
Expand Down
2 changes: 1 addition & 1 deletion test/update.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from 'node:test';
import assert from 'assert';
import assert from 'node:assert';
import { Arr } from '../src/helpers.js';

const exampleArray = new Arr([
Expand Down

0 comments on commit efb44a4

Please sign in to comment.