diff --git a/package-lock.json b/package-lock.json index e0519c6..a8acb82 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,7 @@ "esm-runner": "^0.3.4", "isomorphic-assert": "^0.1.1", "jsdoc-to-markdown": "^7.0.0", - "rollup": "^2.40.0", + "rollup": "^2.42.1", "rollup-plugin-node-resolve": "^5.2.0", "test-object-model": "^0.6.1" }, @@ -2268,9 +2268,9 @@ } }, "node_modules/rollup": { - "version": "2.40.0", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.40.0.tgz", - "integrity": "sha512-WiOGAPbXoHu+TOz6hyYUxIksOwsY/21TRWoO593jgYt8mvYafYqQl+axaA8y1z2HFazNUUrsMSjahV2A6/2R9A==", + "version": "2.42.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.42.1.tgz", + "integrity": "sha512-/y7M2ULg06JOXmMpPzhTeQroJSchy8lX8q6qrjqil0jmLz6ejCWbQzVnWTsdmMQRhfU0QcwtiW8iZlmrGXWV4g==", "dev": true, "bin": { "rollup": "dist/bin/rollup" @@ -4684,9 +4684,9 @@ } }, "rollup": { - "version": "2.40.0", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.40.0.tgz", - "integrity": "sha512-WiOGAPbXoHu+TOz6hyYUxIksOwsY/21TRWoO593jgYt8mvYafYqQl+axaA8y1z2HFazNUUrsMSjahV2A6/2R9A==", + "version": "2.42.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.42.1.tgz", + "integrity": "sha512-/y7M2ULg06JOXmMpPzhTeQroJSchy8lX8q6qrjqil0jmLz6ejCWbQzVnWTsdmMQRhfU0QcwtiW8iZlmrGXWV4g==", "dev": true, "requires": { "fsevents": "~2.3.1" diff --git a/package.json b/package.json index 617f314..ea2c662 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "repository": "https://github.com/75lb/sort-array", "license": "MIT", "main": "dist/index.js", - "module": "index.mjs", + "type": "module", "keywords": [ "sort", "by", @@ -38,7 +38,7 @@ "esm-runner": "^0.3.4", "isomorphic-assert": "^0.1.1", "jsdoc-to-markdown": "^7.0.0", - "rollup": "^2.40.0", + "rollup": "^2.42.1", "rollup-plugin-node-resolve": "^5.2.0", "test-object-model": "^0.6.1" }, diff --git a/test/sort-custom-order.mjs b/test/sort-custom-order.mjs index 5b258b6..7ad9492 100644 --- a/test/sort-custom-order.mjs +++ b/test/sort-custom-order.mjs @@ -199,6 +199,40 @@ async function getTom () { a.deepStrictEqual(result, expected) }) + tom.todo('Alphanumeric then date sort', async function () { + const fixture = [ + { id: 'ZZ01', date: new Date('2021-01-01') }, + { id: 'AB01', date: new Date('2021-01-01') }, + { id: 'AB010', date: new Date('2021-01-01') }, + { id: 'AB02', date: new Date('2021-01-01') }, + { id: 'L', date: new Date('2021-01-01') }, + { id: 'L4', date: new Date('2021-01-03') }, + { id: 'L4', date: new Date('2021-01-01') }, + { id: 'L4', date: new Date('2021-01-05') }, + { id: '4L40', date: new Date('2021-01-01') }, + { id: '4L5', date: new Date('2021-01-01') }, + ] + const expected = [ + { id: '4L5', date: new Date('2021-01-01') }, + { id: '4L40', date: new Date('2021-01-01') }, + { id: 'AB01', date: new Date('2021-01-01') }, + { id: 'AB02', date: new Date('2021-01-01') }, + { id: 'AB010', date: new Date('2021-01-01') }, + { id: 'L', date: new Date('2021-01-01') }, + { id: 'L4', date: new Date('2021-01-01') }, + { id: 'L4', date: new Date('2021-01-03') }, + { id: 'L4', date: new Date('2021-01-05') }, + { id: 'ZZ01', date: new Date('2021-01-01') }, + ] + const by = ['id', 'date'] + const order = ['alphaNumeric'] + const customOrders = { + alphaNumeric: (a, b) => a.localeCompare(b, 'en', { numeric: true }) + } + const result = sortArray(fixture, { by, order, customOrders }) + a.deepStrictEqual(result, expected) + }) + return tom } diff --git a/test/sort-falsy.mjs b/test/sort-null-undefined.mjs similarity index 100% rename from test/sort-falsy.mjs rename to test/sort-null-undefined.mjs