// 实现暂停功能
function sleep(time) {
    let start = Date.now();
    let i = 0;
    while (true) {
        let currentTime = Date.now();
        if (currentTime - start >= time) {
            break;
        }
    }
}
// console.log(Date.now());
// sleep(2000);
// console.log(Date.now());

function sleep1(time, callback) {
    setTimeout(callback, time)
}

// console.log(Date.now());
// sleep1(2000,function(){
//     console.log(Date.now());
// })
function sleep2(time) {
    return new Promise((resovle) => {
        setTimeout(resovle, time);
    });
}
// console.log(Date.now());
sleep2(2000).then(() => {
    sleep2(2000).then(() => {
        console.log(Date.now());
    })
})

async function test() {
    console.log(Date.now());
    await sleep2(2000);
    await sleep2(2000);
    console.log(Date.now());
}
// test();

// 纯真IP 不支持ipv6
//npm i lib-qqwry 
const libqqwry = require('lib-qqwry');
const qqwry = libqqwry() //初始化IP库解析器
qqwry.speed(); //启用急速模式;


const ip1 = qqwry.searchIP("202.103.102.10"); //查询IP信息
console.log(ip1)

const ip2 = qqwry.searchIP("127.0.0.1"); //查询IP信息
console.log(ip2)








// 支持ipv6
//npm i ip2region 
const IP2Region = require("ip2region").default;
const query = new IP2Region();

const res = query.search('202.103.102.10');
console.log(res);
const res2 = query.search('240e:47d:c20:1627:30a3:ba0d:a5e6:ec19');
console.log(res2);
const res3 = query.search('192.168.10.11');
console.log(res3);
const res4 = query.search('::1');
console.log(res4);
const res5 = query.search('1.1.1.1');
console.log(res5);