From 385436ee3f002764abcdc418d66b837320db95f1 Mon Sep 17 00:00:00 2001 From: ptrcnull Date: Fri, 2 Dec 2022 22:51:51 +0100 Subject: [PATCH] node-print: upgrade to 6 --- node-print/APKBUILD | 4 ++-- node-print/index.js | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/node-print/APKBUILD b/node-print/APKBUILD index 37b5311..f46ccb8 100644 --- a/node-print/APKBUILD +++ b/node-print/APKBUILD @@ -1,7 +1,7 @@ # Contributor: Patrycja Rosa # Maintainer: Patrycja Rosa pkgname=node-print -pkgver=5 +pkgver=6 pkgrel=0 pkgdesc="another terrible javascript engine wrapper" url="https://git.ddd.rip/ptrcnull/ptrcports" @@ -43,5 +43,5 @@ package() { sha512sums=" b3dfdeb49637be33d2e2718c5abcf35a87dd55023918c99341273c3b38bd6685189d1f786451a742c47c5f3bc3b58555decb58e2a3a018c9b9ee92043f8fac03 np -afcc775f7d76b05bf72eef59a47b02d9a2021b09015b37502eaa457d9b38f3259a99c2ebf8ed8b5a1e36b27dd13ab447f2e673467d5717b60452d8c585aba995 index.js +56d67b0da1149a65902c7d60d9063c0846eac2229cba664879991ded528b14ab87d00ef68e270e5f4e4fd56c68c50502e51932b32eec1965ba6bea44a1061d14 index.js " diff --git a/node-print/index.js b/node-print/index.js index de82535..8247462 100644 --- a/node-print/index.js +++ b/node-print/index.js @@ -57,3 +57,41 @@ global.apkindex = () => stdin() .filter(str => str.length) .map(x => Object.fromEntries(x.split("\n").map(e => [e.at(0), e.slice(2)]))) .filter(Boolean) + +Array.prototype.sum = function(def = 0) { + return this.reduce((a, b) => a + b, def) +} + +Array.prototype.sortNum = function() { + return this.sort((a, b) => a - b) +} + +Array.prototype.partition = function(compareFn) { + const a = [] + const b = [] + this.forEach((elem, i, arr) => { + if (compareFn(elem, i, arr)) { + a.push(elem) + } else { + b.push(elem) + } + }) + return [a, b] +} + +Array.prototype.chunks = function(chunkSize) { + // inspired by https://stackoverflow.com/questions/8495687/split-array-into-chunks#comment84212474_8495740 + return new Array(Math.ceil(this.length / chunkSize)) + .fill() + .map((_, i) => this.slice(i * chunkSize, (i + 1) * chunkSize)) +} + +Set.prototype.union = function(other) { + if (!other || !(other instanceof Set)) throw new TypeError('other must be a Set') + return new Set([...this, ...other]) +} + +Set.prototype.intersection = function(other) { + if (!other || !(other instanceof Set)) throw new TypeError('other must be a Set') + return new Set([...this].filter(el => other.has(el))) +}