2022-08-27 11:01:43 +00:00
|
|
|
global.stdin = () => {
|
|
|
|
const fs = require('fs')
|
|
|
|
const out = fs.readFileSync(0).toString()
|
2022-08-27 11:51:10 +00:00
|
|
|
if (out.at(0) === '{' || out.at(0) === '[') {
|
2022-08-27 11:01:43 +00:00
|
|
|
return JSON.parse(out)
|
|
|
|
} else {
|
|
|
|
return out
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Object.prototype.map = function(cb) {
|
|
|
|
return cb(this)
|
|
|
|
}
|
|
|
|
|
|
|
|
String.prototype.lines = function() {
|
|
|
|
let res = this.split("\n")
|
|
|
|
return res.at(-1) === '' ? res.slice(0, -1) : res
|
|
|
|
}
|
2022-08-27 12:08:44 +00:00
|
|
|
|
|
|
|
String.prototype.reverse = function() {
|
|
|
|
return this.split('').reverse().join('')
|
|
|
|
}
|