diff --git a/index.js b/index.js index 61a7698..cca8fec 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,4 @@ -const sortby = (properties) => (a, b) => { +const sortby = (...properties) => (a, b) => { // 'base' treat accent as there base character const collator = new Intl.Collator('en', { numeric: true, sensitivity: 'base' }) diff --git a/lib/sortby.test.js b/lib/sortby.test.js index 5829e0b..3578a4a 100644 --- a/lib/sortby.test.js +++ b/lib/sortby.test.js @@ -11,7 +11,7 @@ const data = [ ] test('sort by name ascending', () => { - const result = data.sort(sortby(['name'])) + const result = data.sort(sortby('name')) equal(result, [ { age: 40, name: "Persone 1", new: true }, @@ -20,7 +20,7 @@ test('sort by name ascending', () => { }) test('sort by age ascending', () => { - const result = data.sort(sortby(['age'])) + const result = data.sort(sortby('age')) equal(result, [ { age: 17, name: "Persone 2", new: false }, @@ -29,7 +29,7 @@ test('sort by age ascending', () => { }) test('sort by age descending', () => { - const result = data.sort(sortby(['age', 'desc'])) + const result = data.sort(sortby('age', 'desc')) equal(result, [ { age: 40, name: "Persone 1", new: true }, @@ -38,7 +38,7 @@ test('sort by age descending', () => { }) test('sort by new descending', () => { - const result = data.sort(sortby(['new', 'desc'])) + const result = data.sort(sortby('new', 'desc')) equal(result, [ { age: 40, name: "Persone 1", new: true }, @@ -49,7 +49,7 @@ test('sort by new descending', () => { test('sort with accent, should not change order', () => { const data = [{ name: 'è' }, { name: 'é' }, { name: 'e' }] - const result = data.sort(sortby(['name'])) + const result = data.sort(sortby('name')) equal(result, [{ name: 'è' }, { name: 'é' }, { name: 'e' }]) }) diff --git a/package-lock.json b/package-lock.json index 529611b..9c67d3d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "sortby", - "version": "1.0.0", + "version": "2.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "sortby", - "version": "1.0.0", + "version": "2.0.0", "license": "AGPL-3.0-or-later", "dependencies": { "metaltest": "git+https://git.tranche.ca/fmatte/metaltest" diff --git a/package.json b/package.json index b25b4f6..62af775 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "sortby", "description": "Sort object by property name", - "version": "1.0.0", + "version": "2.0.0", "author": "Frédéric Matte ", "license": "AGPL-3.0-or-later", "main": "index.js",