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,