node-print: upgrade to 11

This commit is contained in:
ptrcnull 2023-04-28 05:11:30 +02:00
parent 77b7daa719
commit e322afd0db
2 changed files with 18 additions and 6 deletions

View file

@ -1,7 +1,7 @@
# Contributor: Patrycja Rosa <alpine@ptrcnull.me> # Contributor: Patrycja Rosa <alpine@ptrcnull.me>
# Maintainer: Patrycja Rosa <alpine@ptrcnull.me> # Maintainer: Patrycja Rosa <alpine@ptrcnull.me>
pkgname=node-print pkgname=node-print
pkgver=10 pkgver=11
pkgrel=0 pkgrel=0
pkgdesc="another terrible javascript engine wrapper" pkgdesc="another terrible javascript engine wrapper"
url="https://git.ddd.rip/ptrcnull/ptrcports" url="https://git.ddd.rip/ptrcnull/ptrcports"
@ -43,5 +43,5 @@ package() {
sha512sums=" sha512sums="
b3dfdeb49637be33d2e2718c5abcf35a87dd55023918c99341273c3b38bd6685189d1f786451a742c47c5f3bc3b58555decb58e2a3a018c9b9ee92043f8fac03 np b3dfdeb49637be33d2e2718c5abcf35a87dd55023918c99341273c3b38bd6685189d1f786451a742c47c5f3bc3b58555decb58e2a3a018c9b9ee92043f8fac03 np
85ad9dfdfc32afa606855d0484fa43bdc52c0d2f66e8702e98ebc37621e3f961a3939fdb4b21e4518505160b9fb1a52c70ad9185c81e484374f94b52b4f26a13 index.js 3355f0f044726a75111f7a2788c5eb6150e44c7f9b4789973a6dda9ac980bc6133677067007e9c40f4c576ad2f8365922f98eda422e690a12775025eb788b584 index.js
" "

View file

@ -1,5 +1,7 @@
const fs = require('fs')
const child_process = require('child_process')
global.stdin = () => { global.stdin = () => {
const fs = require('fs')
const out = fs.readFileSync(0).toString() const out = fs.readFileSync(0).toString()
return out.tryParseJSON() return out.tryParseJSON()
} }
@ -8,6 +10,8 @@ Object.prototype.map = function(cb) {
return cb(this) return cb(this)
} }
Object.prototype.apply = Object.prototype.map
String.prototype.lines = function() { String.prototype.lines = function() {
let res = this.split("\n") let res = this.split("\n")
return res.at(-1) === '' ? res.slice(0, -1) : res return res.at(-1) === '' ? res.slice(0, -1) : res
@ -48,10 +52,18 @@ Buffer.prototype.tryParseJSON = function() {
} }
global.exec = (command, args, options) => { global.exec = (command, args, options) => {
const child_process = require('child_process')
const res = child_process.spawnSync(command, args, options) const res = child_process.spawnSync(command, args, options)
res.stdout = res.stdout?.tryParseJSON() res.stdout = res.stdout?.tryParseJSON()
res.stderr = res.stderr?.tryParseJSON() res.stderr = res.stderr?.tryParseJSON()
res.orFail = function() {
if (res.status !== 0) {
const cmd = [
command,
...((args && Array.isArray(args)) ? args : [])
].join(' ')
throw new Error(`command '${cmd}' exited with code ${res.status}`)
}
}
return res return res
} }
@ -86,8 +98,8 @@ Array.prototype.product = function(def = 1) {
return this.reduce((a, b) => a * b, def) return this.reduce((a, b) => a * b, def)
} }
Array.prototype.sortNum = function() { Array.prototype.sortNum = function(getter = (x => x)) {
return this.sort((a, b) => a - b) return this.sort((a, b) => getter(a) - getter(b))
} }
Array.prototype.partition = function(compareFn) { Array.prototype.partition = function(compareFn) {