19 lines
349 B
JavaScript
19 lines
349 B
JavaScript
|
global.stdin = () => {
|
||
|
const fs = require('fs')
|
||
|
const out = fs.readFileSync(0).toString()
|
||
|
if (out.at(0) === '{') {
|
||
|
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
|
||
|
}
|