node-print: upgrade to 9
This commit is contained in:
parent
8e00d3d8d4
commit
1d44cf0ccc
2 changed files with 38 additions and 4 deletions
|
@ -1,7 +1,7 @@
|
|||
# Contributor: Patrycja Rosa <alpine@ptrcnull.me>
|
||||
# Maintainer: Patrycja Rosa <alpine@ptrcnull.me>
|
||||
pkgname=node-print
|
||||
pkgver=8
|
||||
pkgver=9
|
||||
pkgrel=0
|
||||
pkgdesc="another terrible javascript engine wrapper"
|
||||
url="https://git.ddd.rip/ptrcnull/ptrcports"
|
||||
|
@ -43,5 +43,5 @@ package() {
|
|||
|
||||
sha512sums="
|
||||
b3dfdeb49637be33d2e2718c5abcf35a87dd55023918c99341273c3b38bd6685189d1f786451a742c47c5f3bc3b58555decb58e2a3a018c9b9ee92043f8fac03 np
|
||||
4e80247d16485e2ca4e0d4e92523a5a99727dba20e5c3e64737d74676853d1a92278d54bccf5d4a5d159dc282f95cd484b3e7bbc206b0675d7b50e37c428f125 index.js
|
||||
78e8f576fe7d13394c08fc7746817cfaf61ff76fd779f09fb0ace9ac72a5fd7202479624b50f1b4b03375aae86685a8da9d7e7c034dc69ee4b5fb336ee37fdb1 index.js
|
||||
"
|
||||
|
|
|
@ -17,6 +17,11 @@ String.prototype.reverse = function() {
|
|||
return this.split('').reverse().join('')
|
||||
}
|
||||
|
||||
String.prototype.includesAny = function(strings) {
|
||||
if (!(strings instanceof Array)) throw new TypeError('strings must be an Array')
|
||||
return strings.some(x => this.includes(x))
|
||||
}
|
||||
|
||||
String.prototype.tryParseJSON = function() {
|
||||
const str = this.trim()
|
||||
if (
|
||||
|
@ -55,8 +60,17 @@ global.exec = (command, args, options) => {
|
|||
global.apkindex = () => stdin()
|
||||
.split("\n\n")
|
||||
.filter(str => str.length)
|
||||
.map(x => Object.fromEntries(x.split("\n").map(e => [e.at(0), e.slice(2)])))
|
||||
.filter(Boolean)
|
||||
.map(x => Object.fromEntries(x.lines().map(e => [e.at(0), e.slice(2)])))
|
||||
.map(pkg => ({
|
||||
...pkg,
|
||||
S: Number(pkg.S),
|
||||
I: Number(pkg.I),
|
||||
t: new Date(Number(pkg.t) * 1000),
|
||||
i: pkg.i?.split(' '),
|
||||
D: pkg.D?.split(' '),
|
||||
p: pkg.p?.split(' ')
|
||||
}))
|
||||
.map(Object.prune)
|
||||
|
||||
Array.prototype.sum = function(def = 0) {
|
||||
return this.reduce((a, b) => a + b, def)
|
||||
|
@ -90,6 +104,10 @@ Array.prototype.chunks = function(chunkSize) {
|
|||
.map((_, i) => this.slice(i * chunkSize, (i + 1) * chunkSize))
|
||||
}
|
||||
|
||||
Array.prototype.transpose = function() {
|
||||
return new Array(this[0].length).fill().map((_, i) => this.map(x => x[i]))
|
||||
}
|
||||
|
||||
Set.prototype.union = function(other) {
|
||||
if (!other || !(other instanceof Set)) throw new TypeError('other must be a Set')
|
||||
return new Set([...this, ...other])
|
||||
|
@ -118,3 +136,19 @@ Number.prototype.toXY = function(width) {
|
|||
if (!(width && typeof width === 'number')) throw new TypeError('width must be a Number')
|
||||
return [ this % width, Math.floor(this / width) ]
|
||||
}
|
||||
|
||||
global.sed = function(filename, cb) {
|
||||
let content = fs.readFileSync(filename, 'utf-8')
|
||||
content = cb(content)
|
||||
fs.writeFileSync(filename, content, 'utf-8')
|
||||
}
|
||||
|
||||
Object.prune = function(obj) {
|
||||
if (typeof obj !== 'object') throw new TypeError('obj must be an object')
|
||||
for (let key of Object.keys(obj)) {
|
||||
if (obj[key] === undefined) {
|
||||
delete obj[key]
|
||||
}
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue