How to import *.json
?
As already answered you need Typescript >= 2.9 and the following settings in tsconfig.json:
{
"resolveJsonModule": true,
"esModuleInterop": true,
"module": "commonjs"
}
import { appendFile, existsSync, mkdirSync } from "fs"; | |
import { join } from "path"; | |
let GLOBAL_COUNT = 0; | |
export class Log { | |
private dir: string | |
constructor(private name: string) { | |
this.dir = join(process.cwd(), "logs"); | |
this.checkDir(); | |
} |
How to import *.json
?
As already answered you need Typescript >= 2.9 and the following settings in tsconfig.json:
{
"resolveJsonModule": true,
"esModuleInterop": true,
"module": "commonjs"
}
const http = require("http"), | |
url = require("url"); | |
http.createServer((proxyReq, proxyRes) => { | |
console.log(proxyReq.url); | |
const options = url.parse(proxyReq.url); | |
const svr = http.request(options, svrRes => { | |
svrRes.pipe(proxyRes, { end: true }); | |
}); | |
proxyReq.pipe(svr, { |
netsh interface portproxy add v4tov4 protocol=tcp connectaddress=192.168.67.128 connectport=9091 listenport=9091
const fs = require("fs"), path = require("path"); | |
let debugMode = false; | |
//#region 日志函数 | |
function log(txt) { | |
if (debugMode) { | |
console.log(`[${new Date().toLocaleString()}] ${txt}`); | |
} | |
} | |
function warn(txt) { |
/** | |
* 所有Promise都被 settled | |
* @param {[{promise: function():Promise, data: {}}]} promises | |
* @retu {Promise<[{isResolve: boolean, isReject: boolean, error: {}, result: {}, data: {}}]>} | |
*/ | |
Promise.whenAllSettled = function (promises) { | |
const isPromise = function (obj) { | |
return obj && typeof obj.then === "function" && typeof obj.catch === "function"; | |
}; |
编辑 /etc/apk/repositories
,然后在文件的最顶端添加(注意将 3.3 换成需要的版本)
http://mirrors.ustc.edu.cn/alpine/v3.3/main/
{ | |
"globals" : | |
{ | |
"alwaysShowTabs" : true, | |
"defaultProfile" : "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}", | |
"initialCols" : 120, | |
"initialRows" : 30, | |
"keybindings" : | |
[ | |
{ |
# 0. Your file name | |
FNAME="$2" | |
# 1. Somehow sanitize the file content | |
# Remove \r (from Windows end-of-lines), | |
# Replace tabs by \t | |
# Replace " by \" | |
# Replace EOL by \n | |
CONTENT=$(sed -e 's/\r//' -e's/\t/\\t/g' -e 's/"/\\"/g' "${FNAME}" | awk '{ printf($0 "\\n") }') |
#r "nuget: Newtonsoft.Json, 12.0.2" | |
using System.Net.Http; | |
using static System.Console; | |
using Newtonsoft.Json; | |
using static Newtonsoft.Json.JsonConvert; | |
if (Args.Count == 0) | |
{ | |
Console.WriteLine($@" |