From be0aef322f293628d77c3d31719c2fafb0a991e6 Mon Sep 17 00:00:00 2001 From: ptrcnull Date: Fri, 19 May 2023 19:59:00 +0200 Subject: [PATCH] node-print: upgrade to 13 adds set difference --- node-print/APKBUILD | 2 +- node-print/index.js | 5 +++++ node-print/test.js | 13 +++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/node-print/APKBUILD b/node-print/APKBUILD index fa089fb..b341112 100644 --- a/node-print/APKBUILD +++ b/node-print/APKBUILD @@ -1,7 +1,7 @@ # Contributor: Patrycja Rosa # Maintainer: Patrycja Rosa pkgname=node-print -pkgver=12 +pkgver=13 pkgrel=0 pkgdesc="another terrible javascript engine wrapper" url="https://git.ddd.rip/ptrcnull/ptrcports" diff --git a/node-print/index.js b/node-print/index.js index 9975642..6af3afa 100644 --- a/node-print/index.js +++ b/node-print/index.js @@ -148,6 +148,11 @@ Set.prototype.intersection = function(other) { return new Set([...this].filter(el => other.has(el))) } +Set.prototype.difference = function(other) { + if (!other || !(other instanceof Set)) throw new TypeError('other must be a Set') + return new Set([...this].filter(el => !other.has(el))) +} + Set.prototype.at = function(index) { return [...this].at(index) } diff --git a/node-print/test.js b/node-print/test.js index 5f04c53..e323b8c 100644 --- a/node-print/test.js +++ b/node-print/test.js @@ -196,6 +196,19 @@ test('Set.prototype.intersection', t => { ) }) +test('Set.prototype.difference', t => { + const left = new Set([1, 2, 3]) + const right = new Set([2, 4]) + assert.deepEqual( + new Set([1, 3]), + left.difference(right) + ) + assert.deepEqual( + new Set([4]), + right.difference(left) + ) +}) + test('Set.prototype.at - single element', t => { assert.equal( 2,