From 993a2eef96c055ee7237d97898c2ce7d606b2636 Mon Sep 17 00:00:00 2001 From: Ray Date: Sun, 13 Oct 2024 19:30:22 +0100 Subject: [PATCH] Added distinct array --- package.json | 2 +- src/extensions/array.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 5ff135d..0dcb509 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "LiteRyzJS", - "version": "0.1.0.397", + "version": "0.1.0.424", "devDependencies": { "css-loader": "^7.1.2", "sass": "^1.77.8", diff --git a/src/extensions/array.js b/src/extensions/array.js index e551376..1aad74c 100644 --- a/src/extensions/array.js +++ b/src/extensions/array.js @@ -160,6 +160,14 @@ Array.prototype.create = function (length, value) { return result }; +Array.prototype.distinct = function () { + this = this.filter((obj, index, self) => + index === self.findIndex((x) => JSON.stringify(x) === JSON.stringify(obj)) + ); + + return this; +} + /** * Convert this array of objects to a linear/one-dimensional array using a property. * @param {*} propName Property name.